From d4a9d24930c40fb42755cf1b5dfc0de7c4a94696 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Thu, 18 Jan 2018 15:29:46 -0800 Subject: [PATCH] Litecoin: Fix tests --- src/qt/test/rpcnestedtests.cpp | 8 ------- src/test/test_bitcoin_main.cpp | 2 +- test/functional/signmessages.py | 2 +- test/functional/test_framework/test_node.py | 26 ++++++++++----------- test/functional/test_script_address2.py | 8 +++---- test/util/data/bitcoin-util-test.json | 6 ++--- test/util/data/txcreatemultisig5.json | 2 +- 7 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/qt/test/rpcnestedtests.cpp b/src/qt/test/rpcnestedtests.cpp index f24ad50ce..23904a47e 100644 --- a/src/qt/test/rpcnestedtests.cpp +++ b/src/qt/test/rpcnestedtests.cpp @@ -36,14 +36,6 @@ void RPCNestedTests::rpcNestedTests() // do some test setup // could be moved to a more generic place when we add more tests on QT level tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]); -<<<<<<< c4466c1eb3215d3faa1f1fe4d4d122114c1e143a -======= - ClearDatadirCache(); - std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_litecoin_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000))); - QDir dir(QString::fromStdString(path)); - dir.mkpath("."); - gArgs.ForceSetArg("-datadir", path); ->>>>>>> Litecoin: Fix various tests //mempool.setSanityCheck(1.0); TestingSetup test; diff --git a/src/test/test_bitcoin_main.cpp b/src/test/test_bitcoin_main.cpp index 34beef553..a2c73bbe9 100644 --- a/src/test/test_bitcoin_main.cpp +++ b/src/test/test_bitcoin_main.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#define BOOST_TEST_MODULE Bitcoin Test Suite +#define BOOST_TEST_MODULE Litecoin Test Suite #include "net.h" diff --git a/test/functional/signmessages.py b/test/functional/signmessages.py index 52ba6a5ad..8dff0061f 100755 --- a/test/functional/signmessages.py +++ b/test/functional/signmessages.py @@ -18,7 +18,7 @@ class SignMessagesTest(BitcoinTestFramework): self.log.info('test signing with priv_key') priv_key = 'cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N' address = 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB' - expected_signature = 'INbVnW4e6PeRmsv2Qgu8NuopvrVjkcxob+sX8OcZG0SALhWybUjzMLPdAsXI46YZGb0KQTRii+wWIQzRpG/U+S0=' + expected_signature = 'IGve8AOjIcu+a/nYW1PABSfmp2oQlEqLIOwPgNW5/Y5teggr8S0vy4SMdjL2Viv3iuBZjJbhvyBo0tv5m3H63b8=' signature = self.nodes[0].signmessagewithprivkey(priv_key, message) assert_equal(expected_signature, signature) assert(self.nodes[0].verifymessage(address, signature, message)) diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 12dab57a0..2f9a201b8 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -2,7 +2,7 @@ # Copyright (c) 2017 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -"""Class for bitcoind node under test""" +"""Class for litecoind node under test""" import decimal import errno @@ -24,7 +24,7 @@ from .authproxy import JSONRPCException BITCOIND_PROC_WAIT_TIMEOUT = 60 class TestNode(): - """A class for representing a bitcoind node under test. + """A class for representing a litecoind node under test. This class contains: @@ -45,7 +45,7 @@ class TestNode(): # Wait for up to 60 seconds for the RPC server to respond self.rpc_timeout = 60 if binary is None: - self.binary = os.getenv("BITCOIND", "bitcoind") + self.binary = os.getenv("LITECOIND", "litecoind") else: self.binary = binary self.stderr = stderr @@ -54,7 +54,7 @@ class TestNode(): self.extra_args = extra_args self.args = [self.binary, "-datadir=" + self.datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-logtimemicros", "-debug", "-debugexclude=libevent", "-debugexclude=leveldb", "-mocktime=" + str(mocktime), "-uacomment=testnode%d" % i] - self.cli = TestNodeCLI(os.getenv("BITCOINCLI", "bitcoin-cli"), self.datadir) + self.cli = TestNodeCLI(os.getenv("LITECOINCLI", "litecoin-cli"), self.datadir) self.running = False self.process = None @@ -76,14 +76,14 @@ class TestNode(): stderr = self.stderr self.process = subprocess.Popen(self.args + extra_args, stderr=stderr) self.running = True - self.log.debug("bitcoind started, waiting for RPC to come up") + self.log.debug("litecoind started, waiting for RPC to come up") def wait_for_rpc_connection(self): - """Sets up an RPC connection to the bitcoind process. Returns False if unable to connect.""" + """Sets up an RPC connection to the litecoind process. Returns False if unable to connect.""" # Poll at a rate of four times per second poll_per_s = 4 for _ in range(poll_per_s * self.rpc_timeout): - assert self.process.poll() is None, "bitcoind exited with status %i during initialization" % self.process.returncode + assert self.process.poll() is None, "litecoind exited with status %i during initialization" % self.process.returncode try: self.rpc = get_rpc_proxy(rpc_url(self.datadir, self.index, self.rpchost), self.index, timeout=self.rpc_timeout, coveragedir=self.coverage_dir) self.rpc.getblockcount() @@ -102,7 +102,7 @@ class TestNode(): if "No RPC credentials" not in str(e): raise time.sleep(1.0 / poll_per_s) - raise AssertionError("Unable to connect to bitcoind") + raise AssertionError("Unable to connect to litecoind") def get_wallet_rpc(self, wallet_name): assert self.rpc_connected @@ -146,13 +146,13 @@ class TestNode(): def node_encrypt_wallet(self, passphrase): """"Encrypts the wallet. - This causes bitcoind to shutdown, so this method takes + This causes litecoind to shutdown, so this method takes care of cleaning up resources.""" self.encryptwallet(passphrase) self.wait_until_stopped() class TestNodeCLI(): - """Interface to bitcoin-cli for an individual node""" + """Interface to litecoin-cli for an individual node""" def __init__(self, binary, datadir): self.args = [] @@ -161,7 +161,7 @@ class TestNodeCLI(): self.input = None def __call__(self, *args, input=None): - # TestNodeCLI is callable with bitcoin-cli command-line args + # TestNodeCLI is callable with litecoin-cli command-line args self.args = [str(arg) for arg in args] self.input = input return self @@ -172,11 +172,11 @@ class TestNodeCLI(): return dispatcher def send_cli(self, command, *args, **kwargs): - """Run bitcoin-cli command. Deserializes returned string as python object.""" + """Run litecoin-cli command. Deserializes returned string as python object.""" pos_args = [str(arg) for arg in args] named_args = [str(key) + "=" + str(value) for (key, value) in kwargs.items()] - assert not (pos_args and named_args), "Cannot use positional arguments and named arguments in the same bitcoin-cli call" + assert not (pos_args and named_args), "Cannot use positional arguments and named arguments in the same litecoin-cli call" p_args = [self.binary, "-datadir=" + self.datadir] + self.args if named_args: p_args += ["-named"] diff --git a/test/functional/test_script_address2.py b/test/functional/test_script_address2.py index 57f63ed67..015c515bc 100755 --- a/test/functional/test_script_address2.py +++ b/test/functional/test_script_address2.py @@ -12,16 +12,14 @@ from test_framework.util import * import decimal class ScriptAddress2Test(BitcoinTestFramework): - def __init__(self): - super().__init__() + def set_test_params(self): self.num_nodes = 3 self.setup_clean_chain = False - def setup_network(self): - self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir) + def setup_network(self, split=False): + self.setup_nodes() connect_nodes(self.nodes[1], 0) connect_nodes(self.nodes[2], 0) - self.is_network_split = False self.sync_all() def run_test(self): diff --git a/test/util/data/bitcoin-util-test.json b/test/util/data/bitcoin-util-test.json index daf3d2437..fbdac92f7 100644 --- a/test/util/data/bitcoin-util-test.json +++ b/test/util/data/bitcoin-util-test.json @@ -268,7 +268,7 @@ "error_txt": "error: Uncompressed pubkeys are not useable for SegWit outputs", "description": "Creates a new transaction with a single pay-to-pub-key output, wrapped in P2SH (output as json)" }, - { "exec": "./bitcoin-tx", + { "exec": "./litecoin-tx", "args": ["-create", "in=69e9c12d30a6cd598a31ddfcaabeb9d9f0baf8938bf0ba6610beb04f589cc5ef:0", @@ -396,12 +396,12 @@ "output_cmp": "txcreatemultisig4.json", "description": "Creates a new transaction with a single 2-of-3 multisig in a P2WSH output, wrapped in P2SH (output in json)" }, - { "exec": "./bitcoin-tx", + { "exec": "./litecoin-tx", "args": ["-json", "-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:047d1368ba7ae01c94bc32293efd70bd7e3be7aa7912d07d0b1c659c1008d179b8642f5fb90f47580feb29f045e216ff5a4716d3a0fed36da414d332046303c44a:S"], "output_cmp": "txcreatemultisig5.json", "description": "Uncompressed pubkeys should work just fine for non-witness outputs" }, - { "exec": "./bitcoin-tx", + { "exec": "./litecoin-tx", "args": ["-json", "-create", "outmultisig=1:2:3:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397:021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d:047d1368ba7ae01c94bc32293efd70bd7e3be7aa7912d07d0b1c659c1008d179b8642f5fb90f47580feb29f045e216ff5a4716d3a0fed36da414d332046303c44a:WS"], "return_code": 1, "error_txt": "error: Uncompressed pubkeys are not useable for SegWit outputs", diff --git a/test/util/data/txcreatemultisig5.json b/test/util/data/txcreatemultisig5.json index 20e9bb077..dd6a0ba28 100644 --- a/test/util/data/txcreatemultisig5.json +++ b/test/util/data/txcreatemultisig5.json @@ -17,7 +17,7 @@ "reqSigs": 1, "type": "scripthash", "addresses": [ - "3GeGs1eHUxPz5YyuFe9WPpXid2UsUb5Jos" + "MNrRAu4FS5FQt4FoMX8rDTn7wj5KUunnGr" ] } }