Created
November 21, 2024 17:37
-
-
Save instagibbs/cb1f7cfbd0a70e8b5393e457c7a959e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py | |
index fb649c1a6b..fe0cc5fa42 100755 | |
--- a/test/functional/mining_basic.py | |
+++ b/test/functional/mining_basic.py | |
@@ -54,11 +54,16 @@ def assert_template(node, block, expect, rehash=True): | |
assert_equal(rsp, expect) | |
class MiningTest(BitcoinTestFramework): | |
def set_test_params(self): | |
- self.num_nodes = 2 | |
+ self.num_nodes = 3 | |
+ self.extra_args = [ | |
+ [], | |
+ [], | |
+ ["-fastprune", "-prune=1"] | |
+ ] | |
self.setup_clean_chain = True | |
self.supports_cli = False | |
def mine_chain(self): | |
self.log.info('Create some old blocks') | |
@@ -166,10 +171,25 @@ class MiningTest(BitcoinTestFramework): | |
bad_block.nTime = t + MAX_FUTURE_BLOCK_TIME - MAX_TIMEWARP | |
bad_block.solve() | |
node.submitheader(hexdata=CBlockHeader(bad_block).serialize().hex()) | |
+ def test_pruning(self): | |
+ self.log.info("Test that submitblock stores previously pruned block") | |
+ prune_node = self.nodes[2] | |
+ self.generate(prune_node, 400, sync_fun=self.no_op) | |
+ pruned_block = prune_node.getblock(prune_node.getblockhash(2), verbosity=0) | |
+ pruned_height = prune_node.pruneblockchain(400) | |
+ assert_greater_than_or_equal(pruned_height, 2) | |
+ pruned_blockhash = prune_node.getblockhash(2) | |
+ | |
+ assert_raises_rpc_error(-1, 'Block not available (pruned data)', prune_node.getblock, pruned_blockhash) | |
+ | |
+ result = prune_node.submitblock(pruned_block) | |
+ assert_equal(result, "inconclusive") | |
+ assert_equal(prune_node.getblock(pruned_blockhash, verbosity=0), pruned_block) | |
+ | |
def run_test(self): | |
node = self.nodes[0] | |
self.wallet = MiniWallet(node) | |
self.mine_chain() | |
@@ -382,9 +402,10 @@ class MiningTest(BitcoinTestFramework): | |
node.submitheader(hexdata=CBlockHeader(bad_block_root).serialize().hex()) | |
assert_equal(node.submitblock(hexdata=block.serialize().hex()), 'duplicate') # valid | |
self.test_blockmintxfee_parameter() | |
self.test_timewarp() | |
+ self.test_pruning() | |
if __name__ == '__main__': | |
MiningTest(__file__).main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment