From 2a7039f13d1fe7ac748761c871e357e570ebdfc3 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Fri, 22 Mar 2019 17:40:51 +0000 Subject: [PATCH] Add Travis fedpeg test with downloaded bitcoind --- .travis.yml | 13 +++++++++++++ .travis/test_06_script.sh | 10 ++++++++++ src/chainparams.cpp | 2 +- test/functional/feature_fedpeg.py | 14 +++++++++++--- test/functional/test_framework/test_framework.py | 6 ++++-- test/functional/test_framework/test_node.py | 5 +++-- 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1a3a243316..ab7536c410 100644 --- a/.travis.yml +++ b/.travis.yml @@ -159,3 +159,16 @@ jobs: RUN_FUNCTIONAL_TESTS=false GOAL="install" BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --enable-glibc-back-compat --enable-reduce-exports --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER" + +# x86_64 Linux w/ single fedpeg test that uses upstream bitcoind as mainchain + - stage: test + env: >- + HOST=x86_64-unknown-linux-gnu + PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev" + NO_DEPENDS=1 + RUN_UNIT_TESTS=false + RUN_BITCOIN_TESTS=false + RUN_FUNCTIONAL_TESTS=false + RUN_FEDPEG_BITCOIND_TEST=true + GOAL="install" + BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --enable-glibc-back-compat --enable-reduce-exports --with-gui=no --disable-tests --disable-bench CPPFLAGS=-DDEBUG_LOCKORDER" diff --git a/.travis/test_06_script.sh b/.travis/test_06_script.sh index eeb728e092..a7d729ac55 100755 --- a/.travis/test_06_script.sh +++ b/.travis/test_06_script.sh @@ -71,3 +71,13 @@ if [ "$RUN_BITCOIN_TESTS" = "true" ]; then DOCKER_EXEC test/bitcoin_functional/functional/test_runner.py --combinedlogslen=4000 --coverage --quiet --failfast ${extended} END_FOLD fi + +if [ "$RUN_FEDPEG_BITCOIND_TEST" = "true" ]; then + BEGIN_FOLD fedpeg-bitcoind-test + BITCOIND_VERSION=0.17.1 + BITCOIND_ARCH=x86_64-linux-gnu + DOCKER_EXEC curl -O https://bitcoincore.org/bin/bitcoin-core-$BITCOIND_VERSION/bitcoin-$BITCOIND_VERSION-$BITCOIND_ARCH.tar.gz + DOCKER_EXEC tar -zxf bitcoin-$BITCOIND_VERSION-$BITCOIND_ARCH.tar.gz + DOCKER_EXEC test/functional/feature_fedpeg.py --parent_bitcoin --parent_binpath $(pwd)/bitcoin-$BITCOIND_VERSION/bin/bitcoind + END_FOLD +fi diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6cd7b36320..ddb8562bfb 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -562,7 +562,7 @@ class CCustomParams : public CRegTestParams { base58Prefixes[PARENT_PUBKEY_ADDRESS] = std::vector(1, args.GetArg("-parentpubkeyprefix", 111)); base58Prefixes[PARENT_SCRIPT_ADDRESS] = std::vector(1, args.GetArg("-parentscriptprefix", 196)); parent_bech32_hrp = args.GetArg("-parent_bech32_hrp", "bcrt"); - parent_blech32_hrp = args.GetArg("-parent_bech32_hrp", "bcrt"); + parent_blech32_hrp = args.GetArg("-parent_blech32_hrp", "bcrt"); base58Prefixes[BLINDED_ADDRESS] = std::vector(1, args.GetArg("-blindedprefix", 4)); diff --git a/test/functional/feature_fedpeg.py b/test/functional/feature_fedpeg.py index e8ea452c3a..d29e9a2210 100755 --- a/test/functional/feature_fedpeg.py +++ b/test/functional/feature_fedpeg.py @@ -38,16 +38,22 @@ def setup_network(self, split=False): self.nodes = [] # Setup parent nodes - parent_chain = "regtest" if self.options.parent_bitcoin else "parent" + parent_chain = "parent" if not self.options.parent_bitcoin else "regtest" parent_binary = [self.options.parent_binpath] if self.options.parent_binpath != "" else None for n in range(2): extra_args = [ - "-printtoconsole=0", "-port="+str(p2p_port(n)), "-rpcport="+str(rpc_port(n)) ] if self.options.parent_bitcoin: + # bitcoind can't read elements.conf config files extra_args.extend([ + "-regtest=1", + "-printtoconsole=0", + "-server=1", + "-discover=0", + "-keypool=1", + "-listenonion=0", "-addresstype=legacy", # To make sure bitcoind gives back p2pkh no matter version ]) else: @@ -58,7 +64,7 @@ def setup_network(self, split=False): "-signblockscript=51", # OP_TRUE ]) - self.add_nodes(1, [extra_args], chain=[parent_chain], binary=parent_binary) + self.add_nodes(1, [extra_args], chain=[parent_chain], binary=parent_binary, chain_in_args=[not self.options.parent_bitcoin]) self.start_node(n) print("Node {} started".format(n)) @@ -86,6 +92,8 @@ def setup_network(self, split=False): '-mainchainrpchost=127.0.0.1', '-mainchainrpcport=%s' % rpc_port(n), '-recheckpeginblockinterval=15', # Long enough to allow failure and repair before timeout + '-parentpubkeyprefix=111', + '-parentscriptprefix=196', ] if not self.options.parent_bitcoin: extra_args.extend([ diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index acd5160930..543179ffc5 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -280,7 +280,7 @@ def run_test(self): # Public helper methods. These can be accessed by the subclass test scripts. - def add_nodes(self, num_nodes, extra_args=None, *, rpchost=None, chain=None, binary=None): + def add_nodes(self, num_nodes, extra_args=None, *, rpchost=None, chain=None, binary=None, chain_in_args=None): """Instantiate TestNode objects""" if self.bind_to_localhost_only: extra_confs = [["bind=127.0.0.1"]] * num_nodes @@ -292,13 +292,15 @@ def add_nodes(self, num_nodes, extra_args=None, *, rpchost=None, chain=None, bin binary = [self.options.bitcoind] * num_nodes if chain is None: chain = [self.chain] * num_nodes + if chain_in_args is None: + chain_in_args = [True] * num_nodes assert_equal(len(extra_confs), num_nodes) assert_equal(len(extra_args), num_nodes) assert_equal(len(binary), num_nodes) assert_equal(len(chain), num_nodes) for i in range(num_nodes): numnode = len(self.nodes) - self.nodes.append(TestNode(numnode, get_datadir_path(self.options.tmpdir, numnode), chain[i], rpchost=rpchost, timewait=self.rpc_timewait, bitcoind=binary[i], bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli)) + self.nodes.append(TestNode(numnode, get_datadir_path(self.options.tmpdir, numnode), chain[i], rpchost=rpchost, timewait=self.rpc_timewait, bitcoind=binary[i], bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli, chain_in_args=chain_in_args[i])) def start_node(self, i, *args, **kwargs): """Start a bitcoind""" diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 5af1f24261..3b6452feaf 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -58,7 +58,7 @@ class TestNode(): To make things easier for the test writer, any unrecognised messages will be dispatched to the RPC connection.""" - def __init__(self, i, datadir, chain, *, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False): + def __init__(self, i, datadir, chain, *, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False, chain_in_args=True): self.index = i self.datadir = datadir self.stdout_dir = os.path.join(self.datadir, "stdout") @@ -77,7 +77,6 @@ def __init__(self, i, datadir, chain, *, rpchost, timewait, bitcoind, bitcoin_cl self.args = [ self.binary, "-datadir=" + self.datadir, - "-chain=" + self.chain, "-logtimemicros", "-debug", "-debugexclude=libevent", @@ -85,6 +84,8 @@ def __init__(self, i, datadir, chain, *, rpchost, timewait, bitcoind, bitcoin_cl "-mocktime=" + str(mocktime), "-uacomment=testnode%d" % i ] + if chain_in_args: + self.args += ["-chain=" + self.chain] self.cli = TestNodeCLI(bitcoin_cli, self.datadir, self.chain) self.use_cli = use_cli