Skip to content

Commit a165bfb

Browse files
committed
tests: rpc_fundrawtx use specific inputs for unavailable change test
For the test that checks that there is no error when change is unavailable but change is also not needed, use specific UTXOs so that SRD does not cause this to fail when it chooses random inputs.
1 parent df765a4 commit a165bfb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/functional/rpc_fundrawtransaction.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,18 @@ def test_locked_wallet(self):
587587
# Drain the keypool.
588588
self.nodes[1].getnewaddress()
589589
self.nodes[1].getrawchangeaddress()
590-
inputs = []
591-
outputs = {self.nodes[0].getnewaddress():1.19999500}
590+
591+
# Choose 2 inputs
592+
inputs = self.nodes[1].listunspent()[0:2]
593+
value = sum(inp["amount"] for inp in inputs) - Decimal("0.00000500") # Pay a 500 sat fee
594+
outputs = {self.nodes[0].getnewaddress():value}
592595
rawtx = self.nodes[1].createrawtransaction(inputs, outputs)
593596
# fund a transaction that does not require a new key for the change output
594597
self.nodes[1].fundrawtransaction(rawtx)
595598

596599
# fund a transaction that requires a new key for the change output
597600
# creating the key must be impossible because the wallet is locked
598-
outputs = {self.nodes[0].getnewaddress():1.1}
601+
outputs = {self.nodes[0].getnewaddress():value - Decimal("0.1")}
599602
rawtx = self.nodes[1].createrawtransaction(inputs, outputs)
600603
assert_raises_rpc_error(-4, "Transaction needs a change address, but we can't generate it.", self.nodes[1].fundrawtransaction, rawtx)
601604

0 commit comments

Comments
 (0)