use of io.nem.symbol.sdk.model.blockchain.BlockInfo in project nem2-sdk-java by nemtech.
the class BlockServiceTest method isValidStatementInBlockEmpty.
@Test
void isValidStatementInBlockEmpty() throws ExecutionException, InterruptedException {
BigInteger height = BigInteger.ONE;
String leaf = "ABCD";
String root = "ABCD";
BlockInfo blockInfo = Mockito.mock(BlockInfo.class);
Mockito.when(blockInfo.getBlockReceiptsHash()).thenReturn(root);
Mockito.when(blockRepositoryMock.getBlockByHeight(height)).thenReturn(Observable.just(blockInfo));
List<MerklePathItem> merklePath = new ArrayList<>();
MerkleProofInfo merkleProofInfo = new MerkleProofInfo(merklePath);
Mockito.when(blockRepositoryMock.getMerkleReceipts(height, leaf)).thenReturn(Observable.just(merkleProofInfo));
Assertions.assertTrue(service.isValidStatementInBlock(height, leaf).toFuture().get());
}
use of io.nem.symbol.sdk.model.blockchain.BlockInfo in project nem2-sdk-java by nemtech.
the class BlockServiceTest method isValidTransactionInBlockEmtpyNotEquals.
@Test
void isValidTransactionInBlockEmtpyNotEquals() throws ExecutionException, InterruptedException {
BigInteger height = BigInteger.ONE;
String leaf = "ABCD";
String root = "1234";
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.assertFalse(service.isValidTransactionInBlock(height, leaf).toFuture().get());
}
use of io.nem.symbol.sdk.model.blockchain.BlockInfo 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());
}
use of io.nem.symbol.sdk.model.blockchain.BlockInfo 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());
}
Aggregations