use of io.nem.symbol.sdk.api.TransactionPaginationStreamer 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.TransactionPaginationStreamer in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchEmbedded.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchEmbedded(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionGroup group = TransactionGroup.CONFIRMED;
TransactionSearchCriteria criteria = new TransactionSearchCriteria(group).embedded(true);
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
transactions.forEach(b -> {
TransferTransaction transferTransaction = (TransferTransaction) b;
Message message = transferTransaction.getMessage().orElse(PlainMessage.create("No Message!!"));
Assertions.assertNotNull(message.getText());
});
Assertions.assertFalse(transactions.isEmpty());
}
use of io.nem.symbol.sdk.api.TransactionPaginationStreamer in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchByGroup.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByGroup(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionGroup group = TransactionGroup.CONFIRMED;
TransactionSearchCriteria criteria = new TransactionSearchCriteria(group);
List<Transaction> transactions = get(streamer.search(criteria).flatMap(t -> t.isTransactionFullyLoaded() ? Observable.just(t) : transactionRepository.getTransaction(group, t.getTransactionInfo().get().getHash().get())).toList().toObservable());
String generationHash = getGenerationHash();
List<List<String>> reported = new ArrayList<>();
transactions.forEach(b -> {
String originalHash = b.getTransactionInfo().get().getHash().get();
BigInteger height = b.getTransactionInfo().get().getHeight();
String calculatedHash = b.createTransactionHash(ConvertUtils.toHex(b.serialize()), ConvertUtils.fromHexToBytes(generationHash));
boolean valid = originalHash.equals(calculatedHash);
if (!valid) {
List<String> values = Arrays.asList(Boolean.toString(valid), b.getType().name(), height.toString(), originalHash, calculatedHash, ConvertUtils.toHex(b.serialize()), toJson(b));
reported.add(values);
}
Assertions.assertNotNull(b.getTransactionInfo().get().getHeight());
});
reported.forEach(values -> {
System.out.println("| " + String.join(" | ", values) + " |");
});
Assertions.assertTrue(reported.isEmpty());
Assertions.assertFalse(transactions.isEmpty());
helper.assertById(transactionRepository, group, transactions);
}
use of io.nem.symbol.sdk.api.TransactionPaginationStreamer in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchByTransactionToHeight.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByTransactionToHeight(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionSearchCriteria toBlockOneTransactions = new TransactionSearchCriteria(TransactionGroup.CONFIRMED).toHeight(BigInteger.ONE).embedded(true);
List<Transaction> transactions = get(streamer.search(toBlockOneTransactions).toList().toObservable());
transactions.forEach(b -> Assertions.assertEquals(BigInteger.ONE, b.getTransactionInfo().get().getHeight()));
Assertions.assertFalse(transactions.isEmpty());
TransactionSearchCriteria blockOneTransactions = new TransactionSearchCriteria(TransactionGroup.CONFIRMED).height(BigInteger.ONE).embedded(true);
helper.assertSameRecordList(get(streamer.search(toBlockOneTransactions).toList().toObservable()), get(streamer.search(blockOneTransactions).toList().toObservable()));
}
use of io.nem.symbol.sdk.api.TransactionPaginationStreamer in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchByTransactionType.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByTransactionType(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
criteria.transactionTypes(Collections.singletonList(TransactionType.TRANSFER));
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
transactions.forEach(b -> Assertions.assertEquals(TransactionType.TRANSFER, b.getType()));
Assertions.assertFalse(transactions.isEmpty());
helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
Aggregations