Merge pull request #5410 from LarryRuane/2021-12-06-test-python-standalone
Allow rpc python tests to be run standalone
This commit is contained in:
commit
f285a39063
|
@ -76,3 +76,10 @@ Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- The `boost` and `native_b2` dependencies have been updated to version 1.79.0
|
- The `boost` and `native_b2` dependencies have been updated to version 1.79.0
|
||||||
|
|
||||||
|
Tests
|
||||||
|
-----
|
||||||
|
|
||||||
|
- The environment variable that allows users of the rpc (Python) tests to
|
||||||
|
override the default path to the `zcashd` executable has been changed
|
||||||
|
from `BITCOIND` to `ZCASHD`.
|
||||||
|
|
|
@ -274,8 +274,8 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
|
||||||
BOLD = ('\033[0m', '\033[1m')
|
BOLD = ('\033[0m', '\033[1m')
|
||||||
|
|
||||||
#Set env vars
|
#Set env vars
|
||||||
if "BITCOIND" not in os.environ:
|
if "ZCASHD" not in os.environ:
|
||||||
os.environ["BITCOIND"] = build_dir + '/src/zcashd' + exeext
|
os.environ["ZCASHD"] = build_dir + '/src/zcashd' + exeext
|
||||||
|
|
||||||
tests_dir = src_dir + '/qa/rpc-tests/'
|
tests_dir = src_dir + '/qa/rpc-tests/'
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \
|
from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \
|
||||||
EarlyDisconnectError, CInv, msg_inv, mininode_lock
|
EarlyDisconnectError, CInv, msg_inv, mininode_lock
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import start_nodes, p2p_port
|
from test_framework.util import ZCASHD_BINARY, start_nodes, p2p_port
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
@ -82,7 +82,7 @@ class TestManager(NodeConnCB):
|
||||||
class MaxBlocksInFlightTest(BitcoinTestFramework):
|
class MaxBlocksInFlightTest(BitcoinTestFramework):
|
||||||
def add_options(self, parser):
|
def add_options(self, parser):
|
||||||
parser.add_option("--testbinary", dest="testbinary",
|
parser.add_option("--testbinary", dest="testbinary",
|
||||||
default=os.getenv("BITCOIND", "bitcoind"),
|
default=os.getenv("ZCASHD", ZCASHD_BINARY),
|
||||||
help="Binary to test max block requests behavior")
|
help="Binary to test max block requests behavior")
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -12,7 +12,7 @@ from test_framework.mininode import ( \
|
||||||
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import ( \
|
from test_framework.util import ( \
|
||||||
assert_equal, initialize_chain_clean, \
|
ZCASHD_BINARY, assert_equal, initialize_chain_clean, \
|
||||||
start_node, stop_node, \
|
start_node, stop_node, \
|
||||||
p2p_port, \
|
p2p_port, \
|
||||||
)
|
)
|
||||||
|
@ -112,10 +112,10 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
self.txouts = self.txouts + "fd0402"
|
self.txouts = self.txouts + "fd0402"
|
||||||
# add script_pubkey
|
# add script_pubkey
|
||||||
self.txouts = self.txouts + script_pubkey
|
self.txouts = self.txouts + script_pubkey
|
||||||
|
|
||||||
def add_options(self, parser):
|
def add_options(self, parser):
|
||||||
parser.add_option("--testbinary", dest="testbinary",
|
parser.add_option("--testbinary", dest="testbinary",
|
||||||
default=os.getenv("BITCOIND", "zcashd"),
|
default=os.getenv("ZCASHD", ZCASHD_BINARY),
|
||||||
help="zcashd binary to test")
|
help="zcashd binary to test")
|
||||||
|
|
||||||
def setup_chain(self):
|
def setup_chain(self):
|
||||||
|
@ -142,7 +142,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
remchange = t["amount"] - Decimal("0.001000")
|
remchange = t["amount"] - Decimal("0.001000")
|
||||||
outputs[address]=remchange
|
outputs[address]=remchange
|
||||||
# Create a basic transaction that will send change back to ourself after account for a fee
|
# Create a basic transaction that will send change back to ourself after account for a fee
|
||||||
# and then insert the 128 generated transaction outs in the middle. rawtx[100] is where the
|
# and then insert the 128 generated transaction outs in the middle. rawtx[100] is where the
|
||||||
# number of txouts is stored and is the only thing we overwrite from the original transaction
|
# number of txouts is stored and is the only thing we overwrite from the original transaction
|
||||||
rawtx = node.createrawtransaction(inputs, outputs)
|
rawtx = node.createrawtransaction(inputs, outputs)
|
||||||
newtx = rawtx[0:100]
|
newtx = rawtx[0:100]
|
||||||
|
@ -222,7 +222,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
assert_equal(test_nodes[0].block_receive_map[big_old_block], i+1)
|
assert_equal(test_nodes[0].block_receive_map[big_old_block], i+1)
|
||||||
|
|
||||||
assert_equal(len(self.nodes[0].getpeerinfo()), 3)
|
assert_equal(len(self.nodes[0].getpeerinfo()), 3)
|
||||||
# At most a couple more tries should succeed (depending on how long
|
# At most a couple more tries should succeed (depending on how long
|
||||||
# the test has been running so far).
|
# the test has been running so far).
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
test_nodes[0].send_message(getdata_request)
|
test_nodes[0].send_message(getdata_request)
|
||||||
|
|
|
@ -8,7 +8,7 @@ from test_framework.mininode import CBlockHeader, CInv, NodeConn, NodeConnCB, \
|
||||||
mininode_lock
|
mininode_lock
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import assert_equal, \
|
from test_framework.util import assert_equal, \
|
||||||
start_node, p2p_port
|
start_node, p2p_port, ZCASHD_BINARY
|
||||||
from test_framework.blocktools import create_block, create_coinbase
|
from test_framework.blocktools import create_block, create_coinbase
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -114,8 +114,8 @@ class TestNode(NodeConnCB):
|
||||||
class AcceptBlockTest(BitcoinTestFramework):
|
class AcceptBlockTest(BitcoinTestFramework):
|
||||||
def add_options(self, parser):
|
def add_options(self, parser):
|
||||||
parser.add_option("--testbinary", dest="testbinary",
|
parser.add_option("--testbinary", dest="testbinary",
|
||||||
default=os.getenv("BITCOIND", "bitcoind"),
|
default=os.getenv("ZCASHD", ZCASHD_BINARY),
|
||||||
help="bitcoind binary to test")
|
help="zcashd binary to test")
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
|
@ -15,6 +15,7 @@ import traceback
|
||||||
|
|
||||||
from .authproxy import JSONRPCException
|
from .authproxy import JSONRPCException
|
||||||
from .util import (
|
from .util import (
|
||||||
|
ZCASHD_BINARY,
|
||||||
initialize_chain,
|
initialize_chain,
|
||||||
start_nodes,
|
start_nodes,
|
||||||
connect_nodes_bi,
|
connect_nodes_bi,
|
||||||
|
@ -194,11 +195,11 @@ class ComparisonTestFramework(BitcoinTestFramework):
|
||||||
|
|
||||||
def add_options(self, parser):
|
def add_options(self, parser):
|
||||||
parser.add_option("--testbinary", dest="testbinary",
|
parser.add_option("--testbinary", dest="testbinary",
|
||||||
default=os.getenv("BITCOIND", "bitcoind"),
|
default=os.getenv("ZCASHD", ZCASHD_BINARY),
|
||||||
help="bitcoind binary to test")
|
help="zcashd binary to test")
|
||||||
parser.add_option("--refbinary", dest="refbinary",
|
parser.add_option("--refbinary", dest="refbinary",
|
||||||
default=os.getenv("BITCOIND", "bitcoind"),
|
default=os.getenv("ZCASHD", ZCASHD_BINARY),
|
||||||
help="bitcoind binary to use for reference nodes (if any)")
|
help="zcashd binary to use for reference nodes (if any)")
|
||||||
|
|
||||||
def setup_network(self):
|
def setup_network(self):
|
||||||
self.nodes = start_nodes(
|
self.nodes = start_nodes(
|
||||||
|
|
|
@ -27,6 +27,8 @@ import errno
|
||||||
from . import coverage
|
from . import coverage
|
||||||
from .authproxy import AuthServiceProxy, JSONRPCException
|
from .authproxy import AuthServiceProxy, JSONRPCException
|
||||||
|
|
||||||
|
ZCASHD_BINARY = os.path.join('src', 'zcashd')
|
||||||
|
|
||||||
DEFAULT_FEE = Decimal('0.00001')
|
DEFAULT_FEE = Decimal('0.00001')
|
||||||
DEFAULT_FEE_ZATS = 1000
|
DEFAULT_FEE_ZATS = 1000
|
||||||
|
|
||||||
|
@ -261,7 +263,7 @@ def initialize_chain(test_dir, num_nodes, cachedir):
|
||||||
# Create cache directories, run bitcoinds:
|
# Create cache directories, run bitcoinds:
|
||||||
for i in range(MAX_NODES):
|
for i in range(MAX_NODES):
|
||||||
datadir=initialize_datadir(cachedir, i)
|
datadir=initialize_datadir(cachedir, i)
|
||||||
args = [ os.getenv("BITCOIND", "bitcoind"), "-keypool=1", "-datadir="+datadir, "-discover=0" ]
|
args = [ os.getenv("ZCASHD", ZCASHD_BINARY), "-keypool=1", "-datadir="+datadir, "-discover=0" ]
|
||||||
args.extend([
|
args.extend([
|
||||||
'-nuparams=5ba81b19:1', # Overwinter
|
'-nuparams=5ba81b19:1', # Overwinter
|
||||||
'-nuparams=76b809bb:1', # Sapling
|
'-nuparams=76b809bb:1', # Sapling
|
||||||
|
@ -353,7 +355,7 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
|
||||||
"""
|
"""
|
||||||
datadir = os.path.join(dirname, "node"+str(i))
|
datadir = os.path.join(dirname, "node"+str(i))
|
||||||
if binary is None:
|
if binary is None:
|
||||||
binary = os.getenv("BITCOIND", "bitcoind")
|
binary = os.getenv("ZCASHD", ZCASHD_BINARY)
|
||||||
args = [ binary, "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ]
|
args = [ binary, "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ]
|
||||||
args.extend([
|
args.extend([
|
||||||
'-nuparams=5ba81b19:1', # Overwinter
|
'-nuparams=5ba81b19:1', # Overwinter
|
||||||
|
@ -562,13 +564,13 @@ def random_transaction(nodes, amount, min_fee, fee_increment, fee_variants):
|
||||||
def assert_equal(expected, actual, message=""):
|
def assert_equal(expected, actual, message=""):
|
||||||
if expected != actual:
|
if expected != actual:
|
||||||
if message:
|
if message:
|
||||||
message = "; %s" % message
|
message = "; %s" % message
|
||||||
raise AssertionError("(left == right)%s\n left: <%s>\n right: <%s>" % (message, str(expected), str(actual)))
|
raise AssertionError("(left == right)%s\n left: <%s>\n right: <%s>" % (message, str(expected), str(actual)))
|
||||||
|
|
||||||
def assert_true(condition, message = ""):
|
def assert_true(condition, message = ""):
|
||||||
if not condition:
|
if not condition:
|
||||||
raise AssertionError(message)
|
raise AssertionError(message)
|
||||||
|
|
||||||
def assert_false(condition, message = ""):
|
def assert_false(condition, message = ""):
|
||||||
assert_true(not condition, message)
|
assert_true(not condition, message)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue