Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p-acceptblock.py
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert_equal(x['status'], "headers-only") | assert_equal(x['status'], "headers-only") | ||||
tip_entry_found = True | tip_entry_found = True | ||||
assert(tip_entry_found) | assert(tip_entry_found) | ||||
# But this block should be accepted by node since it has equal work. | # But this block should be accepted by node since it has equal work. | ||||
# FIXME: Replace the assert with the commented lines once Core backport | # FIXME: Replace the assert with the commented lines once Core backport | ||||
# 932f118 is completed. Current behavior does not accept equal work | # 932f118 is completed. Current behavior does not accept equal work | ||||
# blocks ontop of unprocessed blocks. | # blocks ontop of unprocessed blocks. | ||||
#self.nodes[0].getblock(block_h2f.hash) | # self.nodes[0].getblock(block_h2f.hash) | ||||
#self.log.info("Second height 2 block accepted, but not reorg'ed to") | #self.log.info("Second height 2 block accepted, but not reorg'ed to") | ||||
assert_raises_rpc_error(-1, "Block not found on disk", | assert_raises_rpc_error(-1, "Block not found on disk", | ||||
self.nodes[0].getblock, block_h2f.hash) | self.nodes[0].getblock, block_h2f.hash) | ||||
# 4b. Now send another block that builds on the forking chain. | # 4b. Now send another block that builds on the forking chain. | ||||
block_h3 = create_block( | block_h3 = create_block( | ||||
block_h2f.sha256, create_coinbase(3), block_h2f.nTime+1) | block_h2f.sha256, create_coinbase(3), block_h2f.nTime+1) | ||||
block_h3.solve() | block_h3.solve() | ||||
▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
block_293 = create_block( | block_293 = create_block( | ||||
block_292.sha256, create_coinbase(293), block_292.nTime+1) | block_292.sha256, create_coinbase(293), block_292.nTime+1) | ||||
block_293.solve() | block_293.solve() | ||||
headers_message = msg_headers() | headers_message = msg_headers() | ||||
headers_message.headers.append(CBlockHeader(block_293)) | headers_message.headers.append(CBlockHeader(block_293)) | ||||
test_node.send_message(headers_message) | test_node.send_message(headers_message) | ||||
# FIXME: Uncomment this line once Core backport 015a525 is completed. | # FIXME: Uncomment this line once Core backport 015a525 is completed. | ||||
# Current behavior does not ban peers that give us headers on invalid chains. | # Current behavior does not ban peers that give us headers on invalid chains. | ||||
#test_node.wait_for_disconnect() | # test_node.wait_for_disconnect() | ||||
# 9. Connect node1 to node0 and ensure it is able to sync | # 9. Connect node1 to node0 and ensure it is able to sync | ||||
connect_nodes(self.nodes[0], 1) | connect_nodes(self.nodes[0], self.nodes[1]) | ||||
sync_blocks([self.nodes[0], self.nodes[1]]) | sync_blocks([self.nodes[0], self.nodes[1]]) | ||||
self.log.info("Successfully synced nodes 1 and 0") | self.log.info("Successfully synced nodes 1 and 0") | ||||
[c.disconnect_node() for c in connections] | [c.disconnect_node() for c in connections] | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
AcceptBlockTest().main() | AcceptBlockTest().main() |