aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/util.py
diff options
context:
space:
mode:
authormrbandrews <bandrewsny@gmail.com>2014-11-19 15:55:40 -0500
committermrbandrews <bandrewsny@gmail.com>2014-11-20 14:11:44 -0500
commit189fb526f188e90eed24840b826b6c6b97f3e479 (patch)
tree7502e79afc0f0d4255df729cf0fff132b4a1f92e /qa/rpc-tests/util.py
parentb5d1b1092998bc95313856d535c632ea5a8f9104 (diff)
downloadbitcoin-189fb526f188e90eed24840b826b6c6b97f3e479.tar.xz
Port of wallet.sh to python (wallet.py).
Also included are minor edits to util.py to create a clean blockchain and add a parameter to gather_inputs to specify number of confirmations.
Diffstat (limited to 'qa/rpc-tests/util.py')
-rw-r--r--qa/rpc-tests/util.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/qa/rpc-tests/util.py b/qa/rpc-tests/util.py
index c6d918a81c..bed7fed8ca 100644
--- a/qa/rpc-tests/util.py
+++ b/qa/rpc-tests/util.py
@@ -57,7 +57,6 @@ def sync_mempools(rpc_connections):
if num_match == len(rpc_connections):
break
time.sleep(1)
-
bitcoind_processes = {}
@@ -130,6 +129,15 @@ def initialize_chain(test_dir):
shutil.copytree(from_dir, to_dir)
initialize_datadir(test_dir, i) # Overwrite port/rpcport in bitcoin.conf
+def initialize_chain_clean(test_dir, num_nodes):
+ """
+ Create an empty blockchain and num_nodes wallets.
+ Useful if a test case wants complete control over initialization.
+ """
+ for i in range(num_nodes):
+ datadir=initialize_datadir(test_dir, i)
+
+
def _rpchost_to_args(rpchost):
'''Convert optional IP:port spec to rpcconnect/rpcport args'''
if rpchost is None:
@@ -221,11 +229,13 @@ def find_output(node, txid, amount):
return i
raise RuntimeError("find_output txid %s : %s not found"%(txid,str(amount)))
-def gather_inputs(from_node, amount_needed):
+
+def gather_inputs(from_node, amount_needed, confirmations_required=1):
"""
Return a random set of unspent txouts that are enough to pay amount_needed
"""
- utxo = from_node.listunspent(1)
+ assert(confirmations_required >=0)
+ utxo = from_node.listunspent(confirmations_required)
random.shuffle(utxo)
inputs = []
total_in = Decimal("0.00000000")