/ test / functional / wallet_fallbackfee.py
wallet_fallbackfee.py
 1  #!/usr/bin/env python3
 2  # Copyright (c) 2017-present The Bitcoin Core developers
 3  # Distributed under the MIT software license, see the accompanying
 4  # file COPYING or http://www.opensource.org/licenses/mit-license.php.
 5  """Test wallet replace-by-fee capabilities in conjunction with the fallbackfee."""
 6  
 7  from test_framework.blocktools import COINBASE_MATURITY
 8  from test_framework.test_framework import BitcoinTestFramework
 9  from test_framework.util import assert_raises_rpc_error
10  
11  class WalletRBFTest(BitcoinTestFramework):
12      def set_test_params(self):
13          self.num_nodes = 1
14          self.setup_clean_chain = True
15  
16      def skip_test_if_missing_module(self):
17          self.skip_if_no_wallet()
18  
19      def run_test(self):
20          self.generate(self.nodes[0], COINBASE_MATURITY + 1)
21  
22          # sending a transaction without fee estimations must be possible by default on regtest
23          self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
24  
25          # test sending a tx with disabled fallback fee (must fail)
26          self.restart_node(0, extra_args=["-fallbackfee=0"])
27          assert_raises_rpc_error(-6, "Fee estimation failed", lambda: self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1))
28          assert_raises_rpc_error(-4, "Fee estimation failed", lambda: self.nodes[0].fundrawtransaction(self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress(): 1})))
29          assert_raises_rpc_error(-6, "Fee estimation failed", lambda: self.nodes[0].sendmany("", {self.nodes[0].getnewaddress(): 1}))
30  
31  if __name__ == '__main__':
32      WalletRBFTest(__file__).main()