Search in sources :

Example 1 with MerklePathItemDTO

use of io.nem.symbol.sdk.openapi.okhttp_gson.model.MerklePathItemDTO in project nem2-sdk-java by nemtech.

the class BlockRepositoryOkHttpImplTest method shouldGetMerkleReceipts.

@Test
public void shouldGetMerkleReceipts() throws Exception {
    MerkleProofInfoDTO merkleProofInfoDTO = new MerkleProofInfoDTO();
    MerklePathItemDTO marklePathItem = new MerklePathItemDTO();
    marklePathItem.setHash("SomeHash");
    marklePathItem.setPosition(PositionEnum.LEFT);
    merkleProofInfoDTO.setMerklePath(Collections.singletonList(marklePathItem));
    mockRemoteCall(merkleProofInfoDTO);
    BigInteger height = BigInteger.valueOf(10L);
    MerkleProofInfo info = repository.getMerkleReceipts(height, "AnotherHash").toFuture().get();
    Assertions.assertNotNull(info);
    Assertions.assertEquals(1, info.getMerklePath().size());
    Assertions.assertEquals(marklePathItem.getHash(), info.getMerklePath().get(0).getHash());
    Assertions.assertEquals(Position.LEFT, info.getMerklePath().get(0).getPosition());
}
Also used : MerklePathItemDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MerklePathItemDTO) MerkleProofInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MerkleProofInfoDTO) BigInteger(java.math.BigInteger) MerkleProofInfo(io.nem.symbol.sdk.model.blockchain.MerkleProofInfo) Test(org.junit.jupiter.api.Test)

Example 2 with MerklePathItemDTO

use of io.nem.symbol.sdk.openapi.okhttp_gson.model.MerklePathItemDTO in project nem2-sdk-java by nemtech.

the class BlockRepositoryOkHttpImplTest method getMerkleTransaction.

@Test
public void getMerkleTransaction() throws Exception {
    MerkleProofInfoDTO merkleProofInfoDTO = new MerkleProofInfoDTO();
    MerklePathItemDTO item = new MerklePathItemDTO().hash("someHash").position(PositionEnum.LEFT);
    mockRemoteCall(merkleProofInfoDTO.addMerklePathItem(item));
    MerkleProofInfo merkleProofInfo = repository.getMerkleTransaction(BigInteger.ONE, "HASH!").toFuture().get();
    Assertions.assertEquals(1, merkleProofInfo.getMerklePath().size());
    Assertions.assertEquals("someHash", merkleProofInfo.getMerklePath().get(0).getHash());
    Assertions.assertEquals(Position.LEFT, merkleProofInfo.getMerklePath().get(0).getPosition());
}
Also used : MerklePathItemDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MerklePathItemDTO) MerkleProofInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MerkleProofInfoDTO) MerkleProofInfo(io.nem.symbol.sdk.model.blockchain.MerkleProofInfo) Test(org.junit.jupiter.api.Test)

Aggregations

MerkleProofInfo (io.nem.symbol.sdk.model.blockchain.MerkleProofInfo)2 MerklePathItemDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.MerklePathItemDTO)2 MerkleProofInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.MerkleProofInfoDTO)2 Test (org.junit.jupiter.api.Test)2 BigInteger (java.math.BigInteger)1