aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/fundrawtransaction.py
diff options
context:
space:
mode:
Diffstat (limited to 'qa/rpc-tests/fundrawtransaction.py')
-rwxr-xr-xqa/rpc-tests/fundrawtransaction.py61
1 files changed, 34 insertions, 27 deletions
diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py
index 93d13faa06..0287965b97 100755
--- a/qa/rpc-tests/fundrawtransaction.py
+++ b/qa/rpc-tests/fundrawtransaction.py
@@ -1,12 +1,10 @@
#!/usr/bin/env python2
-# Copyright (c) 2014 The Bitcoin Core developers
+# Copyright (c) 2014-2015 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
-from pprint import pprint
-from time import sleep
# Create one-input, one-output, no-fee transaction:
class RawTransactionsTest(BitcoinTestFramework):
@@ -30,6 +28,11 @@ class RawTransactionsTest(BitcoinTestFramework):
print "Mining blocks..."
min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee']
+ # This test is not meant to test fee estimation and we'd like
+ # to be sure all txs are sent at a consistent desired feerate
+ for node in self.nodes:
+ node.settxfee(min_relay_tx_fee)
+
# if the fee's positive delta is higher than this value tests will fail,
# neg. delta always fail the tests.
# The size of the signature of every input may be at most 2 bytes larger
@@ -48,11 +51,11 @@ class RawTransactionsTest(BitcoinTestFramework):
watchonly_amount = 200
self.nodes[3].importpubkey(watchonly_pubkey, "", True)
watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount)
- self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10);
+ self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10)
- self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5);
- self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0);
- self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0);
+ self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.5)
+ 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)
@@ -125,7 +128,7 @@ class RawTransactionsTest(BitcoinTestFramework):
for aUtx in listunspent:
if aUtx['amount'] == 5.0:
utx = aUtx
- break;
+ break
assert_equal(utx!=False, True)
@@ -154,7 +157,7 @@ class RawTransactionsTest(BitcoinTestFramework):
for aUtx in listunspent:
if aUtx['amount'] == 5.0:
utx = aUtx
- break;
+ break
assert_equal(utx!=False, True)
@@ -184,7 +187,7 @@ class RawTransactionsTest(BitcoinTestFramework):
for aUtx in listunspent:
if aUtx['amount'] == 1.0:
utx = aUtx
- break;
+ break
assert_equal(utx!=False, True)
@@ -309,7 +312,7 @@ class RawTransactionsTest(BitcoinTestFramework):
except JSONRPCException,e:
errorString = e.error['message']
- assert_equal("Insufficient" in errorString, True);
+ assert("Insufficient" in errorString)
@@ -321,11 +324,11 @@ class RawTransactionsTest(BitcoinTestFramework):
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
- txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1);
+ txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
#compare fee
- feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
+ feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################
@@ -336,11 +339,11 @@ class RawTransactionsTest(BitcoinTestFramework):
rawTx = self.nodes[0].createrawtransaction(inputs, outputs)
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
- txId = self.nodes[0].sendmany("", outputs);
+ txId = self.nodes[0].sendmany("", outputs)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
#compare fee
- feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
+ feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################
@@ -363,11 +366,11 @@ class RawTransactionsTest(BitcoinTestFramework):
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
- txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
+ txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
#compare fee
- feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
+ feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################
@@ -396,11 +399,11 @@ class RawTransactionsTest(BitcoinTestFramework):
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
- txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
+ txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
#compare fee
- feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
+ feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################
@@ -419,7 +422,7 @@ class RawTransactionsTest(BitcoinTestFramework):
# send 1.2 BTC to msig addr
- txId = self.nodes[0].sendtoaddress(mSigObj, 1.2);
+ txId = self.nodes[0].sendtoaddress(mSigObj, 1.2)
self.sync_all()
self.nodes[1].generate(1)
self.sync_all()
@@ -447,6 +450,10 @@ class RawTransactionsTest(BitcoinTestFramework):
wait_bitcoinds()
self.nodes = start_nodes(4, self.options.tmpdir)
+ # This test is not meant to test fee estimation and we'd like
+ # to be sure all txs are sent at a consistent desired feerate
+ for node in self.nodes:
+ node.settxfee(min_relay_tx_fee)
connect_nodes_bi(self.nodes,0,1)
connect_nodes_bi(self.nodes,1,2)
@@ -457,7 +464,7 @@ class RawTransactionsTest(BitcoinTestFramework):
error = False
try:
- self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2);
+ self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2)
except:
error = True
assert(error)
@@ -487,13 +494,13 @@ class RawTransactionsTest(BitcoinTestFramework):
###############################################
#empty node1, send some small coins from node0 to node1
- self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
+ self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
for i in range(0,20):
- self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
+ self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
@@ -505,11 +512,11 @@ class RawTransactionsTest(BitcoinTestFramework):
fundedTx = self.nodes[1].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
- txId = self.nodes[1].sendmany("", outputs);
+ txId = self.nodes[1].sendmany("", outputs)
signedFee = self.nodes[1].getrawmempool(True)[txId]['fee']
#compare fee
- feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
+ feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance*19) #~19 inputs
@@ -518,13 +525,13 @@ class RawTransactionsTest(BitcoinTestFramework):
#############################################
#again, empty node1, send some small coins from node0 to node1
- self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
+ self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
for i in range(0,20):
- self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
+ self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()