@@ -58,7 +58,6 @@ def run_test(self):
5858 self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 10 )
5959 self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 50 )
6060
61- self .sync_all ()
6261 self .nodes [0 ].generate (1 )
6362 self .sync_all ()
6463
@@ -569,7 +568,6 @@ def run_test(self):
569568 self .nodes [1 ].walletpassphrase ("test" , 100 )
570569 signedTx = self .nodes [1 ].signrawtransaction (fundedTx ['hex' ])
571570 txId = self .nodes [1 ].sendrawtransaction (signedTx ['hex' ])
572- self .sync_all ()
573571 self .nodes [1 ].generate (1 )
574572 self .sync_all ()
575573
@@ -588,7 +586,6 @@ def run_test(self):
588586
589587 for i in range (0 ,20 ):
590588 self .nodes [0 ].sendtoaddress (self .nodes [1 ].getnewaddress (), 0.01 )
591- self .sync_all ()
592589 self .nodes [0 ].generate (1 )
593590 self .sync_all ()
594591
@@ -619,7 +616,6 @@ def run_test(self):
619616
620617 for i in range (0 ,20 ):
621618 self .nodes [0 ].sendtoaddress (self .nodes [1 ].getnewaddress (), 0.01 )
622- self .sync_all ()
623619 self .nodes [0 ].generate (1 )
624620 self .sync_all ()
625621
@@ -693,15 +689,25 @@ def run_test(self):
693689 signedtx = self .nodes [0 ].signrawtransaction (signedtx ["hex" ])
694690 assert (signedtx ["complete" ])
695691 self .nodes [0 ].sendrawtransaction (signedtx ["hex" ])
692+ self .nodes [0 ].generate (1 )
693+ self .sync_all ()
694+
695+ #######################
696+ # Test feeRate option #
697+ #######################
698+
699+ # Make sure there is exactly one input so coin selection can't skew the result
700+ assert_equal (len (self .nodes [3 ].listunspent (1 )), 1 )
696701
697702 inputs = []
698703 outputs = {self .nodes [2 ].getnewaddress () : 1 }
699704 rawtx = self .nodes [3 ].createrawtransaction (inputs , outputs )
700705 result = self .nodes [3 ].fundrawtransaction (rawtx ) # uses min_relay_tx_fee (set by settxfee)
701706 result2 = self .nodes [3 ].fundrawtransaction (rawtx , {"feeRate" : 2 * min_relay_tx_fee })
702707 result3 = self .nodes [3 ].fundrawtransaction (rawtx , {"feeRate" : 10 * min_relay_tx_fee })
703- assert_equal (result ['fee' ]* 2 , result2 ['fee' ])
704- assert_equal (result ['fee' ]* 10 , result3 ['fee' ])
708+ result_fee_rate = result ['fee' ] * 1000 / count_bytes (result ['hex' ])
709+ assert_fee_amount (result2 ['fee' ], count_bytes (result2 ['hex' ]), 2 * result_fee_rate )
710+ assert_fee_amount (result3 ['fee' ], count_bytes (result3 ['hex' ]), 10 * result_fee_rate )
705711
706712if __name__ == '__main__' :
707713 RawTransactionsTest ().main ()
0 commit comments