Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/util.py
Show First 20 Lines • Show All 305 Lines • ▼ Show 20 Lines | def get_rpc_proxy(url, node_number, timeout=None, coveragedir=None): | ||||
coverage_logfile = coverage.get_filename( | coverage_logfile = coverage.get_filename( | ||||
coveragedir, node_number) if coveragedir else None | coveragedir, node_number) if coveragedir else None | ||||
return coverage.AuthServiceProxyWrapper(proxy, coverage_logfile) | return coverage.AuthServiceProxyWrapper(proxy, coverage_logfile) | ||||
def p2p_port(n): | def p2p_port(n): | ||||
assert(n <= MAX_NODES) | assert n <= MAX_NODES | ||||
return PORT_MIN + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES) | return PORT_MIN + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES) | ||||
def rpc_port(n): | def rpc_port(n): | ||||
return PORT_MIN + PORT_RANGE + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES) | return PORT_MIN + PORT_RANGE + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES) | ||||
def rpc_url(datadir, host, port): | def rpc_url(datadir, host, port): | ||||
▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | def find_output(node, txid, amount): | ||||
raise RuntimeError("find_output txid {} : {} not found".format( | raise RuntimeError("find_output txid {} : {} not found".format( | ||||
txid, str(amount))) | txid, str(amount))) | ||||
def gather_inputs(from_node, amount_needed, confirmations_required=1): | def gather_inputs(from_node, amount_needed, confirmations_required=1): | ||||
""" | """ | ||||
Return a random set of unspent txouts that are enough to pay amount_needed | Return a random set of unspent txouts that are enough to pay amount_needed | ||||
""" | """ | ||||
assert(confirmations_required >= 0) | assert confirmations_required >= 0 | ||||
utxo = from_node.listunspent(confirmations_required) | utxo = from_node.listunspent(confirmations_required) | ||||
random.shuffle(utxo) | random.shuffle(utxo) | ||||
inputs = [] | inputs = [] | ||||
total_in = Decimal("0.00000000") | total_in = Decimal("0.00000000") | ||||
while total_in < amount_needed and len(utxo) > 0: | while total_in < amount_needed and len(utxo) > 0: | ||||
t = utxo.pop() | t = utxo.pop() | ||||
total_in += t["amount"] | total_in += t["amount"] | ||||
inputs.append( | inputs.append( | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |