test: wallet: -fallbackfee default is 0
What changed, and why it matters
This commit only changes a test file. It improves an existing functional test to verify that Bitcoin Core's wallet correctly fails to send transactions when the fallback fee is unset or set to zero, and succeeds when a fallback fee is configured. There is no change to production code, no security fix, and no vulnerability being patched.
No action required. This is a test-only change and does not affect production security posture.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/wallet_fallbackfee.py. It adds a helper method sending_succeeds() that checks the fee_reason is ‘Fallback fee’ for sendtoaddress, fundrawtransaction, and sendmany. It updates the test flow to: (1) remove the test framework’s default fallbackfee from config, (2) restart the node, (3) assert sending fails because the default fallbackfee is 0, (4) assert sending still fails with -fallbackfee=0 explicitly, and (5) assert sending succeeds with a configured fallback fee. This is purely a test-coverage improvement.
Changed components
test/functional/wallet_fallbackfee.pyInspect captured patch +32 / −3
diff --git a/test/functional/wallet_fallbackfee.py b/test/functional/wallet_fallbackfee.py
index b5244020..b2a76b85 100755
--- a/test/functional/wallet_fallbackfee.py
+++ b/test/functional/wallet_fallbackfee.py
@@ -4,9 +4,14 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test wallet fallbackfee."""
+from decimal import Decimal
+
from test_framework.blocktools import COINBASE_MATURITY
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import assert_raises_rpc_error
+from test_framework.util import assert_equal, assert_raises_rpc_error
+
+HIGH_TX_FEE_PER_KB = Decimal('0.01')
+
class WalletFallbackFeeTest(BitcoinTestFramework):
def set_test_params(self):
@@ -16,6 +21,18 @@ class WalletFallbackFeeTest(BitcoinTestFramework):
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
+ def sending_succeeds(self, node):
+ # Check that fallback fee is being used as a test-of-the-test.
+ assert_equal(
+ node.sendtoaddress(node.getnewaddress(), 1, verbose=True)['fee_reason'],
+ "Fallback fee"
+ )
+ node.fundrawtransaction(node.createrawtransaction([], {node.getnewaddress(): 1}))
+ assert_equal(
+ node.sendmany("", {node.getnewaddress(): 1}, verbose=True)["fee_reason"],
+ "Fallback fee"
+ )
+
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})))
@@ -25,13 +42,25 @@ class WalletFallbackFeeTest(BitcoinTestFramework):
node = self.nodes[0]
self.generate(node, COINBASE_MATURITY + 1)
- # sending a transaction without fee estimations must be possible by default on regtest
- node.sendtoaddress(node.getnewaddress(), 1)
+ # By default, the test framework sets a fallback fee for nodes,
+ # in order to test default behavior, comment this line out.
+ node.replace_in_config([("fallbackfee=", "#fallbackfee=")])
+ self.restart_node(0)
+
+ # Sending a transaction with no -fallbackfee setting fails, since the
+ # default value is 0.
+ self.sending_fails(node)
# Sending a tx with explicitly disabled fallback fee fails.
self.restart_node(0, extra_args=["-fallbackfee=0"])
self.sending_fails(node)
+ # Sending a transaction with a fallback fee set succeeds. Use the
+ # largest fallbackfee value that doesn't trigger a warning.
+ self.restart_node(0, extra_args=[f"-fallbackfee={HIGH_TX_FEE_PER_KB}"])
+ self.sending_succeeds(node)
+ self.stop_node(0, expected_stderr='')
+
if __name__ == '__main__':
WalletFallbackFeeTest(__file__).main()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.