-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBlockTest.java
More file actions
91 lines (77 loc) · 2.39 KB
/
BlockTest.java
File metadata and controls
91 lines (77 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package io.bytom.integration;
import org.junit.Test;
import io.bytom.api.Block;
import io.bytom.exception.BytomException;
import io.bytom.http.Client;
public class BlockTest {
private static Client client;
@Test
public void run() {
try {
testGetBlockCount();
testGetBlockHash();
testGetBlock(1);
testGetBlockHeader(1);
testGetBlockDifficulty(1);
testGetBlockHashRate(1);
} catch (Exception e) {
e.printStackTrace();
}
}
private void testGetBlock(int blockHeight) throws BytomException {
client = TestUtils.generateClient();
try {
Block block = new Block.QueryBuilder().setBlockHeight(blockHeight).getBlock(client);
System.out.println("Block:" + block);
} catch (BytomException e) {
e.printStackTrace();
}
}
private void testGetBlockCount() throws BytomException {
client = TestUtils.generateClient();
try {
int blockCount = Block.getBlockCount(client);
System.out.println("blockCount:" + blockCount);
} catch (BytomException e) {
e.printStackTrace();
}
}
private void testGetBlockHash() throws BytomException {
client = TestUtils.generateClient();
try {
String blockHash = Block.getBlockHash(client);
System.out.println("blockHash:" + blockHash);
} catch (BytomException e) {
e.printStackTrace();
}
}
private void testGetBlockHeader(int blockHeight) throws BytomException {
client = TestUtils.generateClient();
try {
Block.BlockHeader blockHeader = new Block.QueryBuilder().setBlockHeight(blockHeight).getBlockHeader(client);
System.out.println("blockHeader Header:" + blockHeader.blockHeader);
} catch (BytomException e) {
e.printStackTrace();
}
}
private void testGetBlockDifficulty(int blockHeight) throws BytomException {
client = TestUtils.generateClient();
try {
Block.BlockDifficulty blockDifficulty = new Block.QueryBuilder().setBlockHeight(blockHeight)
.getBlockDifficulty(client);
System.out.println("blockDifficulty Difficulty:" + blockDifficulty.difficulty);
} catch (BytomException e) {
e.printStackTrace();
}
}
private void testGetBlockHashRate(int blockHeight) throws BytomException {
client = TestUtils.generateClient();
try {
Block.BlockHashRate blockHashRate = new Block.QueryBuilder().setBlockHeight(blockHeight)
.getHashRate(client);
System.out.println("blockHashRate HashRate:" + blockHashRate.hash_rate);
} catch (BytomException e) {
e.printStackTrace();
}
}
}