Skip to content

Commit f1ccc08

Browse files
committed
txid: Test bumpfee orig_change_pos
1 parent 55bf001 commit f1ccc08

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/functional/wallet_bumpfee.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
assert_equal,
3131
assert_greater_than,
3232
assert_raises_rpc_error,
33+
find_vout_for_address,
3334
)
3435
from test_framework.wallet import MiniWallet
3536

@@ -103,6 +104,7 @@ def run_test(self):
103104
# These tests wipe out a number of utxos that are expected in other tests
104105
test_small_output_with_feerate_succeeds(self, rbf_node, dest_address)
105106
test_no_more_inputs_fails(self, rbf_node, dest_address)
107+
self.test_provided_change_pos(rbf_node)
106108

107109
def test_invalid_parameters(self, rbf_node, peer_node, dest_address):
108110
self.log.info('Test invalid parameters')
@@ -157,9 +159,42 @@ def test_invalid_parameters(self, rbf_node, peer_node, dest_address):
157159
assert_raises_rpc_error(-8, 'Invalid estimate_mode parameter, must be one of: "unset", "economical", "conservative"',
158160
rbf_node.bumpfee, rbfid, {"estimate_mode": mode})
159161

162+
self.log.info("Test change position option")
163+
assert_raises_rpc_error(-1, "JSON integer out of range", rbf_node.bumpfee, rbfid, {"reduce_output": -1})
164+
assert_raises_rpc_error(-8, "Change position is out of range", rbf_node.bumpfee, rbfid, {"reduce_output": 2})
165+
160166
self.clear_mempool()
161167

162168

169+
def test_provided_change_pos(self, rbf_node):
170+
self.log.info("Test the reduce_output option")
171+
172+
change_addr = rbf_node.getnewaddress()
173+
dest_addr = rbf_node.getnewaddress()
174+
assert_equal(rbf_node.getaddressinfo(change_addr)["ischange"], False)
175+
assert_equal(rbf_node.getaddressinfo(dest_addr)["ischange"], False)
176+
177+
send_res = rbf_node.send(outputs=[{dest_addr: 1}], options={"change_address": change_addr})
178+
assert send_res["complete"]
179+
txid = send_res["txid"]
180+
181+
tx = rbf_node.gettransaction(txid=txid, verbose=True)
182+
assert_equal(len(tx["decoded"]["vout"]), 2)
183+
184+
change_pos = find_vout_for_address(rbf_node, txid, change_addr)
185+
change_value = tx["decoded"]["vout"][change_pos]["value"]
186+
187+
bumped = rbf_node.bumpfee(txid, {"reduce_output": change_pos})
188+
new_txid = bumped["txid"]
189+
190+
new_tx = rbf_node.gettransaction(txid=new_txid, verbose=True)
191+
assert_equal(len(new_tx["decoded"]["vout"]), 2)
192+
new_change_pos = find_vout_for_address(rbf_node, new_txid, change_addr)
193+
new_change_value = new_tx["decoded"]["vout"][new_change_pos]["value"]
194+
195+
assert_greater_than(change_value, new_change_value)
196+
197+
163198
def test_simple_bumpfee_succeeds(self, mode, rbf_node, peer_node, dest_address):
164199
self.log.info('Test simple bumpfee: {}'.format(mode))
165200
rbfid = spend_one_input(rbf_node, dest_address)

0 commit comments

Comments
 (0)