Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_assumevalid.py
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | def assert_blockchain_height(self, node, height): | ||||
timeout - 0.25 | timeout - 0.25 | ||||
continue | continue | ||||
elif current_height > height: | elif current_height > height: | ||||
assert False, "blockchain too long: {}".format(current_height) | assert False, "blockchain too long: {}".format(current_height) | ||||
elif current_height == height: | elif current_height == height: | ||||
break | break | ||||
def run_test(self): | def run_test(self): | ||||
# Connect to node0 | |||||
p2p0 = self.nodes[0].add_p2p_connection(BaseNode()) | p2p0 = self.nodes[0].add_p2p_connection(BaseNode()) | ||||
self.nodes[0].p2p.wait_for_verack() | |||||
# Build the blockchain | # Build the blockchain | ||||
self.tip = int(self.nodes[0].getbestblockhash(), 16) | self.tip = int(self.nodes[0].getbestblockhash(), 16) | ||||
self.block_time = self.nodes[0].getblock( | self.block_time = self.nodes[0].getblock( | ||||
self.nodes[0].getbestblockhash())['time'] + 1 | self.nodes[0].getbestblockhash())['time'] + 1 | ||||
self.blocks = [] | self.blocks = [] | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Start node1 and node2 with assumevalid so they accept a block with a bad signature. | # Start node1 and node2 with assumevalid so they accept a block with a bad signature. | ||||
self.start_node(1, extra_args=["-assumevalid=" + hex(block102.sha256)]) | self.start_node(1, extra_args=["-assumevalid=" + hex(block102.sha256)]) | ||||
self.start_node(2, extra_args=["-assumevalid=" + hex(block102.sha256)]) | self.start_node(2, extra_args=["-assumevalid=" + hex(block102.sha256)]) | ||||
p2p0 = self.nodes[0].add_p2p_connection(BaseNode()) | p2p0 = self.nodes[0].add_p2p_connection(BaseNode()) | ||||
p2p1 = self.nodes[1].add_p2p_connection(BaseNode()) | p2p1 = self.nodes[1].add_p2p_connection(BaseNode()) | ||||
p2p2 = self.nodes[2].add_p2p_connection(BaseNode()) | p2p2 = self.nodes[2].add_p2p_connection(BaseNode()) | ||||
p2p0.wait_for_verack() | |||||
p2p1.wait_for_verack() | |||||
p2p2.wait_for_verack() | |||||
# send header lists to all three nodes | # send header lists to all three nodes | ||||
p2p0.send_header_for_blocks(self.blocks[0:2000]) | p2p0.send_header_for_blocks(self.blocks[0:2000]) | ||||
p2p0.send_header_for_blocks(self.blocks[2000:]) | p2p0.send_header_for_blocks(self.blocks[2000:]) | ||||
p2p1.send_header_for_blocks(self.blocks[0:2000]) | p2p1.send_header_for_blocks(self.blocks[0:2000]) | ||||
p2p1.send_header_for_blocks(self.blocks[2000:]) | p2p1.send_header_for_blocks(self.blocks[2000:]) | ||||
p2p2.send_header_for_blocks(self.blocks[0:200]) | p2p2.send_header_for_blocks(self.blocks[0:200]) | ||||
# Send blocks to node0. Block 102 will be rejected. | # Send blocks to node0. Block 102 will be rejected. | ||||
Show All 18 Lines |