test: wallet: refactor: fallbackfee extract common send failure checks.
What changed, and why it matters
This is a minor test-code cleanup. It renames a test class to match the actual topic (fallback fee), shortens a comment, and pulls three repeated 'sending must fail' checks into a helper function. No production code or security behavior is changed.
No security action needed. This is a routine test refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors test/functional/wallet_fallbackfee.py only. It renames WalletRBFTest to WalletFallbackFeeTest, updates the module docstring, introduces a sending_fails() helper that wraps three assert_raises_rpc_error calls, and uses that helper after restarting the node with -fallbackfee=0. The assertions and RPC calls remain identical; only duplication is reduced.
Changed components
test/functional/wallet_fallbackfee.pyInspect captured patch +14 / −9
diff --git a/test/functional/wallet_fallbackfee.py b/test/functional/wallet_fallbackfee.py
index e6930627..b5244020 100755
--- a/test/functional/wallet_fallbackfee.py
+++ b/test/functional/wallet_fallbackfee.py
@@ -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()
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.