Skip to content

Commit 8f14fc8

Browse files
pinheadmzmzumsande
authored andcommitted
test: cover fastprune with excessive block size
1 parent 271c23e commit 8f14fc8

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

test/functional/feature_fastprune.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2023 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test fastprune mode."""
6+
from test_framework.test_framework import BitcoinTestFramework
7+
from test_framework.util import (
8+
assert_equal
9+
)
10+
from test_framework.blocktools import (
11+
create_block,
12+
create_coinbase,
13+
add_witness_commitment
14+
)
15+
from test_framework.wallet import MiniWallet
16+
17+
18+
class FeatureFastpruneTest(BitcoinTestFramework):
19+
def set_test_params(self):
20+
self.num_nodes = 1
21+
self.extra_args = [["-fastprune"]]
22+
23+
def run_test(self):
24+
self.log.info("ensure that large blocks don't crash or freeze in -fastprune")
25+
wallet = MiniWallet(self.nodes[0])
26+
tx = wallet.create_self_transfer()['tx']
27+
annex = [0x50]
28+
for _ in range(0x10000):
29+
annex.append(0xff)
30+
tx.wit.vtxinwit[0].scriptWitness.stack.append(bytes(annex))
31+
tip = int(self.nodes[0].getbestblockhash(), 16)
32+
time = self.nodes[0].getblock(self.nodes[0].getbestblockhash())['time'] + 1
33+
height = self.nodes[0].getblockcount() + 1
34+
block = create_block(hashprev=tip, ntime=time, txlist=[tx], coinbase=create_coinbase(height=height))
35+
add_witness_commitment(block)
36+
block.solve()
37+
self.nodes[0].submitblock(block.serialize().hex())
38+
assert_equal(int(self.nodes[0].getbestblockhash(), 16), block.sha256)
39+
40+
41+
if __name__ == '__main__':
42+
FeatureFastpruneTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
'feature_includeconf.py',
321321
'feature_addrman.py',
322322
'feature_asmap.py',
323+
'feature_fastprune.py',
323324
'mempool_unbroadcast.py',
324325
'mempool_compatibility.py',
325326
'mempool_accept_wtxid.py',

0 commit comments

Comments
 (0)