Skip to content

Commit fae1d06

Browse files
author
MarcoFalke
committed
[qa] fundrawtransaction: Fix race, assert amounts
1 parent fa26c42 commit fae1d06

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

qa/rpc-tests/fundrawtransaction.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def run_test(self):
5858
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0)
5959
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 5.0)
6060

61-
self.sync_all()
6261
self.nodes[0].generate(1)
6362
self.sync_all()
6463

@@ -552,7 +551,6 @@ def run_test(self):
552551
self.nodes[1].walletpassphrase("test", 100)
553552
signedTx = self.nodes[1].signrawtransaction(fundedTx['hex'])
554553
txId = self.nodes[1].sendrawtransaction(signedTx['hex'])
555-
self.sync_all()
556554
self.nodes[1].generate(1)
557555
self.sync_all()
558556

@@ -572,7 +570,6 @@ def run_test(self):
572570

573571
for i in range(0,20):
574572
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
575-
self.sync_all()
576573
self.nodes[0].generate(1)
577574
self.sync_all()
578575

@@ -603,7 +600,6 @@ def run_test(self):
603600

604601
for i in range(0,20):
605602
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
606-
self.sync_all()
607603
self.nodes[0].generate(1)
608604
self.sync_all()
609605

@@ -677,15 +673,25 @@ def run_test(self):
677673
signedtx = self.nodes[0].signrawtransaction(signedtx["hex"])
678674
assert(signedtx["complete"])
679675
self.nodes[0].sendrawtransaction(signedtx["hex"])
676+
self.nodes[0].generate(1)
677+
self.sync_all()
678+
679+
#######################
680+
# Test feeRate option #
681+
#######################
682+
683+
# Make sure there is exactly one input so coin selection can't skew the result
684+
assert_equal(len(self.nodes[3].listunspent(1)), 1)
680685

681686
inputs = []
682687
outputs = {self.nodes[2].getnewaddress() : 1}
683688
rawtx = self.nodes[3].createrawtransaction(inputs, outputs)
684689
result = self.nodes[3].fundrawtransaction(rawtx) # uses min_relay_tx_fee (set by settxfee)
685690
result2 = self.nodes[3].fundrawtransaction(rawtx, {"feeRate": 2*min_relay_tx_fee})
686691
result3 = self.nodes[3].fundrawtransaction(rawtx, {"feeRate": 10*min_relay_tx_fee})
687-
assert_equal(result['fee']*2, result2['fee'])
688-
assert_equal(result['fee']*10, result3['fee'])
692+
result_fee_rate = result['fee'] * 1000 / count_bytes(result['hex'])
693+
assert_fee_amount(result2['fee'], count_bytes(result2['hex']), 2 * result_fee_rate)
694+
assert_fee_amount(result3['fee'], count_bytes(result3['hex']), 10 * result_fee_rate)
689695

690696
if __name__ == '__main__':
691697
RawTransactionsTest().main()

0 commit comments

Comments
 (0)