forked from Conflux-Chain/conflux-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblame_test.py
executable file
·52 lines (43 loc) · 1.74 KB
/
blame_test.py
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
#!/usr/bin/env python3
"""An example functional test
"""
from test_framework.test_framework import ConfluxTestFramework
from test_framework.util import *
from conflux.rpc import RpcClient
class BlameTest(ConfluxTestFramework):
def set_test_params(self):
self.num_nodes = 2
def setup_network(self):
self.setup_nodes()
def run_test(self):
time.sleep(7)
client0 = RpcClient(self.nodes[0])
client1 = RpcClient(self.nodes[1])
genesis = self.nodes[0].best_block_hash()
self.log.info(genesis)
blame_info = {}
blame_info['blame'] = "0x1"
blame_info['deferredStateRoot'] = "0x1111111111111111111111111111111111111111111111111111111111111111"
self.nodes[0].test_generateBlockWithBlameInfo(1, 0, blame_info)
h = self.nodes[0].test_generateEmptyBlocks(1)
hash_a = h[0]
block_a = client0.block_by_hash(hash_a)
assert(block_a['blame'] == "0x1")
h = self.nodes[0].test_generateEmptyBlocks(1)
hash_b = h[0]
block_b = client0.block_by_hash(hash_b)
assert(block_b['blame'] == "0x0")
connect_nodes(self.nodes, 0, 1)
sync_blocks(self.nodes[0:2])
block_a1 = client1.block_by_hash(hash_a)
assert(block_a1['blame'] == "0x1")
self.nodes[0].test_generateBlockWithBlameInfo(1, 0, blame_info)
self.nodes[0].test_generateBlockWithBlameInfo(1, 0, blame_info)
self.nodes[0].test_generateBlockWithBlameInfo(1, 0, blame_info)
sync_blocks(self.nodes[0:2])
h = self.nodes[1].test_generateEmptyBlocks(1)
hash_c = h[0]
block_c1 = client1.block_by_hash(hash_c)
assert(block_c1['blame'] == "0x3")
if __name__ == '__main__':
BlameTest().main()