From dcf565982aeaff0fccc19af5ccddd7ca8c22ff81 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Mon, 6 May 2019 22:47:06 -0700 Subject: [PATCH] Litecoin: Fix various tests --- test/functional/feature_block.py | 2 +- test/functional/feature_filelock.py | 6 +-- test/functional/rpc_deriveaddresses.py | 8 ++-- test/functional/test_framework/messages.py | 2 +- .../test_framework/test_framework.py | 6 +-- test/functional/tool_wallet.py | 2 +- test/functional/wallet_basic.py | 6 +-- test/functional/wallet_dump.py | 2 +- test/functional/wallet_importmulti.py | 10 ++--- test/util/data/bitcoin-util-test.json | 38 +++++++++---------- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py index 2df37f122..ed4066b22 100755 --- a/test/functional/feature_block.py +++ b/test/functional/feature_block.py @@ -1323,7 +1323,7 @@ class FullBlockTest(BitcoinTestFramework): tx.rehash() return tx - def next_block(self, number, spend=None, additional_coinbase_value=0, script=CScript([OP_TRUE]), *, version=4): + def next_block(self, number, spend=None, additional_coinbase_value=0, script=CScript([OP_TRUE]), *, version=0x20000000): if self.tip is None: base_block_hash = self.genesis_hash block_time = int(time.time()) + 1 diff --git a/test/functional/feature_filelock.py b/test/functional/feature_filelock.py index 7de9a589b..9dabd6193 100755 --- a/test/functional/feature_filelock.py +++ b/test/functional/feature_filelock.py @@ -2,7 +2,7 @@ # Copyright (c) 2018-2020 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -"""Check that it's not possible to start a second bitcoind instance using the same datadir or wallet.""" +"""Check that it's not possible to start a second litecoind instance using the same datadir or wallet.""" import os from test_framework.test_framework import BitcoinTestFramework @@ -22,14 +22,14 @@ class FilelockTest(BitcoinTestFramework): datadir = os.path.join(self.nodes[0].datadir, self.chain) self.log.info("Using datadir {}".format(datadir)) - self.log.info("Check that we can't start a second bitcoind instance using the same datadir") + self.log.info("Check that we can't start a second litecoind instance using the same datadir") expected_msg = "Error: Cannot obtain a lock on data directory {0}. {1} is probably already running.".format(datadir, self.config['environment']['PACKAGE_NAME']) self.nodes[1].assert_start_raises_init_error(extra_args=['-datadir={}'.format(self.nodes[0].datadir), '-noserver'], expected_msg=expected_msg) if self.is_wallet_compiled(): self.nodes[0].createwallet(self.default_wallet_name) wallet_dir = os.path.join(datadir, 'wallets') - self.log.info("Check that we can't start a second bitcoind instance using the same wallet") + self.log.info("Check that we can't start a second litecoind instance using the same wallet") expected_msg = "Error: Error initializing wallet database environment" self.nodes[1].assert_start_raises_init_error(extra_args=['-walletdir={}'.format(wallet_dir), '-wallet=' + self.default_wallet_name, '-noserver'], expected_msg=expected_msg, match=ErrorMatch.PARTIAL_REGEX) diff --git a/test/functional/rpc_deriveaddresses.py b/test/functional/rpc_deriveaddresses.py index 42d7d59d5..87011f220 100755 --- a/test/functional/rpc_deriveaddresses.py +++ b/test/functional/rpc_deriveaddresses.py @@ -15,19 +15,19 @@ class DeriveaddressesTest(BitcoinTestFramework): assert_raises_rpc_error(-5, "Missing checksum", self.nodes[0].deriveaddresses, "a") descriptor = "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)#t6wfjs64" - address = "bcrt1qjqmxmkpmxt80xz4y3746zgt0q3u3ferr34acd5" + address = "rltc1qjqmxmkpmxt80xz4y3746zgt0q3u3ferr0c8362" assert_equal(self.nodes[0].deriveaddresses(descriptor), [address]) descriptor = descriptor[:-9] assert_raises_rpc_error(-5, "Missing checksum", self.nodes[0].deriveaddresses, descriptor) descriptor_pubkey = "wpkh(tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B/1/1/0)#s9ga3alw" - address = "bcrt1qjqmxmkpmxt80xz4y3746zgt0q3u3ferr34acd5" + address = "rltc1qjqmxmkpmxt80xz4y3746zgt0q3u3ferr0c8362" assert_equal(self.nodes[0].deriveaddresses(descriptor_pubkey), [address]) ranged_descriptor = "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/*)#kft60nuy" - assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, [1, 2]), ["bcrt1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rq4442dy", "bcrt1qpgptk2gvshyl0s9lqshsmx932l9ccsv265tvaq"]) - assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, 2), [address, "bcrt1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rq4442dy", "bcrt1qpgptk2gvshyl0s9lqshsmx932l9ccsv265tvaq"]) + assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, [1, 2]), ["rltc1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rqtc0r66", "rltc1qpgptk2gvshyl0s9lqshsmx932l9ccsv2ye3927"]) + assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, 2), [address, "rltc1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rqtc0r66", "rltc1qpgptk2gvshyl0s9lqshsmx932l9ccsv2ye3927"]) assert_raises_rpc_error(-8, "Range should not be specified for an un-ranged descriptor", self.nodes[0].deriveaddresses, descsum_create("wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)"), [0, 2]) diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index ff7f73bdf..326164baa 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -603,7 +603,7 @@ class CTransaction: class CBlockHeader: __slots__ = ("hash", "hashMerkleRoot", "hashPrevBlock", "nBits", "nNonce", - "nTime", "nVersion", "sha256") + "nTime", "nVersion", "sha256", "scrypt256") def __init__(self, header=None): if header is None: diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 831599913..918d9c423 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -43,7 +43,7 @@ TEST_EXIT_PASSED = 0 TEST_EXIT_FAILED = 1 TEST_EXIT_SKIPPED = 77 -TMPDIR_PREFIX = "bitcoin_func_test_" +TMPDIR_PREFIX = "litecoin_func_test_" class SkipTest(Exception): @@ -210,12 +210,12 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass): fname_bitcoind = os.path.join( config["environment"]["BUILDDIR"], "src", - "bitcoind" + config["environment"]["EXEEXT"], + "litecoind" + config["environment"]["EXEEXT"], ) fname_bitcoincli = os.path.join( config["environment"]["BUILDDIR"], "src", - "bitcoin-cli" + config["environment"]["EXEEXT"], + "litecoin-cli" + config["environment"]["EXEEXT"], ) self.options.bitcoind = os.getenv("BITCOIND", default=fname_bitcoind) self.options.bitcoincli = os.getenv("BITCOINCLI", default=fname_bitcoincli) diff --git a/test/functional/tool_wallet.py b/test/functional/tool_wallet.py index 615b772dc..ddb039500 100755 --- a/test/functional/tool_wallet.py +++ b/test/functional/tool_wallet.py @@ -27,7 +27,7 @@ class ToolWalletTest(BitcoinTestFramework): self.skip_if_no_wallet_tool() def bitcoin_wallet_process(self, *args): - binary = self.config["environment"]["BUILDDIR"] + '/src/bitcoin-wallet' + self.config["environment"]["EXEEXT"] + binary = self.config["environment"]["BUILDDIR"] + '/src/litecoin-wallet' + self.config["environment"]["EXEEXT"] args = ['-datadir={}'.format(self.nodes[0].datadir), '-chain=%s' % self.chain] + list(args) return subprocess.Popen([binary] + args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index 3cbddaf6d..dde5a5e06 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -389,13 +389,13 @@ class WalletTest(BitcoinTestFramework): assert_raises_rpc_error(-3, "Address does not refer to a key", self.nodes[0].dumpprivkey, temp_address) # This will raise an exception for attempting to get the private key of an invalid Bitcoin address - assert_raises_rpc_error(-5, "Invalid Bitcoin address", self.nodes[0].dumpprivkey, "invalid") + assert_raises_rpc_error(-5, "Invalid Litecoin address", self.nodes[0].dumpprivkey, "invalid") # This will raise an exception for attempting to set a label for an invalid Bitcoin address - assert_raises_rpc_error(-5, "Invalid Bitcoin address", self.nodes[0].setlabel, "invalid address", "label") + assert_raises_rpc_error(-5, "Invalid Litecoin address", self.nodes[0].setlabel, "invalid address", "label") # This will raise an exception for importing an invalid address - assert_raises_rpc_error(-5, "Invalid Bitcoin address or script", self.nodes[0].importaddress, "invalid") + assert_raises_rpc_error(-5, "Invalid Litecoin address or script", self.nodes[0].importaddress, "invalid") # This will raise an exception for attempting to import a pubkey that isn't in hex assert_raises_rpc_error(-5, "Pubkey must be a hex string", self.nodes[0].importpubkey, "not hex") diff --git a/test/functional/wallet_dump.py b/test/functional/wallet_dump.py index eb54da99f..9918f2cbd 100755 --- a/test/functional/wallet_dump.py +++ b/test/functional/wallet_dump.py @@ -73,7 +73,7 @@ def read_dump(file_name, addrs, script_addrs, hd_master_addr_old): elif addr.startswith('2'): # P2SH-segwit address found_p2sh_segwit_addr += 1 - elif addr.startswith('bcrt1'): + elif addr.startswith('rltc1'): found_bech32_addr += 1 break elif keytype == "change=1": diff --git a/test/functional/wallet_importmulti.py b/test/functional/wallet_importmulti.py index f7fdd6e90..f8cf00a8e 100755 --- a/test/functional/wallet_importmulti.py +++ b/test/functional/wallet_importmulti.py @@ -839,11 +839,11 @@ class ImportMultiTest(BitcoinTestFramework): assert_equal(wrpc.getwalletinfo()["private_keys_enabled"], False) xpub = "tpubDAXcJ7s7ZwicqjprRaEWdPoHKrCS215qxGYxpusRLLmJuT69ZSicuGdSfyvyKpvUNYBW1s2U3NSrT6vrCYB9e6nZUEvrqnwXPF8ArTCRXMY" addresses = [ - 'bcrt1qtmp74ayg7p24uslctssvjm06q5phz4yrxucgnv', # m/0'/0'/0 - 'bcrt1q8vprchan07gzagd5e6v9wd7azyucksq2xc76k8', # m/0'/0'/1 - 'bcrt1qtuqdtha7zmqgcrr26n2rqxztv5y8rafjp9lulu', # m/0'/0'/2 - 'bcrt1qau64272ymawq26t90md6an0ps99qkrse58m640', # m/0'/0'/3 - 'bcrt1qsg97266hrh6cpmutqen8s4s962aryy77jp0fg0', # m/0'/0'/4 + 'rltc1qtmp74ayg7p24uslctssvjm06q5phz4yrc3zpyj', # m/0'/0'/0 + 'rltc1q8vprchan07gzagd5e6v9wd7azyucksq2c4ynpe', # m/0'/0'/1 + 'rltc1qtuqdtha7zmqgcrr26n2rqxztv5y8rafjlg94gz', # m/0'/0'/2 + 'rltc1qau64272ymawq26t90md6an0ps99qkrse22pnz3', # m/0'/0'/3 + 'rltc1qsg97266hrh6cpmutqen8s4s962aryy77vv4ql3', # m/0'/0'/4 ] result = wrpc.importmulti( [{ diff --git a/test/util/data/bitcoin-util-test.json b/test/util/data/bitcoin-util-test.json index 5807f04d2..657fa25b3 100644 --- a/test/util/data/bitcoin-util-test.json +++ b/test/util/data/bitcoin-util-test.json @@ -110,7 +110,7 @@ "error_txt": "error: invalid TX input txid", "description": "Tests the check for an invalid txid invalid hex" }, - { "exec": "./bitcoin-tx", + { "exec": "./litecoin-tx", "args": ["-create", "in=5897de6bd6:0"], @@ -118,7 +118,7 @@ "error_txt": "error: invalid TX input txid", "description": "Tests the check for an invalid txid valid hex but too short" }, - { "exec": "./bitcoin-tx", + { "exec": "./litecoin-tx", "args": ["-create", "in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f12:0"], @@ -126,7 +126,7 @@ "error_txt": "error: invalid TX input txid", "description": "Tests the check for an invalid txid valid hex but too long" }, - { "exec": "./bitcoin-tx", + { "exec": "./litecoin-tx", "args": ["-create", "in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0", @@ -347,40 +347,40 @@ { "exec": "./bitcoin-tx", "args": ["-create", - "in=4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485:0", - "set=privatekeys:[\"5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf\"]", + "in=6c2789243608b46f750f49ff24f6f79a78c3010f7e56951e045e5b7ea5d07bf7:0", + "set=privatekeys:[\"T3Eyvg7Me8fuajt2RJvQaRokRabBweiyBWVJiQG8P1bwDUEXPhqv\"]", "set=prevtxs:[{\"txid\":\"Zd49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59412\",\"vout\":0,\"scriptPubKey\":\"76a91491b24bf9f5288532960ac687abb035127b1d28a588ac\"}]", "sign=ALL", - "outaddr=0.001:193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7"], + "outaddr=0.001:LXC44cQhuRufFtaDhDYv4q8nxQJBkUAsXp"], "return_code": 1, "error_txt": "error: txid must be hexadecimal string (not 'Zd49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59412')", "description": "Tests the check for invalid txid due to invalid hex" }, - { "exec": "./bitcoin-tx", + { "exec": "./litecoin-tx", "args": ["-create", - "in=4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485:0", - "set=privatekeys:[\"5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf\"]", - "set=prevtxs:[{\"txid\":\"4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc594\",\"vout\":0,\"scriptPubKey\":\"76a91491b24bf9f5288532960ac687abb035127b1d28a588ac\"}]", + "in=6c2789243608b46f750f49ff24f6f79a78c3010f7e56951e045e5b7ea5d07bf7:0", + "set=privatekeys:[\"T3Eyvg7Me8fuajt2RJvQaRokRabBweiyBWVJiQG8P1bwDUEXPhqv\"]", + "set=prevtxs:[{\"txid\":\"6c2789243608b46f750f49ff24f6f79a78c3010f7e56951e045e5b7ea5d07b\",\"vout\":0,\"scriptPubKey\":\"76a91491b24bf9f5288532960ac687abb035127b1d28a588ac\"}]", "sign=ALL", - "outaddr=0.001:193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7"], + "outaddr=0.001:LXC44cQhuRufFtaDhDYv4q8nxQJBkUAsXp"], "return_code": 1, - "error_txt": "error: txid must be hexadecimal string (not '4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc594')", + "error_txt": "error: txid must be hexadecimal string (not '6c2789243608b46f750f49ff24f6f79a78c3010f7e56951e045e5b7ea5d07b')", "description": "Tests the check for invalid txid valid hex, but too short" }, - { "exec": "./bitcoin-tx", + { "exec": "./litecoin-tx", "args": ["-create", - "in=4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485:0", - "set=privatekeys:[\"5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf\"]", - "set=prevtxs:[{\"txid\":\"4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc5948512\",\"vout\":0,\"scriptPubKey\":\"76a91491b24bf9f5288532960ac687abb035127b1d28a588ac\"}]", + "in=6c2789243608b46f750f49ff24f6f79a78c3010f7e56951e045e5b7ea5d07bf7:0", + "set=privatekeys:[\"T3Eyvg7Me8fuajt2RJvQaRokRabBweiyBWVJiQG8P1bwDUEXPhqv\"]", + "set=prevtxs:[{\"txid\":\"6c2789243608b46f750f49ff24f6f79a78c3010f7e56951e045e5b7ea5d07bf712\",\"vout\":0,\"scriptPubKey\":\"76a91491b24bf9f5288532960ac687abb035127b1d28a588ac\"}]", "sign=ALL", - "outaddr=0.001:193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7"], + "outaddr=0.001:LXC44cQhuRufFtaDhDYv4q8nxQJBkUAsXp"], "return_code": 1, - "error_txt": "error: txid must be hexadecimal string (not '4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc5948512')", + "error_txt": "error: txid must be hexadecimal string (not '6c2789243608b46f750f49ff24f6f79a78c3010f7e56951e045e5b7ea5d07bf712')", "description": "Tests the check for invalid txid valid hex, but too long" }, - { "exec": "./bitcoin-tx", + { "exec": "./litecoin-tx", "args": ["-create", "outpubkey=0:02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397", "nversion=1"], "output_cmp": "txcreateoutpubkey1.hex",