Skip to content

Commit

Permalink
test: add regression test for the getrawtransaction segfault
Browse files Browse the repository at this point in the history
This fails on master without the previous commit.
  • Loading branch information
mzumsande committed Dec 5, 2023
1 parent 494a926 commit 9075a44
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/functional/rpc_rawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_greater_than,
assert_raises_rpc_error,
)
from test_framework.wallet import (
Expand Down Expand Up @@ -70,7 +71,7 @@ def set_test_params(self):
self.extra_args = [
["-txindex"],
["-txindex"],
[],
["-fastprune", "-prune=1"],
]
# whitelist all peers to speed up tx relay / mempool sync
for args in self.extra_args:
Expand All @@ -85,7 +86,6 @@ def run_test(self):
self.wallet = MiniWallet(self.nodes[0])

self.getrawtransaction_tests()
self.getrawtransaction_verbosity_tests()
self.createrawtransaction_tests()
self.sendrawtransaction_tests()
self.sendrawtransaction_testmempoolaccept_tests()
Expand All @@ -94,6 +94,8 @@ def run_test(self):
if self.is_specified_wallet_compiled() and not self.options.descriptors:
self.import_deterministic_coinbase_privkeys()
self.raw_multisig_transaction_legacy_tests()
self.getrawtransaction_verbosity_tests()


def getrawtransaction_tests(self):
tx = self.wallet.send_self_transfer(from_node=self.nodes[0])
Expand Down Expand Up @@ -243,6 +245,13 @@ def getrawtransaction_verbosity_tests(self):
coin_base = self.nodes[1].getblock(block1)['tx'][0]
gottx = self.nodes[1].getrawtransaction(txid=coin_base, verbosity=2, blockhash=block1)
assert 'fee' not in gottx
# check that verbosity 2 for a mempool tx will fallback to verbosity 1
# Do this with a pruned chain, as a regression test for https://github.com/bitcoin/bitcoin/pull/29003
self.generate(self.nodes[2], 400)
assert_greater_than(self.nodes[2].pruneblockchain(250), 0)
mempool_tx = self.wallet.send_self_transfer(from_node=self.nodes[2])['txid']
gottx = self.nodes[2].getrawtransaction(txid=mempool_tx, verbosity=2)
assert 'fee' not in gottx

def createrawtransaction_tests(self):
self.log.info("Test createrawtransaction")
Expand Down

0 comments on commit 9075a44

Please sign in to comment.