Skip to content

Commit 0087ba4

Browse files
committed
Merge bitcoin/bitcoin#32968: test: fix intermittent failure in rpc_invalidateblock.py
28416f3 test: fix intermittent failure in rpc_invalidateblock.py (stratospher) Pull request description: resolves #32965. node1 (with 24 blocks) causes node0 (with 6 blocks + 1 extra header) to silently reorg. so move the subtest to a point before the 20 blocks are generated so that node1's state doesn't cause node0 to silently reorg. ACKs for top commit: maflcko: lgtm ACK 28416f3 mzumsande: Code Review ACK 28416f3 Tree-SHA512: f6cc682b8e5416125f887c094d5e291dd37f0bfc41d7c0de218f3e24fa1ea0cd642f7a1e362f3127f68cde725a67f3054501326b9bd25f0caa9a05de7d0052b0
2 parents b53fab1 + 28416f3 commit 0087ba4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/functional/rpc_invalidateblock.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ def run_test(self):
102102
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], 3)
103103
assert_equal(self.nodes[0].getblockchaininfo()['headers'], 3)
104104

105+
# Reconsider the header
106+
self.nodes[0].reconsiderblock(block.hash)
107+
# Since header doesn't have block data, it can't be chain tip
108+
# Check if it's possible for an ancestor (with block data) to be the chain tip
109+
assert_equal(self.nodes[0].getbestblockhash(), blockhash_6)
110+
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], 6)
111+
assert_equal(self.nodes[0].getblockchaininfo()['headers'], 7)
112+
105113
self.log.info("Verify that we reconsider all ancestors as well")
106114
blocks = self.generatetodescriptor(self.nodes[1], 10, ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR, sync_fun=self.no_op)
107115
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])
@@ -128,14 +136,6 @@ def run_test(self):
128136
# Should report consistent blockchain info
129137
assert_equal(self.nodes[1].getblockchaininfo()["headers"], self.nodes[1].getblockchaininfo()["blocks"])
130138

131-
# Reconsider the header
132-
self.nodes[0].reconsiderblock(block.hash)
133-
# Since header doesn't have block data, it can't be chain tip
134-
# Check if it's possible for an ancestor (with block data) to be the chain tip
135-
assert_equal(self.nodes[0].getbestblockhash(), blockhash_6)
136-
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], 6)
137-
assert_equal(self.nodes[0].getblockchaininfo()['headers'], 7)
138-
139139
self.log.info("Verify that invalidating an unknown block throws an error")
140140
assert_raises_rpc_error(-5, "Block not found", self.nodes[1].invalidateblock, "00" * 32)
141141
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])

0 commit comments

Comments
 (0)