Skip to content

Commit 67bb197

Browse files
committed
test: fix flaky CLTV test in signrawtransaction.py
1 parent c92a8f2 commit 67bb197

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/functional/rpc_signrawtransaction.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ def test_signing_with_cltv(self):
328328
vout = find_vout_for_address(self.nodes[0], txid, address)
329329
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
330330
utxo = self.nodes[0].listunspent()[0]
331+
# ELEMENTS:
332+
# use increased Decimal precision
333+
# when utxo['amount'] has many decimal places (eg: 50.00005640)
334+
# then this 'amt' calculation would be incorrect
335+
# precision 8: 1 + 50.00005640 - 0.00001 = 51.000046
336+
# precision 10: 1 + 50.00005640 - 0.00001 = 51.00004640
337+
# which causes the inputs/outputs to not balance
338+
getcontext().prec = 10
331339
amt = Decimal(1) + utxo["amount"] - Decimal(0.00001)
332340
tx = self.nodes[0].createrawtransaction(
333341
[{"txid": txid, "vout": vout},{"txid": utxo["txid"], "vout": utxo["vout"]}],

0 commit comments

Comments
 (0)