Search in sources :

Example 1 with ReceiptRepository

use of io.nem.symbol.sdk.api.ReceiptRepository in project nem2-sdk-java by nemtech.

the class ReceiptRepositoryTransactionSearchIntegrationTest method assertRecipientType.

List<TransactionStatement> assertRecipientType(RepositoryType type, List<ReceiptType> receiptTypes) {
    ReceiptRepository receiptRepository = getReceiptRepository(type);
    PaginationStreamer<TransactionStatement, TransactionStatementSearchCriteria> streamer = ReceiptPaginationStreamer.transactions(receiptRepository);
    List<TransactionStatement> transactionStatements = get(streamer.search(new TransactionStatementSearchCriteria().receiptTypes(receiptTypes)).toList().toObservable());
    transactionStatements.forEach(s -> Assertions.assertTrue(s.getReceipts().stream().anyMatch(r -> (receiptTypes.contains(r.getType())))));
    return transactionStatements;
}
Also used : TransactionStatementSearchCriteria(io.nem.symbol.sdk.api.TransactionStatementSearchCriteria) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) TransactionStatement(io.nem.symbol.sdk.model.receipt.TransactionStatement)

Example 2 with ReceiptRepository

use of io.nem.symbol.sdk.api.ReceiptRepository in project nem2-sdk-java by nemtech.

the class BlockRepositoryIntegrationTest method getMerkleReceiptsFromAddresses.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMerkleReceiptsFromAddresses(RepositoryType type) {
    Pair<Account, NamespaceId> testAccount = helper().getTestAccount(type);
    helper().basicSendMosaicFromNemesis(type, testAccount.getRight());
    BlockRepository blockRepository = getBlockRepository(type);
    ReceiptRepository receiptRepository = getRepositoryFactory(type).createReceiptRepository();
    PaginationStreamer<AddressResolutionStatement, ResolutionStatementSearchCriteria> streamer = ReceiptPaginationStreamer.addresses(receiptRepository);
    List<AddressResolutionStatement> 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());
    });
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) BlockRepository(io.nem.symbol.sdk.api.BlockRepository) AddressResolutionStatement(io.nem.symbol.sdk.model.receipt.AddressResolutionStatement) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) MerkleProofInfo(io.nem.symbol.sdk.model.blockchain.MerkleProofInfo) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with ReceiptRepository

use of io.nem.symbol.sdk.api.ReceiptRepository in project nem2-sdk-java by nemtech.

the class BlockRepositoryIntegrationTest method getMerkleReceiptsFromTransactions.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMerkleReceiptsFromTransactions(RepositoryType type) {
    BlockRepository blockRepository = getBlockRepository(type);
    ReceiptRepository receiptRepository = getRepositoryFactory(type).createReceiptRepository();
    PaginationStreamer<TransactionStatement, TransactionStatementSearchCriteria> streamer = ReceiptPaginationStreamer.transactions(receiptRepository);
    List<TransactionStatement> list = get(streamer.search(new TransactionStatementSearchCriteria()).take(5).toList().toObservable());
    System.out.println(list.size());
    list.forEach(s -> {
        String hash = s.generateHash();
        System.out.println(hash);
        System.out.println(s.getHeight());
        MerkleProofInfo merkleProofInfo = get(blockRepository.getMerkleReceipts(s.getHeight(), hash));
        System.out.println(toJson(merkleProofInfo));
    });
}
Also used : TransactionStatementSearchCriteria(io.nem.symbol.sdk.api.TransactionStatementSearchCriteria) ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) BlockRepository(io.nem.symbol.sdk.api.BlockRepository) TransactionStatement(io.nem.symbol.sdk.model.receipt.TransactionStatement) MerkleProofInfo(io.nem.symbol.sdk.model.blockchain.MerkleProofInfo) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with ReceiptRepository

use of io.nem.symbol.sdk.api.ReceiptRepository 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());
    });
}
Also used : ReceiptRepository(io.nem.symbol.sdk.api.ReceiptRepository) BlockRepository(io.nem.symbol.sdk.api.BlockRepository) ResolutionStatementSearchCriteria(io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria) MerkleProofInfo(io.nem.symbol.sdk.model.blockchain.MerkleProofInfo) MosaicResolutionStatement(io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ReceiptRepository (io.nem.symbol.sdk.api.ReceiptRepository)4 BlockRepository (io.nem.symbol.sdk.api.BlockRepository)3 MerkleProofInfo (io.nem.symbol.sdk.model.blockchain.MerkleProofInfo)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnumSource (org.junit.jupiter.params.provider.EnumSource)3 ResolutionStatementSearchCriteria (io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria)2 TransactionStatementSearchCriteria (io.nem.symbol.sdk.api.TransactionStatementSearchCriteria)2 TransactionStatement (io.nem.symbol.sdk.model.receipt.TransactionStatement)2 Account (io.nem.symbol.sdk.model.account.Account)1 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)1 AddressResolutionStatement (io.nem.symbol.sdk.model.receipt.AddressResolutionStatement)1 MosaicResolutionStatement (io.nem.symbol.sdk.model.receipt.MosaicResolutionStatement)1