use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.
the class TransactionRepositoryVertxImplTest method searchTransactions.
@Test
public void searchTransactions() throws Exception {
TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json");
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 TransactionRepositoryVertxImplTest method searchTransactionsTransactionTypes.
@Test
public void searchTransactionsTransactionTypes() throws Exception {
TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json");
mockRemoteCall(toPage(transferTransactionDTO));
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Arrays.asList(TransactionType.NAMESPACE_METADATA, TransactionType.AGGREGATE_COMPLETE));
Page<Transaction> transactions = repository.search(criteria).toFuture().get();
Assertions.assertEquals(TransactionType.TRANSFER, transactions.getData().get(0).getType());
Assertions.assertEquals(TransactionGroup.CONFIRMED, 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 MultisignIntegrationTest method shouldReturnCosignatureAddedViaListener2.
@Disabled
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnCosignatureAddedViaListener2(RepositoryType type) {
Listener listener = getListener(type);
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
TransactionRepository transactionRepository = repositoryFactory.createTransactionRepository();
SignedTransaction signedAggregatedTx = createSignedAggregatedBondTransaction(multisigAccount, cosignAccount1, account2.getAddress());
Object finalObject = get(createHashLockTransactionAndAnnounce(type, signedAggregatedTx, cosignAccount1).flatMap(t -> {
System.out.println("hash lock finished");
TransactionServiceImpl transactionService = new TransactionServiceImpl(getRepositoryFactory(type));
return transactionService.announceAggregateBonded(listener, signedAggregatedTx).flatMap(a -> {
System.out.println("Aggregate bonded finished");
return repositoryFactory.createTransactionRepository().search(new TransactionSearchCriteria(TransactionGroup.PARTIAL).signerPublicKey(cosignAccount1.getPublicAccount().getPublicKey())).flatMap((page) -> {
List<Transaction> transactions = page.getData();
System.out.println("partialTransactions " + transactions.size());
AggregateTransaction transactionToCosign = (AggregateTransaction) transactions.get(0);
CosignatureTransaction cosignatureTransaction = CosignatureTransaction.create(transactionToCosign);
CosignatureSignedTransaction cosignatureSignedTransaction = cosignAccount2.signCosignatureTransaction(cosignatureTransaction);
return transactionRepository.announceAggregateBondedCosignature(cosignatureSignedTransaction).flatMap(r -> {
System.out.println("announceAggregateBondedCosignature " + r);
return listener.cosignatureAdded(cosignAccount1.getAddress());
});
});
});
}));
System.out.println(finalObject.getClass());
Assertions.assertNull(finalObject);
}
use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.
the class TestnetTester method readTransactions.
private static void readTransactions(RepositoryFactory repositoryFactory) throws Exception {
String generationHash = repositoryFactory.getGenerationHash().toFuture().get();
NetworkType networkType = repositoryFactory.getNetworkType().toFuture().get();
List<Transaction> transactions = repositoryFactory.createTransactionRepository().streamer().search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).order(OrderBy.DESC).transactionTypes(Arrays.asList(TransactionType.VOTING_KEY_LINK))).take(50).toList().blockingGet();
transactions.forEach(t -> {
System.out.println(t.getVersion());
System.out.println(t.getTransactionInfo().get().getHash().get());
System.out.println(t.createTransactionHash(ConvertUtils.toHex(t.serialize()), ConvertUtils.fromHexToBytes(generationHash)));
});
}
use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchBySignerPublicKeyInvalid.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKeyInvalid(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
PublicKey expectedSignerPublicKey = Account.generateNewAccount(getNetworkType()).getPublicAccount().getPublicKey();
criteria.setSignerPublicKey(expectedSignerPublicKey);
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
Assertions.assertTrue(transactions.isEmpty());
helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
Aggregations