use of io.nem.symbol.sdk.api.BlockRepository in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method searchByBeneficiaryAddress.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByBeneficiaryAddress(RepositoryType type) {
BlockRepository blockRepository = getBlockRepository(type);
BlockInfo block1 = get(blockRepository.getBlockByHeight(BigInteger.ONE));
BlockSearchCriteria criteria = new BlockSearchCriteria();
Address expectedBeneficiaryAddress = block1.getBeneficiaryAddress();
criteria.setBeneficiaryAddress(expectedBeneficiaryAddress);
BlockPaginationStreamer streamer = new BlockPaginationStreamer(blockRepository);
List<BlockInfo> blocks = get(streamer.search(criteria).toList().toObservable());
blocks.forEach(b -> Assertions.assertEquals(expectedBeneficiaryAddress, b.getBeneficiaryAddress()));
Assertions.assertFalse(blocks.isEmpty());
}
use of io.nem.symbol.sdk.api.BlockRepository in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method searchBySignerPublicKey.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKey(RepositoryType type) {
BlockRepository blockRepository = getBlockRepository(type);
BlockInfo block1 = get(blockRepository.getBlockByHeight(BigInteger.ONE));
BlockSearchCriteria criteria = new BlockSearchCriteria();
PublicKey expectedSignerPublicKey = block1.getSignerPublicAccount().getPublicKey();
criteria.setSignerPublicKey(expectedSignerPublicKey);
BlockPaginationStreamer streamer = new BlockPaginationStreamer(blockRepository);
List<BlockInfo> blocks = get(streamer.search(criteria).toList().toObservable());
blocks.forEach(b -> Assertions.assertEquals(expectedSignerPublicKey, b.getSignerPublicAccount().getPublicKey()));
Assertions.assertFalse(blocks.isEmpty());
}
use of io.nem.symbol.sdk.api.BlockRepository in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method getMerkleReceiptsFromMosaics.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMerkleReceiptsFromMosaics(RepositoryType type) {
BlockRepository blockRepository = getBlockRepository(type);
ReceiptRepository receiptRepository = getRepositoryFactory(type).createReceiptRepository();
PaginationStreamer<MosaicResolutionStatement, ResolutionStatementSearchCriteria> streamer = ReceiptPaginationStreamer.mosaics(receiptRepository);
List<MosaicResolutionStatement> list = get(streamer.search(new ResolutionStatementSearchCriteria()).take(5).toList().toObservable());
Assertions.assertFalse(list.isEmpty());
list.forEach(s -> {
String hash = s.generateHash(getNetworkType());
MerkleProofInfo merkleProofInfo = get(blockRepository.getMerkleReceipts(s.getHeight(), hash));
Assertions.assertFalse(merkleProofInfo.getMerklePath().isEmpty());
});
}
use of io.nem.symbol.sdk.api.BlockRepository in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method searchUsingOffset.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchUsingOffset(RepositoryType type) {
BlockRepository blockRepository = getBlockRepository(type);
BlockPaginationStreamer streamer = new BlockPaginationStreamer(blockRepository);
BlockSearchCriteria criteria = new BlockSearchCriteria();
criteria.setPageSize(10);
criteria.setOrderBy(BlockOrderBy.HEIGHT);
int offsetIndex = 2;
List<BlockInfo> blocksWithoutOffset = get(streamer.search(criteria).toList().toObservable());
String offset = blocksWithoutOffset.get(offsetIndex).getHeight().toString();
criteria.setOffset(offset);
List<BlockInfo> blockFromOffsets = get(streamer.search(criteria).toList().toObservable());
List<BlockInfo> expectedList = blocksWithoutOffset.stream().skip(offsetIndex + 1).collect(Collectors.toList());
// If the block grows when running the last search
PaginationTester.sameEntities(expectedList, blockFromOffsets.subList(0, expectedList.size()));
}
Aggregations