use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.
the class TransactionRepositoryOkHttpImplTest method searchTransactions.
@Test
public void searchTransactions() throws Exception {
BigInteger version = AggregateTransactionCosignature.DEFAULT_VERSION;
TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json", TransactionInfoDTO.class);
PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
mockRemoteCall(toPage(transferTransactionDTO));
Page<Transaction> transactions = repository.search(new TransactionSearchCriteria(TransactionGroup.UNCONFIRMED).signerPublicKey(publicAccount.getPublicKey())).toFuture().get();
Assertions.assertEquals(TransactionType.TRANSFER, transactions.getData().get(0).getType());
Assertions.assertEquals(TransactionGroup.UNCONFIRMED, transactions.getData().get(0).getGroup().get());
Assertions.assertEquals(1, transactions.getData().size());
Assertions.assertEquals(1, transactions.getPageNumber());
Assertions.assertEquals(2, transactions.getPageSize());
}
use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.
the class AccountRepositoryIntegrationTest method outgoingTransactions.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void outgoingTransactions(RepositoryType type) {
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
PublicAccount recipient = this.helper().getTestAccount(type).getLeft().getPublicAccount();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Collections.singletonList(TransactionType.TRANSFER)).recipientAddress(recipient.getAddress()))).getData();
System.out.println(transactions.size());
transactions.forEach(transaction -> {
assertTransaction(transaction, null);
TransferTransaction transferTransaction = (TransferTransaction) transaction;
Assertions.assertEquals(recipient.getAddress(), transferTransaction.getRecipient());
});
}
use of io.nem.symbol.sdk.api.TransactionSearchCriteria 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())));
}
use of io.nem.symbol.sdk.api.TransactionSearchCriteria 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());
});
}
use of io.nem.symbol.sdk.api.TransactionSearchCriteria 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);
});
}
Aggregations