Search in sources :

Example 1 with ChainInfo

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

the class ChainRepositoryOkHttpImplTest method shouldGetBlockchainScore.

@Test
public void shouldGetBlockchainScore() throws Exception {
    ChainInfoDTO dto = new ChainInfoDTO();
    dto.setScoreLow(BigInteger.valueOf(1));
    dto.setScoreHigh(BigInteger.valueOf(2));
    dto.setHeight(BigInteger.valueOf(3));
    dto.latestFinalizedBlock(new FinalizedBlockDTO().hash("abc").height(BigInteger.valueOf(6)).finalizationEpoch(7L).finalizationPoint(8L));
    mockRemoteCall(dto);
    ChainInfo chainInfo = repository.getChainInfo().toFuture().get();
    Assertions.assertEquals((dto.getScoreLow()), chainInfo.getScoreLow());
    Assertions.assertEquals((dto.getScoreHigh()), chainInfo.getScoreHigh());
    Assertions.assertEquals((dto.getHeight()), chainInfo.getHeight());
    Assertions.assertEquals((dto.getLatestFinalizedBlock().getFinalizationPoint()), chainInfo.getLatestFinalizedBlock().getFinalizationPoint());
    Assertions.assertEquals((dto.getLatestFinalizedBlock().getHeight()), chainInfo.getLatestFinalizedBlock().getHeight());
    Assertions.assertEquals((dto.getLatestFinalizedBlock().getFinalizationEpoch()), chainInfo.getLatestFinalizedBlock().getFinalizationEpoch());
    Assertions.assertEquals((dto.getLatestFinalizedBlock().getHash()), chainInfo.getLatestFinalizedBlock().getHash());
}
Also used : FinalizedBlockDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.FinalizedBlockDTO) ChainInfo(io.nem.symbol.sdk.model.blockchain.ChainInfo) ChainInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.ChainInfoDTO) Test(org.junit.jupiter.api.Test)

Example 2 with ChainInfo

use of io.nem.symbol.sdk.model.blockchain.ChainInfo 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 3 with ChainInfo

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

the class ChainRepositoryVertxImplTest method shouldGetBlockchainScore.

@Test
public void shouldGetBlockchainScore() throws Exception {
    ChainInfoDTO dto = new ChainInfoDTO();
    dto.setScoreLow(BigInteger.valueOf(1));
    dto.setScoreHigh(BigInteger.valueOf(2));
    dto.setHeight(BigInteger.valueOf(3));
    dto.latestFinalizedBlock(new FinalizedBlockDTO().hash("abc").height(BigInteger.valueOf(6)).finalizationEpoch(7L).finalizationPoint(8L));
    mockRemoteCall(dto);
    ChainInfo chainInfo = repository.getChainInfo().toFuture().get();
    Assertions.assertEquals((dto.getScoreLow()), chainInfo.getScoreLow());
    Assertions.assertEquals((dto.getScoreHigh()), chainInfo.getScoreHigh());
    Assertions.assertEquals((dto.getHeight()), chainInfo.getHeight());
    Assertions.assertEquals((dto.getLatestFinalizedBlock().getFinalizationPoint()), chainInfo.getLatestFinalizedBlock().getFinalizationPoint());
    Assertions.assertEquals((dto.getLatestFinalizedBlock().getHeight()), chainInfo.getLatestFinalizedBlock().getHeight());
    Assertions.assertEquals((dto.getLatestFinalizedBlock().getFinalizationEpoch()), chainInfo.getLatestFinalizedBlock().getFinalizationEpoch());
    Assertions.assertEquals((dto.getLatestFinalizedBlock().getHash()), chainInfo.getLatestFinalizedBlock().getHash());
}
Also used : FinalizedBlockDTO(io.nem.symbol.sdk.openapi.vertx.model.FinalizedBlockDTO) ChainInfo(io.nem.symbol.sdk.model.blockchain.ChainInfo) ChainInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.ChainInfoDTO) Test(org.junit.jupiter.api.Test)

Aggregations

ChainInfo (io.nem.symbol.sdk.model.blockchain.ChainInfo)3 Test (org.junit.jupiter.api.Test)2 FinalizedBlock (io.nem.symbol.sdk.model.blockchain.FinalizedBlock)1 ChainInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.ChainInfoDTO)1 FinalizedBlockDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.FinalizedBlockDTO)1 ChainInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.ChainInfoDTO)1 FinalizedBlockDTO (io.nem.symbol.sdk.openapi.vertx.model.FinalizedBlockDTO)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1