Search in sources :

Example 56 with Transaction

use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.

the class AccountRepositoryIntegrationTest method getMultipleTransactions.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMultipleTransactions(RepositoryType type) {
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    Account account = config().getDefaultAccount();
    List<TransactionType> transactionTypes = Arrays.asList(TransactionType.TRANSFER, TransactionType.AGGREGATE_COMPLETE, TransactionType.NAMESPACE_METADATA);
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).signerPublicKey(account.getPublicAccount().getPublicKey()).transactionTypes(transactionTypes))).getData();
    Assertions.assertFalse(transactions.isEmpty());
    transactions.forEach(t -> Assertions.assertTrue(transactionTypes.contains(t.getType())));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 57 with Transaction

use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.

the class BlockRepositoryIntegrationTest method getMerkleTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMerkleTransaction(RepositoryType type) {
    BlockRepository blockRepository = getBlockRepository(type);
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    List<Transaction> list = get(streamer.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED)).take(5).toList().toObservable());
    Assertions.assertFalse(list.isEmpty());
    list.forEach(s -> {
        String hash = s.getTransactionInfo().get().getHash().get();
        BigInteger height = s.getTransactionInfo().get().getHeight();
        MerkleProofInfo merkleProofInfo = get(blockRepository.getMerkleTransaction(height, hash));
        Assertions.assertFalse(merkleProofInfo.getMerklePath().isEmpty());
    });
}
Also used : BlockRepository(io.nem.symbol.sdk.api.BlockRepository) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) BigInteger(java.math.BigInteger) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) MerkleProofInfo(io.nem.symbol.sdk.model.blockchain.MerkleProofInfo) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 58 with Transaction

use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.

the class ListenerIntegrationTest method shouldReturnUnconfirmedAddedTransactionViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnUnconfirmedAddedTransactionViaListener(RepositoryType type) {
    Listener listener = getListener(type);
    SignedTransaction signedTransaction = this.announceStandaloneTransferTransaction(type, this.getRecipient());
    Transaction transaction = get(listener.unconfirmedAdded(this.account.getAddress(), signedTransaction.getHash()).take(1));
    assertEquals(signedTransaction.getHash(), transaction.getTransactionInfo().get().getHash().get());
}
Also used : Listener(io.nem.symbol.sdk.api.Listener) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 59 with Transaction

use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.

the class ListenerIntegrationTest method shouldReturnConfirmedTransactionAddressRecipientViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnConfirmedTransactionAddressRecipientViaListener(RepositoryType type) {
    Listener listener = getListener(type);
    SignedTransaction signedTransaction = this.announceStandaloneTransferTransaction(type, this.getRecipient());
    Observable<Transaction> confirmed = listener.confirmed(this.getRecipient(), signedTransaction.getHash());
    Transaction transaction = get(confirmed.take(1));
    assertEquals(signedTransaction.getHash(), transaction.getTransactionInfo().get().getHash().get());
}
Also used : Listener(io.nem.symbol.sdk.api.Listener) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) CosignatureTransaction(io.nem.symbol.sdk.model.transaction.CosignatureTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 60 with Transaction

use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.

the class BlockServiceIntegrationTest method isValidTransactionInBlock.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void isValidTransactionInBlock(RepositoryType type) {
    BigInteger height = BigInteger.ONE;
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).height(height).pageNumber(1))).getData();
    BlockService service = new BlockServiceImpl(repositoryFactory);
    transactions.forEach(t -> {
        String hash = t.getTransactionInfo().get().getHash().get();
        Assertions.assertNotNull(hash);
        Boolean valid = get(service.isValidTransactionInBlock(height, hash));
        Assertions.assertTrue(valid);
    });
}
Also used : Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) BigInteger(java.math.BigInteger) BlockService(io.nem.symbol.sdk.api.BlockService) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Transaction (io.nem.symbol.sdk.model.transaction.Transaction)125 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)107 Test (org.junit.jupiter.api.Test)78 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)70 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)65 MultisigAccountModificationTransaction (io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction)60 MosaicDefinitionTransaction (io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction)58 MosaicSupplyChangeTransaction (io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction)58 AddressAliasTransaction (io.nem.symbol.sdk.model.transaction.AddressAliasTransaction)57 MosaicAliasTransaction (io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction)57 NamespaceRegistrationTransaction (io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction)57 AccountAddressRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction)55 AccountMosaicRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction)55 MosaicMetadataTransaction (io.nem.symbol.sdk.model.transaction.MosaicMetadataTransaction)55 SecretLockTransaction (io.nem.symbol.sdk.model.transaction.SecretLockTransaction)55 SecretProofTransaction (io.nem.symbol.sdk.model.transaction.SecretProofTransaction)55 AccountKeyLinkTransaction (io.nem.symbol.sdk.model.transaction.AccountKeyLinkTransaction)54 AccountMetadataTransaction (io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction)54 AccountOperationRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction)54 NamespaceMetadataTransaction (io.nem.symbol.sdk.model.transaction.NamespaceMetadataTransaction)54