Skip to content

Commit 16f6f59

Browse files
committed
[qa] Test fundrawtransaction with change_type option
1 parent 536ddeb commit 16f6f59

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/functional/fundrawtransaction.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,19 @@ def run_test(self):
212212
out = dec_tx['vout'][0]
213213
assert_equal(change, out['scriptPubKey']['addresses'][0])
214214

215+
#########################################################
216+
# test a fundrawtransaction with a provided change type #
217+
#########################################################
218+
utx = get_unspent(self.nodes[2].listunspent(), 5)
219+
220+
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']} ]
221+
outputs = { self.nodes[0].getnewaddress() : Decimal(4.0) }
222+
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
223+
assert_raises_rpc_error(-1, "JSON value is not a string as expected", self.nodes[2].fundrawtransaction, rawtx, {'change_type': None})
224+
assert_raises_rpc_error(-5, "Unknown change type", self.nodes[2].fundrawtransaction, rawtx, {'change_type': ''})
225+
rawtx = self.nodes[2].fundrawtransaction(rawtx, {'change_type': 'bech32'})
226+
tx = self.nodes[2].decoderawtransaction(rawtx['hex'])
227+
assert_equal('witness_v0_keyhash', tx['vout'][rawtx['changepos']]['scriptPubKey']['type'])
215228

216229
#########################################################################
217230
# test a fundrawtransaction with a VIN smaller than the required amount #

0 commit comments

Comments
 (0)