|
42 | 42 | getcontext, |
43 | 43 | ) |
44 | 44 |
|
| 45 | +import time # ELEMENTS |
| 46 | + |
45 | 47 | class SignRawTransactionsTest(BitcoinTestFramework): |
46 | 48 | def set_test_params(self): |
47 | 49 | self.setup_clean_chain = True |
@@ -213,6 +215,8 @@ def witness_script_test(self): |
213 | 215 | self.generate(self.nodes[0], COINBASE_MATURITY + 1, sync_fun=self.no_op) |
214 | 216 | self.nodes[0].sendtoaddress(p2sh_p2wsh_address["address"], 49.999) |
215 | 217 | self.generate(self.nodes[0], 1, sync_fun=self.no_op) |
| 218 | + # ElEMENTS: allow time for block sync |
| 219 | + time.sleep(1) |
216 | 220 | # Get the UTXO info from scantxoutset |
217 | 221 | unspent_output = self.nodes[1].scantxoutset('start', [p2sh_p2wsh_address['descriptor']])['unspents'][0] |
218 | 222 | spk = script_to_p2sh_p2wsh_script(p2sh_p2wsh_address['redeemScript']).hex() |
@@ -279,7 +283,7 @@ def OP_1NEGATE_test(self): |
279 | 283 | def test_signing_with_csv(self): |
280 | 284 | self.log.info("Test signing a transaction containing a fully signed CSV input") |
281 | 285 | self.nodes[0].walletpassphrase("password", 9999) |
282 | | - getcontext().prec = 8 |
| 286 | + getcontext().prec = 10 |
283 | 287 |
|
284 | 288 | # Make sure CSV is active |
285 | 289 | assert self.nodes[0].getdeploymentinfo()['deployments']['csv']['active'] |
@@ -328,6 +332,14 @@ def test_signing_with_cltv(self): |
328 | 332 | vout = find_vout_for_address(self.nodes[0], txid, address) |
329 | 333 | self.generate(self.nodes[0], 1, sync_fun=self.no_op) |
330 | 334 | utxo = self.nodes[0].listunspent()[0] |
| 335 | + # ELEMENTS: |
| 336 | + # use increased Decimal precision |
| 337 | + # when utxo['amount'] has many decimal places (eg: 50.00005640) |
| 338 | + # then this 'amt' calculation would be incorrect |
| 339 | + # precision 8: 1 + 50.00005640 - 0.00001 = 51.000046 |
| 340 | + # precision 10: 1 + 50.00005640 - 0.00001 = 51.00004640 |
| 341 | + # which causes the inputs/outputs to not balance |
| 342 | + getcontext().prec = 10 |
331 | 343 | amt = Decimal(1) + utxo["amount"] - Decimal(0.00001) |
332 | 344 | tx = self.nodes[0].createrawtransaction( |
333 | 345 | [{"txid": txid, "vout": vout},{"txid": utxo["txid"], "vout": utxo["vout"]}], |
|
0 commit comments