Skip to content

Commit

Permalink
test: add block sync to getblockfrompeer.py
Browse files Browse the repository at this point in the history
This fixes an intermittent error, caused by blocks arriving
out of order due to how compact block relay may revert to headers
processing when the tip hasn't caught up, and resulting in slightly
different pruning behavior.

Making sure that all blocks from the previous tests are synced before
generating more blocks makes this impossible.
See Issue bitcoin#27749 for more details.
  • Loading branch information
mzumsande committed May 30, 2023
1 parent 7130048 commit 9fe9074
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/functional/rpc_getblockfrompeer.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ def run_test(self):
assert_raises_rpc_error(-1, error_msg, self.nodes[1].getblockfrompeer, blockhash, node1_interface_id)

self.log.info("Connect pruned node")
# We need to generate more blocks to be able to prune
self.connect_nodes(0, 2)
pruned_node = self.nodes[2]
self.sync_blocks([self.nodes[0], pruned_node])

# We need to generate more blocks to be able to prune
self.generate(self.nodes[0], 400, sync_fun=self.no_op)
self.sync_blocks([self.nodes[0], pruned_node])
pruneheight = pruned_node.pruneblockchain(300)
Expand Down

0 comments on commit 9fe9074

Please sign in to comment.