diff options
author | MarcoFalke <falke.marco@gmail.com> | 2016-06-13 19:52:01 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2016-06-13 21:35:04 +0200 |
commit | fae1d063fc8a54067a8527d249d8801a00feef03 (patch) | |
tree | 0303af4009458347cddd9551f7a37ffbf7d35901 | |
parent | fa26c420bfb7dbad6781f31f222a66ef52f2ae45 (diff) |
[qa] fundrawtransaction: Fix race, assert amounts
-rwxr-xr-x | qa/rpc-tests/fundrawtransaction.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py index 998f822afe..228574e671 100755 --- a/qa/rpc-tests/fundrawtransaction.py +++ b/qa/rpc-tests/fundrawtransaction.py @@ -58,7 +58,6 @@ class RawTransactionsTest(BitcoinTestFramework): self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 5.0) - self.sync_all() self.nodes[0].generate(1) self.sync_all() @@ -552,7 +551,6 @@ class RawTransactionsTest(BitcoinTestFramework): self.nodes[1].walletpassphrase("test", 100) signedTx = self.nodes[1].signrawtransaction(fundedTx['hex']) txId = self.nodes[1].sendrawtransaction(signedTx['hex']) - self.sync_all() self.nodes[1].generate(1) self.sync_all() @@ -572,7 +570,6 @@ class RawTransactionsTest(BitcoinTestFramework): for i in range(0,20): self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01) - self.sync_all() self.nodes[0].generate(1) self.sync_all() @@ -603,7 +600,6 @@ class RawTransactionsTest(BitcoinTestFramework): for i in range(0,20): self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01) - self.sync_all() self.nodes[0].generate(1) self.sync_all() @@ -677,6 +673,15 @@ class RawTransactionsTest(BitcoinTestFramework): signedtx = self.nodes[0].signrawtransaction(signedtx["hex"]) assert(signedtx["complete"]) self.nodes[0].sendrawtransaction(signedtx["hex"]) + self.nodes[0].generate(1) + self.sync_all() + + ####################### + # Test feeRate option # + ####################### + + # Make sure there is exactly one input so coin selection can't skew the result + assert_equal(len(self.nodes[3].listunspent(1)), 1) inputs = [] outputs = {self.nodes[2].getnewaddress() : 1} @@ -684,8 +689,9 @@ class RawTransactionsTest(BitcoinTestFramework): result = self.nodes[3].fundrawtransaction(rawtx) # uses min_relay_tx_fee (set by settxfee) result2 = self.nodes[3].fundrawtransaction(rawtx, {"feeRate": 2*min_relay_tx_fee}) result3 = self.nodes[3].fundrawtransaction(rawtx, {"feeRate": 10*min_relay_tx_fee}) - assert_equal(result['fee']*2, result2['fee']) - assert_equal(result['fee']*10, result3['fee']) + result_fee_rate = result['fee'] * 1000 / count_bytes(result['hex']) + assert_fee_amount(result2['fee'], count_bytes(result2['hex']), 2 * result_fee_rate) + assert_fee_amount(result3['fee'], count_bytes(result3['hex']), 10 * result_fee_rate) if __name__ == '__main__': RawTransactionsTest().main() |