test: wallet: refactor: fallbackfee extract common send failure checks.

This commit is contained in:
David Gumberg
2026-03-24 17:40:17 -07:00
parent 1d8cb78d5b
commit d28c989243

View File

@@ -2,13 +2,13 @@
# Copyright (c) 2017-present 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 wallet replace-by-fee capabilities in conjunction with the fallbackfee."""
"""Test wallet fallbackfee."""
from test_framework.blocktools import COINBASE_MATURITY
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_raises_rpc_error
class WalletRBFTest(BitcoinTestFramework):
class WalletFallbackFeeTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
@@ -16,17 +16,22 @@ class WalletRBFTest(BitcoinTestFramework):
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def sending_fails(self, node):
assert_raises_rpc_error(-6, "Fee estimation failed", lambda: node.sendtoaddress(node.getnewaddress(), 1))
assert_raises_rpc_error(-4, "Fee estimation failed", lambda: node.fundrawtransaction(node.createrawtransaction([], {node.getnewaddress(): 1})))
assert_raises_rpc_error(-6, "Fee estimation failed", lambda: node.sendmany("", {node.getnewaddress(): 1}))
def run_test(self):
self.generate(self.nodes[0], COINBASE_MATURITY + 1)
node = self.nodes[0]
self.generate(node, COINBASE_MATURITY + 1)
# sending a transaction without fee estimations must be possible by default on regtest
self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
node.sendtoaddress(node.getnewaddress(), 1)
# test sending a tx with disabled fallback fee (must fail)
# Sending a tx with explicitly disabled fallback fee fails.
self.restart_node(0, extra_args=["-fallbackfee=0"])
assert_raises_rpc_error(-6, "Fee estimation failed", lambda: self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1))
assert_raises_rpc_error(-4, "Fee estimation failed", lambda: self.nodes[0].fundrawtransaction(self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress(): 1})))
assert_raises_rpc_error(-6, "Fee estimation failed", lambda: self.nodes[0].sendmany("", {self.nodes[0].getnewaddress(): 1}))
self.sending_fails(node)
if __name__ == '__main__':
WalletRBFTest(__file__).main()
WalletFallbackFeeTest(__file__).main()