@@ -58,7 +58,6 @@ def run_test(self):
58
58
self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 1.0 )
59
59
self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 5.0 )
60
60
61
- self .sync_all ()
62
61
self .nodes [0 ].generate (1 )
63
62
self .sync_all ()
64
63
@@ -552,7 +551,6 @@ def run_test(self):
552
551
self .nodes [1 ].walletpassphrase ("test" , 100 )
553
552
signedTx = self .nodes [1 ].signrawtransaction (fundedTx ['hex' ])
554
553
txId = self .nodes [1 ].sendrawtransaction (signedTx ['hex' ])
555
- self .sync_all ()
556
554
self .nodes [1 ].generate (1 )
557
555
self .sync_all ()
558
556
@@ -572,7 +570,6 @@ def run_test(self):
572
570
573
571
for i in range (0 ,20 ):
574
572
self .nodes [0 ].sendtoaddress (self .nodes [1 ].getnewaddress (), 0.01 )
575
- self .sync_all ()
576
573
self .nodes [0 ].generate (1 )
577
574
self .sync_all ()
578
575
@@ -603,7 +600,6 @@ def run_test(self):
603
600
604
601
for i in range (0 ,20 ):
605
602
self .nodes [0 ].sendtoaddress (self .nodes [1 ].getnewaddress (), 0.01 )
606
- self .sync_all ()
607
603
self .nodes [0 ].generate (1 )
608
604
self .sync_all ()
609
605
@@ -677,15 +673,25 @@ def run_test(self):
677
673
signedtx = self .nodes [0 ].signrawtransaction (signedtx ["hex" ])
678
674
assert (signedtx ["complete" ])
679
675
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 )
680
685
681
686
inputs = []
682
687
outputs = {self .nodes [2 ].getnewaddress () : 1 }
683
688
rawtx = self .nodes [3 ].createrawtransaction (inputs , outputs )
684
689
result = self .nodes [3 ].fundrawtransaction (rawtx ) # uses min_relay_tx_fee (set by settxfee)
685
690
result2 = self .nodes [3 ].fundrawtransaction (rawtx , {"feeRate" : 2 * min_relay_tx_fee })
686
691
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 )
689
695
690
696
if __name__ == '__main__' :
691
697
RawTransactionsTest ().main ()
0 commit comments