Search in sources :

Example 56 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class BlockRepositoryIntegrationTest method searchBySignerPublicKeyWhenInvalid.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKeyWhenInvalid(RepositoryType type) {
    BlockRepository blockRepository = getBlockRepository(type);
    BlockSearchCriteria criteria = new BlockSearchCriteria();
    PublicKey expectedSignerPublicKey = PublicKey.generateRandom();
    criteria.setSignerPublicKey(expectedSignerPublicKey);
    BlockPaginationStreamer streamer = new BlockPaginationStreamer(blockRepository);
    List<BlockInfo> blocks = get(streamer.search(criteria).toList().toObservable());
    Assertions.assertTrue(blocks.isEmpty());
}
Also used : BlockRepository(io.nem.symbol.sdk.api.BlockRepository) BlockSearchCriteria(io.nem.symbol.sdk.api.BlockSearchCriteria) PublicKey(io.nem.symbol.core.crypto.PublicKey) BlockInfo(io.nem.symbol.sdk.model.blockchain.BlockInfo) BlockPaginationStreamer(io.nem.symbol.sdk.api.BlockPaginationStreamer) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 57 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource 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 58 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource 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());
}
Also used : BlockRepository(io.nem.symbol.sdk.api.BlockRepository) BlockSearchCriteria(io.nem.symbol.sdk.api.BlockSearchCriteria) Address(io.nem.symbol.sdk.model.account.Address) BlockInfo(io.nem.symbol.sdk.model.blockchain.BlockInfo) BlockPaginationStreamer(io.nem.symbol.sdk.api.BlockPaginationStreamer) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 59 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class ChainRepositoryIntegrationTest method getChainInfo.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getChainInfo(RepositoryType type) {
    ChainInfo chainInfo = get(getChainRepository(type).getChainInfo());
    assertTrue(chainInfo.getScoreLow().longValue() >= 0);
    assertTrue(chainInfo.getScoreHigh().longValue() >= 0);
    assertTrue(chainInfo.getHeight().longValue() > 0);
    FinalizedBlock finalizedBlock = chainInfo.getLatestFinalizedBlock();
    assertTrue(finalizedBlock.getFinalizationEpoch() >= 0);
    assertTrue(finalizedBlock.getFinalizationPoint() >= 0);
    assertTrue(finalizedBlock.getHeight().longValue() > 0);
    assertNotNull(finalizedBlock.getHash());
}
Also used : ChainInfo(io.nem.symbol.sdk.model.blockchain.ChainInfo) FinalizedBlock(io.nem.symbol.sdk.model.blockchain.FinalizedBlock) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 60 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class FinalizationRepositoryIntegrationTest method getFinalizationProofAtHeight.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getFinalizationProofAtHeight(RepositoryType type) {
    FinalizationRepository repository = getRepositoryFactory(type).createFinalizationRepository();
    FinalizationProof finalizationProof = get(repository.getFinalizationProofAtHeight(BigInteger.ONE));
    Assertions.assertEquals(1L, finalizationProof.getFinalizationEpoch());
    Assertions.assertEquals(1L, finalizationProof.getFinalizationPoint());
    Assertions.assertEquals(BigInteger.ONE, finalizationProof.getHeight());
    Assertions.assertEquals(1, finalizationProof.getVersion());
}
Also used : FinalizationProof(io.nem.symbol.sdk.model.finalization.FinalizationProof) FinalizationRepository(io.nem.symbol.sdk.api.FinalizationRepository) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EnumSource (org.junit.jupiter.params.provider.EnumSource)397 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)393 Account (io.nem.symbol.sdk.model.account.Account)40 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)38 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)34 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)34 Address (io.nem.symbol.sdk.model.account.Address)30 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)27 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)26 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)26 BigInteger (java.math.BigInteger)25 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)23 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)23 EntityUpdates (org.neo4j.storageengine.api.EntityUpdates)21 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)19 Path (java.nio.file.Path)18 ArrayList (java.util.ArrayList)16 Listener (io.nem.symbol.sdk.api.Listener)15 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)15 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)14