Search in sources :

Example 1 with Block

use of com.github.rosklyar.client.blockchain.domain.block.Block in project nem-library by rosklyar.

the class BlockchainClientTest method getBlock.

@Test
void getBlock() {
    Block lastBlock = blockchainClient.lastBlock();
    Block block = blockchainClient.block(new BlockHeight(lastBlock.height));
    assertEquals(lastBlock, block);
}
Also used : Block(com.github.rosklyar.client.blockchain.domain.block.Block) BlockHeight(com.github.rosklyar.client.blockchain.domain.block.BlockHeight) Test(org.junit.jupiter.api.Test)

Example 2 with Block

use of com.github.rosklyar.client.blockchain.domain.block.Block in project nem-library by rosklyar.

the class BlockchainClientTest method getBlocks.

@Test
@Disabled("only for local NIS")
void getBlocks() {
    Block lastBlock = blockchainClient.lastBlock();
    assertTrue(lastBlock.height > 0);
    Block block = blockchainClient.block(new BlockHeight(lastBlock.height));
    assertEquals(lastBlock, block);
    BlocksAfterResponse blocksAfterResponse = blockchainClient.blocksAfter(new BlockHeight(lastBlock.height - 10));
    assertEquals(10, blocksAfterResponse.data.size());
    assertEquals(lastBlock, blocksAfterResponse.data.stream().filter(blockInfo -> blockInfo.block.height == lastBlock.height).findFirst().orElseThrow(RuntimeException::new).block);
}
Also used : BlocksAfterResponse(com.github.rosklyar.client.blockchain.domain.block.BlocksAfterResponse) Block(com.github.rosklyar.client.blockchain.domain.block.Block) BlockHeight(com.github.rosklyar.client.blockchain.domain.block.BlockHeight) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with Block

use of com.github.rosklyar.client.blockchain.domain.block.Block in project nem-library by rosklyar.

the class BlockchainClientTest method getLastBlock.

@Test
void getLastBlock() {
    Block lastBlock = blockchainClient.lastBlock();
    assertEquals(lastBlock, simpleBlockchainClient.lastBlock());
    assertTrue(lastBlock.height > 0);
}
Also used : Block(com.github.rosklyar.client.blockchain.domain.block.Block) Test(org.junit.jupiter.api.Test)

Aggregations

Block (com.github.rosklyar.client.blockchain.domain.block.Block)3 Test (org.junit.jupiter.api.Test)3 BlockHeight (com.github.rosklyar.client.blockchain.domain.block.BlockHeight)2 BlocksAfterResponse (com.github.rosklyar.client.blockchain.domain.block.BlocksAfterResponse)1 Disabled (org.junit.jupiter.api.Disabled)1