Search in sources :

Example 1 with BlockService

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

the class BlockServiceIntegrationTest method isValidTransactionInBlock.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void isValidTransactionInBlock(RepositoryType type) {
    BigInteger height = BigInteger.ONE;
    RepositoryFactory repositoryFactory = getRepositoryFactory(type);
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).height(height).pageNumber(1))).getData();
    BlockService service = new BlockServiceImpl(repositoryFactory);
    transactions.forEach(t -> {
        String hash = t.getTransactionInfo().get().getHash().get();
        Assertions.assertNotNull(hash);
        Boolean valid = get(service.isValidTransactionInBlock(height, hash));
        Assertions.assertTrue(valid);
    });
}
Also used : Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) BigInteger(java.math.BigInteger) BlockService(io.nem.symbol.sdk.api.BlockService) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BlockService (io.nem.symbol.sdk.api.BlockService)1 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)1 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)1 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)1 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)1 BigInteger (java.math.BigInteger)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1