Skip to content

Commit

Permalink
test: cover fastprune with excessive block size
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz authored and mzumsande committed Apr 19, 2023
1 parent 271c23e commit 8f14fc8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/functional/feature_fastprune.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
# Copyright (c) 2023 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test fastprune mode."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal
)
from test_framework.blocktools import (
create_block,
create_coinbase,
add_witness_commitment
)
from test_framework.wallet import MiniWallet


class FeatureFastpruneTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.extra_args = [["-fastprune"]]

def run_test(self):
self.log.info("ensure that large blocks don't crash or freeze in -fastprune")
wallet = MiniWallet(self.nodes[0])
tx = wallet.create_self_transfer()['tx']
annex = [0x50]
for _ in range(0x10000):
annex.append(0xff)
tx.wit.vtxinwit[0].scriptWitness.stack.append(bytes(annex))
tip = int(self.nodes[0].getbestblockhash(), 16)
time = self.nodes[0].getblock(self.nodes[0].getbestblockhash())['time'] + 1
height = self.nodes[0].getblockcount() + 1
block = create_block(hashprev=tip, ntime=time, txlist=[tx], coinbase=create_coinbase(height=height))
add_witness_commitment(block)
block.solve()
self.nodes[0].submitblock(block.serialize().hex())
assert_equal(int(self.nodes[0].getbestblockhash(), 16), block.sha256)


if __name__ == '__main__':
FeatureFastpruneTest().main()
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
'feature_includeconf.py',
'feature_addrman.py',
'feature_asmap.py',
'feature_fastprune.py',
'mempool_unbroadcast.py',
'mempool_compatibility.py',
'mempool_accept_wtxid.py',
Expand Down

0 comments on commit 8f14fc8

Please sign in to comment.