Skip to content

Commit 2f7eb77

Browse files
jonatackinstagibbs
authored andcommitted
Add RPC bumpfee totalFee deprecation test
Next steps: remove `totalFee` from the wallet_bumpfee functional tests.
1 parent a92d9ce commit 2f7eb77

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
'rpc_bind.py --nonloopback',
174174
'mining_basic.py',
175175
'wallet_bumpfee.py',
176+
'wallet_bumpfee_totalfee_deprecation.py',
176177
'rpc_named_arguments.py',
177178
'wallet_listsinceblock.py',
178179
'p2p_leak.py',
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2019 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 deprecation of passing `totalFee` to the bumpfee RPC."""
6+
from decimal import Decimal
7+
8+
from test_framework.messages import BIP125_SEQUENCE_NUMBER
9+
from test_framework.test_framework import BitcoinTestFramework
10+
from test_framework.util import assert_raises_rpc_error
11+
12+
class BumpFeeWithTotalFeeArgumentDeprecationTest(BitcoinTestFramework):
13+
def set_test_params(self):
14+
self.num_nodes = 2
15+
self.extra_args = [[
16+
"-walletrbf={}".format(i),
17+
"-mintxfee=0.00002",
18+
] for i in range(self.num_nodes)]
19+
20+
def skip_test_if_missing_module(self):
21+
self.skip_if_no_wallet()
22+
23+
def run_test(self):
24+
peer_node, rbf_node = self.nodes
25+
peer_node.generate(110)
26+
self.sync_all()
27+
peer_node.sendtoaddress(rbf_node.getnewaddress(), 0.001)
28+
self.sync_all()
29+
peer_node.generate(1)
30+
self.sync_all()
31+
rbfid = spend_one_input(rbf_node, peer_node.getnewaddress())
32+
33+
self.log.info("Testing bumpfee with totalFee argument raises RPC error with deprecation message")
34+
assert_raises_rpc_error(
35+
-8,
36+
"totalFee argument has been deprecated and will be removed in 0.20. " +
37+
"Please use -deprecatedrpc=totalFee to continue using this argument until removal.",
38+
rbf_node.bumpfee, rbfid, {"totalFee": 2000})
39+
40+
self.log.info("Testing bumpfee without totalFee argument does not raise")
41+
rbf_node.bumpfee(rbfid)
42+
43+
def spend_one_input(node, dest_address, change_size=Decimal("0.00049000")):
44+
tx_input = dict(sequence=BIP125_SEQUENCE_NUMBER,
45+
**next(u for u in node.listunspent() if u["amount"] == Decimal("0.00100000")))
46+
destinations = {dest_address: Decimal("0.00050000")}
47+
destinations[node.getrawchangeaddress()] = change_size
48+
rawtx = node.createrawtransaction([tx_input], destinations)
49+
signedtx = node.signrawtransactionwithwallet(rawtx)
50+
txid = node.sendrawtransaction(signedtx["hex"])
51+
return txid
52+
53+
if __name__ == "__main__":
54+
BumpFeeWithTotalFeeArgumentDeprecationTest().main()

0 commit comments

Comments
 (0)