Search in sources :

Example 16 with MerkleProofInfo

use of io.nem.symbol.sdk.model.blockchain.MerkleProofInfo in project nem2-sdk-java by nemtech.

the class BlockServiceTest method isValidTransactionInBlockMultipleNotEquals.

@Test
void isValidTransactionInBlockMultipleNotEquals() throws ExecutionException, InterruptedException {
    BigInteger height = BigInteger.ONE;
    String leaf = "1234";
    String root = "00000";
    BlockInfo blockInfo = Mockito.mock(BlockInfo.class);
    Mockito.when(blockInfo.getBlockTransactionsHash()).thenReturn(root);
    Mockito.when(blockRepositoryMock.getBlockByHeight(height)).thenReturn(Observable.just(blockInfo));
    List<MerklePathItem> merklePath = new ArrayList<>();
    merklePath.add(new MerklePathItem(Position.LEFT, "11"));
    merklePath.add(new MerklePathItem(Position.RIGHT, "22"));
    merklePath.add(new MerklePathItem(Position.LEFT, "33"));
    merklePath.add(new MerklePathItem(Position.RIGHT, "44"));
    MerkleProofInfo merkleProofInfo = new MerkleProofInfo(merklePath);
    Mockito.when(blockRepositoryMock.getMerkleTransaction(height, leaf)).thenReturn(Observable.just(merkleProofInfo));
    Assertions.assertFalse(service.isValidTransactionInBlock(height, leaf).toFuture().get());
}
Also used : BlockInfo(io.nem.symbol.sdk.model.blockchain.BlockInfo) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) MerklePathItem(io.nem.symbol.sdk.model.blockchain.MerklePathItem) MerkleProofInfo(io.nem.symbol.sdk.model.blockchain.MerkleProofInfo) Test(org.junit.jupiter.api.Test)

Example 17 with MerkleProofInfo

use of io.nem.symbol.sdk.model.blockchain.MerkleProofInfo in project nem2-sdk-java by nemtech.

the class BlockServiceTest method isValidTransactionInBlockEmptyEquals.

@Test
void isValidTransactionInBlockEmptyEquals() throws ExecutionException, InterruptedException {
    BigInteger height = BigInteger.ONE;
    String leaf = "ABCD";
    String root = "ABCD";
    BlockInfo blockInfo = Mockito.mock(BlockInfo.class);
    Mockito.when(blockInfo.getBlockTransactionsHash()).thenReturn(root);
    Mockito.when(blockRepositoryMock.getBlockByHeight(height)).thenReturn(Observable.just(blockInfo));
    List<MerklePathItem> merklePath = new ArrayList<>();
    MerkleProofInfo merkleProofInfo = new MerkleProofInfo(merklePath);
    Mockito.when(blockRepositoryMock.getMerkleTransaction(height, leaf)).thenReturn(Observable.just(merkleProofInfo));
    Assertions.assertTrue(service.isValidTransactionInBlock(height, leaf).toFuture().get());
}
Also used : BlockInfo(io.nem.symbol.sdk.model.blockchain.BlockInfo) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) MerklePathItem(io.nem.symbol.sdk.model.blockchain.MerklePathItem) MerkleProofInfo(io.nem.symbol.sdk.model.blockchain.MerkleProofInfo) Test(org.junit.jupiter.api.Test)

Aggregations

MerkleProofInfo (io.nem.symbol.sdk.model.blockchain.MerkleProofInfo)17 Test (org.junit.jupiter.api.Test)13 BigInteger (java.math.BigInteger)12 MerklePathItem (io.nem.symbol.sdk.model.blockchain.MerklePathItem)9 ArrayList (java.util.ArrayList)9 BlockInfo (io.nem.symbol.sdk.model.blockchain.BlockInfo)8 BlockRepository (io.nem.symbol.sdk.api.BlockRepository)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 EnumSource (org.junit.jupiter.params.provider.EnumSource)4 ReceiptRepository (io.nem.symbol.sdk.api.ReceiptRepository)3 ResolutionStatementSearchCriteria (io.nem.symbol.sdk.api.ResolutionStatementSearchCriteria)2 MerklePathItemDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.MerklePathItemDTO)2 MerkleProofInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.MerkleProofInfoDTO)2 MerklePathItemDTO (io.nem.symbol.sdk.openapi.vertx.model.MerklePathItemDTO)2 MerkleProofInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.MerkleProofInfoDTO)2 TransactionPaginationStreamer (io.nem.symbol.sdk.api.TransactionPaginationStreamer)1 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)1 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)1 TransactionStatementSearchCriteria (io.nem.symbol.sdk.api.TransactionStatementSearchCriteria)1 Account (io.nem.symbol.sdk.model.account.Account)1