From 9fe9074266c6d7ddb40384d81741df1fc94980ff Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Tue, 30 May 2023 14:11:37 -0400 Subject: [PATCH] test: add block sync to getblockfrompeer.py 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 #27749 for more details. --- test/functional/rpc_getblockfrompeer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/functional/rpc_getblockfrompeer.py b/test/functional/rpc_getblockfrompeer.py index 2f093bebff1..1ab1023cf14 100755 --- a/test/functional/rpc_getblockfrompeer.py +++ b/test/functional/rpc_getblockfrompeer.py @@ -117,9 +117,11 @@ class GetBlockFromPeerTest(BitcoinTestFramework): 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)