use of io.nem.symbol.sdk.model.blockchain.FinalizedBlock 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());
}
use of io.nem.symbol.sdk.model.blockchain.FinalizedBlock in project nem2-sdk-java by nemtech.
the class ListenerOkHttpTest method subscribeFinalizedBlock.
@Test
public void subscribeFinalizedBlock() throws ExecutionException, InterruptedException, TimeoutException {
simulateWebSocketStartup();
FinalizedBlock finalizedBlock = new FinalizedBlock(1L, 2L, BigInteger.valueOf(3), "abc");
JsonObject transactionInfoDtoJsonObject = jsonHelper.convert(finalizedBlock, JsonObject.class);
String channelName = ListenerChannel.FINALIZED_BLOCK.toString();
List<FinalizedBlock> finalizedBlocks = new ArrayList<>();
listener.finalizedBlock().forEach(finalizedBlocks::add);
handle(transactionInfoDtoJsonObject, channelName);
Assertions.assertEquals(1, finalizedBlocks.size());
Assertions.assertEquals(finalizedBlock, finalizedBlocks.get(0));
Mockito.verify(webSocketMock).send(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, channelName)));
}
use of io.nem.symbol.sdk.model.blockchain.FinalizedBlock in project nem2-sdk-java by nemtech.
the class ListenerVertxTest method subscribeFinalizedBlock.
@Test
public void subscribeFinalizedBlock() throws ExecutionException, InterruptedException, TimeoutException {
simulateWebSocketStartup();
String channelName = ListenerChannel.FINALIZED_BLOCK.toString();
FinalizedBlock finalizedBlock = new FinalizedBlock(1L, 2L, BigInteger.valueOf(3), "abc");
ObjectNode transactionInfoDtoJsonObject = jsonHelper.convert(finalizedBlock, ObjectNode.class);
List<FinalizedBlock> finalizedBlocks = new ArrayList<>();
listener.finalizedBlock().forEach(finalizedBlocks::add);
handle(transactionInfoDtoJsonObject, channelName);
Assertions.assertEquals(1, finalizedBlocks.size());
Assertions.assertEquals(1, finalizedBlocks.size());
Mockito.verify(webSocketMock).handler(Mockito.any());
Mockito.verify(webSocketMock).writeTextMessage(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, channelName)));
}
use of io.nem.symbol.sdk.model.blockchain.FinalizedBlock in project nem2-sdk-java by nemtech.
the class FinalizationRepositoryIntegrationTest method getFinalizationProofAtCurrentFinalizedHeight.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getFinalizationProofAtCurrentFinalizedHeight(RepositoryType type) {
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
FinalizedBlock finalizedBlock = get(repositoryFactory.createChainRepository().getChainInfo()).getLatestFinalizedBlock();
FinalizationRepository repository = repositoryFactory.createFinalizationRepository();
FinalizationProof finalizationProof = get(repository.getFinalizationProofAtHeight(finalizedBlock.getHeight()));
Assertions.assertEquals(finalizationProof.getFinalizationEpoch(), finalizationProof.getFinalizationEpoch());
Assertions.assertEquals(finalizationProof.getFinalizationPoint(), finalizationProof.getFinalizationPoint());
Assertions.assertEquals(finalizationProof.getHeight(), finalizationProof.getHeight());
Assertions.assertEquals(1, finalizationProof.getVersion());
}
use of io.nem.symbol.sdk.model.blockchain.FinalizedBlock in project nem2-sdk-java by nemtech.
the class FinalizationRepositoryIntegrationTest method getFinalizationProofAtEpochLatest.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getFinalizationProofAtEpochLatest(RepositoryType type) {
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
FinalizedBlock finalizedBlock = get(repositoryFactory.createChainRepository().getChainInfo()).getLatestFinalizedBlock();
FinalizationRepository repository = repositoryFactory.createFinalizationRepository();
FinalizationProof finalizationProof = get(repository.getFinalizationProofAtEpoch(finalizedBlock.getFinalizationEpoch()));
Assertions.assertEquals(finalizationProof.getFinalizationEpoch(), finalizationProof.getFinalizationEpoch());
Assertions.assertEquals(finalizationProof.getFinalizationPoint(), finalizationProof.getFinalizationPoint());
Assertions.assertEquals(finalizationProof.getHeight(), finalizationProof.getHeight());
Assertions.assertEquals(1, finalizationProof.getVersion());
}
Aggregations