1 package io.bytom.integration;
3 import io.bytom.TestUtils;
4 import io.bytom.api.Asset;
5 import io.bytom.api.Block;
6 import io.bytom.api.Wallet;
7 import io.bytom.exception.BytomException;
8 import io.bytom.http.Client;
9 import org.junit.Assert;
10 import org.junit.Test;
12 public class BlockTest {
18 client = TestUtils.generateClient();
19 } catch (BytomException e) {
25 static Block.BlockHeader blockHeader;
26 static Block.BlockDifficulty blockDifficulty;
27 static Block.BlockHashRate blockHashRate;
30 public void testBlockCountGet() throws Exception {
31 int count = Block.getBlockCount(client);
32 Assert.assertEquals(158, count);
36 public void testBlockHashGet() throws Exception {
37 String blockHash = Block.getBlockHash(client);
38 Assert.assertNotNull(blockHash);
42 public void testBlockGet() throws Exception {
43 int height = Block.getBlockCount(client);
44 String blockHash = Block.getBlockHash(client);
46 block = new Block.QueryBuilder()
47 .setBlockHeight(height)
48 .setBlockHash(blockHash)
53 public void testBlockHeader() throws Exception {
54 int height = Block.getBlockCount(client);
55 String blockHash = Block.getBlockHash(client);
57 blockHeader = new Block.QueryBuilder()
58 .setBlockHeight(height)
59 .setBlockHash(blockHash)
60 .getBlockHeader(client);
64 public void testBlockDifficulty() throws Exception {
65 int height = Block.getBlockCount(client);
66 String blockHash = Block.getBlockHash(client);
68 blockDifficulty = new Block.QueryBuilder()
69 .setBlockHeight(height)
70 .setBlockHash(blockHash)
71 .getBlockDifficulty(client);
75 public void testBlockHashRate() throws Exception {
76 int height = Block.getBlockCount(client);
77 String blockHash = Block.getBlockHash(client);
79 blockHashRate = new Block.QueryBuilder()
80 .setBlockHeight(height)
81 .setBlockHash(blockHash)