Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p-acceptblock.py
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
tip_entry_found = False | tip_entry_found = False | ||||
for x in self.nodes[0].getchaintips(): | for x in self.nodes[0].getchaintips(): | ||||
if x['hash'] == block_h2f.hash: | if x['hash'] == block_h2f.hash: | ||||
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 | self.nodes[0].getblock(block_h2f.hash) | ||||
# 932f118 is completed. Current behavior does not accept equal work | self.log.info("Second height 2 block accepted, but not reorg'ed to") | ||||
# blocks ontop of unprocessed blocks. | |||||
# self.nodes[0].getblock(block_h2f.hash) | |||||
#self.log.info("Second height 2 block accepted, but not reorg'ed to") | |||||
assert_raises_rpc_error(-1, "Block not found on disk", | |||||
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() | ||||
test_node.send_message(msg_block(block_h3)) | test_node.send_message(msg_block(block_h3)) | ||||
test_node.sync_with_ping() | test_node.sync_with_ping() | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Check that the getdata includes the right block | # Check that the getdata includes the right block | ||||
assert_equal(getdata.inv[0].hash, block_h1f.sha256) | assert_equal(getdata.inv[0].hash, block_h1f.sha256) | ||||
self.log.info("Inv at tip triggered getdata for unprocessed block") | self.log.info("Inv at tip triggered getdata for unprocessed block") | ||||
# 7. Send the missing block for the third time (now it is requested) | # 7. Send the missing block for the third time (now it is requested) | ||||
test_node.send_message(msg_block(block_h1f)) | test_node.send_message(msg_block(block_h1f)) | ||||
# 7.b. Send the next missing block now that it's requested. | |||||
# FIXME: Remove this line once Core backport 932f118 is completed. | |||||
# Current behavior is to not process equal work blocks building ontop | |||||
# of unprocessed blocks. | |||||
test_node.send_message(msg_block(block_h2f)) | |||||
test_node.sync_with_ping() | test_node.sync_with_ping() | ||||
assert_equal(self.nodes[0].getblockcount(), 290) | assert_equal(self.nodes[0].getblockcount(), 290) | ||||
self.nodes[0].getblock(all_blocks[286].hash) | self.nodes[0].getblock(all_blocks[286].hash) | ||||
assert_equal(self.nodes[0].getbestblockhash(), all_blocks[286].hash) | assert_equal(self.nodes[0].getbestblockhash(), all_blocks[286].hash) | ||||
assert_raises_rpc_error(-1, "Block not found on disk", | assert_raises_rpc_error(-1, "Block not found on disk", | ||||
self.nodes[0].getblock, all_blocks[287].hash) | self.nodes[0].getblock, all_blocks[287].hash) | ||||
self.log.info( | self.log.info( | ||||
"Successfully reorged to longer chain from non-whitelisted peer") | "Successfully reorged to longer chain from non-whitelisted peer") | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |