Skip to content

Commit bb53ce9

Browse files
instagibbsTheCharlatan
authored andcommitted
tests: Add functional test for submitting a previously pruned block
This tests the new submitblock behaviour that is introduced in the previous commit: Submitting a previously pruned block should persist the block's data again.
1 parent 1f7fc73 commit bb53ce9

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test/functional/mining_basic.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ def assert_template(node, block, expect, rehash=True):
5656

5757
class MiningTest(BitcoinTestFramework):
5858
def set_test_params(self):
59-
self.num_nodes = 2
59+
self.num_nodes = 3
60+
self.extra_args = [
61+
[],
62+
[],
63+
["-fastprune", "-prune=1"]
64+
]
6065
self.setup_clean_chain = True
6166
self.supports_cli = False
6267

@@ -168,6 +173,21 @@ def test_timewarp(self):
168173
bad_block.solve()
169174
node.submitheader(hexdata=CBlockHeader(bad_block).serialize().hex())
170175

176+
def test_pruning(self):
177+
self.log.info("Test that submitblock stores previously pruned block")
178+
prune_node = self.nodes[2]
179+
self.generate(prune_node, 400, sync_fun=self.no_op)
180+
pruned_block = prune_node.getblock(prune_node.getblockhash(2), verbosity=0)
181+
pruned_height = prune_node.pruneblockchain(400)
182+
assert_greater_than_or_equal(pruned_height, 2)
183+
pruned_blockhash = prune_node.getblockhash(2)
184+
185+
assert_raises_rpc_error(-1, 'Block not available (pruned data)', prune_node.getblock, pruned_blockhash)
186+
187+
result = prune_node.submitblock(pruned_block)
188+
assert_equal(result, "inconclusive")
189+
assert_equal(prune_node.getblock(pruned_blockhash, verbosity=0), pruned_block)
190+
171191
def run_test(self):
172192
node = self.nodes[0]
173193
self.wallet = MiniWallet(node)
@@ -386,6 +406,7 @@ def chain_tip(b_hash, *, status='headers-only', branchlen=1):
386406

387407
self.test_blockmintxfee_parameter()
388408
self.test_timewarp()
409+
self.test_pruning()
389410

390411

391412
if __name__ == '__main__':

0 commit comments

Comments
 (0)