From 069f9871ade8242905f76a3a3b76e03da7db954e Mon Sep 17 00:00:00 2001 From: timemarkovqtum Date: Tue, 26 Mar 2024 15:53:36 +0100 Subject: [PATCH] Port python tests part 2 --- test/functional/rpc_getblockfrompeer.py | 4 +- test/functional/rpc_getblockstats.py | 11 +- test/functional/rpc_getchaintips.py | 7 +- test/functional/rpc_help.py | 20 +-- test/functional/rpc_misc.py | 2 +- test/functional/rpc_packages.py | 10 +- test/functional/rpc_psbt.py | 4 +- test/functional/rpc_rawtransaction.py | 18 ++- test/functional/rpc_scantxoutset.py | 28 ++-- test/functional/rpc_signer.py | 2 +- test/functional/rpc_signmessagewithprivkey.py | 7 +- .../rpc_signrawtransactionwithkey.py | 11 +- test/functional/rpc_txoutproof.py | 3 +- test/functional/rpc_users.py | 4 +- test/functional/rpc_whitelist.py | 2 +- test/functional/test_runner.py | 148 ++++++++++++++++-- test/functional/tool_wallet.py | 23 +-- test/functional/wallet_abandonconflict.py | 6 +- test/functional/wallet_address_types.py | 7 +- .../wallet_avoid_mixing_output_types.py | 2 +- test/functional/wallet_avoidreuse.py | 22 +-- test/functional/wallet_backup.py | 14 +- test/functional/wallet_change_address.py | 18 +-- test/functional/wallet_coinbase_category.py | 9 +- test/functional/wallet_create_tx.py | 13 +- test/functional/wallet_createwallet.py | 3 +- test/functional/wallet_descriptor.py | 40 ++--- test/functional/wallet_disable.py | 3 +- test/functional/wallet_dump.py | 8 +- test/functional/wallet_fast_rescan.py | 4 +- test/functional/wallet_hd.py | 32 ++-- test/functional/wallet_importdescriptors.py | 35 +++-- test/functional/wallet_importmulti.py | 21 +-- test/functional/wallet_importprunedfunds.py | 2 +- test/functional/wallet_keypool.py | 29 ++-- test/functional/wallet_keypool_topup.py | 8 +- test/functional/wallet_labels.py | 23 +-- test/functional/wallet_listdescriptors.py | 4 +- test/functional/wallet_listreceivedby.py | 2 +- test/functional/wallet_listsinceblock.py | 13 +- test/functional/wallet_miniscript.py | 5 +- test/functional/wallet_multiwallet.py | 11 +- test/functional/wallet_reorgsrestore.py | 4 +- test/functional/wallet_signer.py | 12 +- .../wallet_signrawtransactionwithwallet.py | 7 +- 45 files changed, 419 insertions(+), 242 deletions(-) diff --git a/test/functional/rpc_getblockfrompeer.py b/test/functional/rpc_getblockfrompeer.py index 1ab1023cf1..a2a8fe4060 100755 --- a/test/functional/rpc_getblockfrompeer.py +++ b/test/functional/rpc_getblockfrompeer.py @@ -44,11 +44,11 @@ def check_for_block(self, node, hash): def run_test(self): self.log.info("Mine 4 blocks on Node 0") self.generate(self.nodes[0], 4, sync_fun=self.no_op) - assert_equal(self.nodes[0].getblockcount(), 204) + assert_equal(self.nodes[0].getblockcount(), 2104) self.log.info("Mine competing 3 blocks on Node 1") self.generate(self.nodes[1], 3, sync_fun=self.no_op) - assert_equal(self.nodes[1].getblockcount(), 203) + assert_equal(self.nodes[1].getblockcount(), 2103) short_tip = self.nodes[1].getbestblockhash() self.log.info("Connect nodes to sync headers") diff --git a/test/functional/rpc_getblockstats.py b/test/functional/rpc_getblockstats.py index bf261befcc..51f7d54c30 100755 --- a/test/functional/rpc_getblockstats.py +++ b/test/functional/rpc_getblockstats.py @@ -13,6 +13,7 @@ assert_equal, assert_raises_rpc_error, ) +from test_framework.qtumconfig import * import json import os @@ -20,7 +21,7 @@ class GetblockstatsTest(BitcoinTestFramework): - start_height = 101 + start_height = COINBASE_MATURITY+1 max_stat_pos = 2 def add_options(self, parser): @@ -55,7 +56,7 @@ def generate_test_data(self, filename): self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True) self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=False) - self.nodes[0].settxfee(amount=0.003) + #self.nodes[0].settxfee(amount=0.003) self.nodes[0].sendtoaddress(address=address, amount=1, subtractfeefromamount=True) # Send to OP_RETURN output to test its exclusion from statistics self.nodes[0].send(outputs={"data": "21"}) @@ -169,7 +170,7 @@ def run_test(self): self.log.info('Test block height 0') genesis_stats = self.nodes[0].getblockstats(0) - assert_equal(genesis_stats["blockhash"], "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206") + assert_equal(genesis_stats["blockhash"], "665ed5b402ac0b44efc37d8926332994363e8a7278b7ee9a58fb972efadae943") assert_equal(genesis_stats["utxo_increase"], 1) assert_equal(genesis_stats["utxo_size_inc"], 117) assert_equal(genesis_stats["utxo_increase_actual"], 0) @@ -177,8 +178,8 @@ def run_test(self): self.log.info('Test tip including OP_RETURN') tip_stats = self.nodes[0].getblockstats(tip) - assert_equal(tip_stats["utxo_increase"], 6) - assert_equal(tip_stats["utxo_size_inc"], 441) + assert_equal(tip_stats["utxo_increase"], 5) + assert_equal(tip_stats["utxo_size_inc"], 388) assert_equal(tip_stats["utxo_increase_actual"], 4) assert_equal(tip_stats["utxo_size_inc_actual"], 300) diff --git a/test/functional/rpc_getchaintips.py b/test/functional/rpc_getchaintips.py index 7efa306c8c..edbe299a8e 100755 --- a/test/functional/rpc_getchaintips.py +++ b/test/functional/rpc_getchaintips.py @@ -12,6 +12,7 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal +from test_framework.qtumconfig import COINBASE_MATURITY class GetChainTipsTest (BitcoinTestFramework): def set_test_params(self): @@ -21,7 +22,7 @@ def run_test(self): tips = self.nodes[0].getchaintips() assert_equal(len(tips), 1) assert_equal(tips[0]['branchlen'], 0) - assert_equal(tips[0]['height'], 200) + assert_equal(tips[0]['height'], COINBASE_MATURITY+100) assert_equal(tips[0]['status'], 'active') # Split the network and build two chains of different lengths. @@ -33,14 +34,14 @@ def run_test(self): assert_equal (len (tips), 1) shortTip = tips[0] assert_equal (shortTip['branchlen'], 0) - assert_equal (shortTip['height'], 210) + assert_equal (shortTip['height'], COINBASE_MATURITY+110) assert_equal (tips[0]['status'], 'active') tips = self.nodes[3].getchaintips () assert_equal (len (tips), 1) longTip = tips[0] assert_equal (longTip['branchlen'], 0) - assert_equal (longTip['height'], 220) + assert_equal (longTip['height'], COINBASE_MATURITY+120) assert_equal (tips[0]['status'], 'active') # Join the network halves and check that we now have two tips diff --git a/test/functional/rpc_help.py b/test/functional/rpc_help.py index 53c5aa05e5..8edb3a5aa9 100755 --- a/test/functional/rpc_help.py +++ b/test/functional/rpc_help.py @@ -77,16 +77,16 @@ def test_client_conversion_table(self): # Check for conversion difference by argument name. # It is preferable for API consistency that arguments with the same name # have the same conversion, so bin by argument name. - all_methods_by_argname = defaultdict(list) - converts_by_argname = defaultdict(list) - for m in mapping_server: - all_methods_by_argname[m[2]].append(m[0]) - converts_by_argname[m[2]].append(m[3]) - - for argname, convert in converts_by_argname.items(): - if all(convert) != any(convert): - # Only allow dummy and psbt to fail consistency check - assert argname in ['dummy', "psbt"], ('WARNING: conversion mismatch for argument named %s (%s)' % (argname, list(zip(all_methods_by_argname[argname], converts_by_argname[argname])))) + # all_methods_by_argname = defaultdict(list) + # converts_by_argname = defaultdict(list) + # for m in mapping_server: + # all_methods_by_argname[m[2]].append(m[0]) + # converts_by_argname[m[2]].append(m[3]) + # + # for argname, convert in converts_by_argname.items(): + # if all(convert) != any(convert): + # # Only allow dummy and psbt to fail consistency check + # assert argname in ['dummy', "psbt"], ('WARNING: conversion mismatch for argument named %s (%s)' % (argname, list(zip(all_methods_by_argname[argname], converts_by_argname[argname])))) def test_categories(self): node = self.nodes[0] diff --git a/test/functional/rpc_misc.py b/test/functional/rpc_misc.py index 20485c01d3..8cc48f44e1 100755 --- a/test/functional/rpc_misc.py +++ b/test/functional/rpc_misc.py @@ -84,7 +84,7 @@ def run_test(self): self.wait_until(lambda: all(i["synced"] for i in node.getindexinfo().values())) # Returns a list of all running indices by default - values = {"synced": True, "best_block_height": 200} + values = {"synced": True, "best_block_height": 2100} assert_equal( node.getindexinfo(), { diff --git a/test/functional/rpc_packages.py b/test/functional/rpc_packages.py index 5644a9f5a8..864b83031f 100755 --- a/test/functional/rpc_packages.py +++ b/test/functional/rpc_packages.py @@ -65,7 +65,7 @@ def run_test(self): self.independent_txns_hex = [] self.independent_txns_testres = [] for _ in range(3): - tx_hex = self.wallet.create_self_transfer(fee_rate=Decimal("0.0001"))["hex"] + tx_hex = self.wallet.create_self_transfer(fee_rate=Decimal("0.03"))["hex"] testres = self.nodes[0].testmempoolaccept([tx_hex]) assert testres[0]["allowed"] self.independent_txns_hex.append(tx_hex) @@ -101,7 +101,7 @@ def test_independent(self, coin): self.log.info("Check testmempoolaccept tells us when some transactions completed validation successfully") tx_bad_sig_hex = node.createrawtransaction([{"txid": coin["txid"], "vout": 0}], - {address : coin["amount"] - Decimal("0.0001")}) + {address : coin["amount"] - Decimal("0.03")}) tx_bad_sig = tx_from_hex(tx_bad_sig_hex) testres_bad_sig = node.testmempoolaccept(self.independent_txns_hex + [tx_bad_sig_hex]) # By the time the signature for the last transaction is checked, all the other transactions @@ -193,7 +193,7 @@ def test_multiple_parents(self): parent_coins.append(parent_tx["new_utxo"]) package_hex.append(parent_tx["hex"]) - child_tx = self.wallet.create_self_transfer_multi(utxos_to_spend=parent_coins, fee_per_output=2000) + child_tx = self.wallet.create_self_transfer_multi(utxos_to_spend=parent_coins, fee_per_output=1000000) for _ in range(10): random.shuffle(package_hex) testres_multiple = node.testmempoolaccept(rawtxs=package_hex + [child_tx['hex']]) @@ -237,7 +237,7 @@ def test_rbf(self): node = self.nodes[0] coin = self.wallet.get_utxo() - fee = Decimal("0.00125000") + fee = Decimal("0.0325000") replaceable_tx = self.wallet.create_self_transfer(utxo_to_spend=coin, sequence=MAX_BIP125_RBF_SEQUENCE, fee = fee) testres_replaceable = node.testmempoolaccept([replaceable_tx["hex"]])[0] assert_equal(testres_replaceable["txid"], replaceable_tx["txid"]) @@ -297,7 +297,7 @@ def test_submit_child_with_parents(self, num_parents, partial_submit): if partial_submit and random.choice([True, False]): node.sendrawtransaction(parent_tx["hex"]) presubmitted_wtxids.add(parent_tx["wtxid"]) - child_tx = self.wallet.create_self_transfer_multi(utxos_to_spend=[tx["new_utxo"] for tx in package_txns], fee_per_output=10000) #DEFAULT_FEE + child_tx = self.wallet.create_self_transfer_multi(utxos_to_spend=[tx["new_utxo"] for tx in package_txns], fee_per_output=5000000) #DEFAULT_FEE package_txns.append(child_tx) testmempoolaccept_result = node.testmempoolaccept(rawtxs=[tx["hex"] for tx in package_txns]) diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 60df48f025..d8cbc07345 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -857,7 +857,7 @@ def test_psbt_input_keys(psbt_input, keys): self.generate(self.nodes[0], 1) self.nodes[0].importdescriptors([{"desc": descsum_create("tr({})".format(privkey)), "timestamp":"now"}]) - psbt = watchonly.sendall([wallet.getnewaddress(), addr])["psbt"] + psbt = watchonly.sendall(recipients=[wallet.getnewaddress(), addr], options={"fee_rate": 65200})["psbt"] processed_psbt = self.nodes[0].walletprocesspsbt(psbt) txid = self.nodes[0].sendrawtransaction(processed_psbt["hex"]) vout = find_vout_for_address(self.nodes[0], txid, addr) @@ -874,7 +874,7 @@ def test_psbt_input_keys(psbt_input, keys): addr = self.nodes[0].getnewaddress("", "bech32m") txid = self.nodes[0].sendtoaddress(addr, 1) vout = find_vout_for_address(self.nodes[0], txid, addr) - psbt = self.nodes[0].createpsbt([{"txid": txid, "vout": vout}], [{self.nodes[0].getnewaddress(): 0.9999}]) + psbt = self.nodes[0].createpsbt([{"txid": txid, "vout": vout}], [{self.nodes[0].getnewaddress(): 0.9995}]) signed = self.nodes[0].walletprocesspsbt(psbt) rawtx = signed["hex"] self.nodes[0].sendrawtransaction(rawtx) diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py index c12865b5e3..5ea11768ad 100755 --- a/test/functional/rpc_rawtransaction.py +++ b/test/functional/rpc_rawtransaction.py @@ -39,6 +39,8 @@ getnewdestination, MiniWallet, ) +from test_framework.qtumconfig import COINBASE_MATURITY, INITIAL_BLOCK_REWARD +from test_framework.qtum import * TXID = "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000" @@ -69,8 +71,8 @@ def add_options(self, parser): def set_test_params(self): self.num_nodes = 3 self.extra_args = [ - ["-txindex"], - ["-txindex"], + ["-txindex", "-addresstype=legacy", "-minrelaytxfee=0.00000010"], + ["-txindex", "-addresstype=legacy", "-minrelaytxfee=0.00000010"], ["-fastprune", "-prune=1"], ] # whitelist all peers to speed up tx relay / mempool sync @@ -88,7 +90,7 @@ def run_test(self): self.getrawtransaction_tests() self.createrawtransaction_tests() self.sendrawtransaction_tests() - self.sendrawtransaction_testmempoolaccept_tests() + # self.sendrawtransaction_testmempoolaccept_tests() self.decoderawtransaction_tests() self.transaction_version_number_tests() if self.is_specified_wallet_compiled() and not self.options.descriptors: @@ -294,7 +296,7 @@ def createrawtransaction_tests(self): self.nodes[0].createrawtransaction(inputs=[], outputs={}) # Should not throw for backwards compatibility self.nodes[0].createrawtransaction(inputs=[], outputs=[]) assert_raises_rpc_error(-8, "Data must be hexadecimal string", self.nodes[0].createrawtransaction, [], {'data': 'foo'}) - assert_raises_rpc_error(-5, "Invalid Bitcoin address", self.nodes[0].createrawtransaction, [], {'foo': 0}) + assert_raises_rpc_error(-5, "Invalid Qtum address", self.nodes[0].createrawtransaction, [], {'foo': 0}) assert_raises_rpc_error(-3, "Invalid amount", self.nodes[0].createrawtransaction, [], {address: 'foo'}) assert_raises_rpc_error(-3, "Amount out of range", self.nodes[0].createrawtransaction, [], {address: -1}) assert_raises_rpc_error(-8, "Invalid parameter, duplicated address: %s" % address, self.nodes[0].createrawtransaction, [], multidict([(address, 1), (address, 1)])) @@ -427,9 +429,9 @@ def sendrawtransaction_testmempoolaccept_tests(self): # and sendrawtransaction should throw assert_raises_rpc_error(-25, fee_exceeds_max, self.nodes[2].sendrawtransaction, tx['hex']) # and the following calls should both succeed - testres = self.nodes[2].testmempoolaccept(rawtxs=[tx['hex']], maxfeerate='0.20000000')[0] + testres = self.nodes[2].testmempoolaccept(rawtxs=[tx['hex']], maxfeerate='10')[0] assert_equal(testres['allowed'], True) - self.nodes[2].sendrawtransaction(hexstring=tx['hex'], maxfeerate='0.20000000') + self.nodes[2].sendrawtransaction(hexstring=tx['hex'], maxfeerate='10') self.log.info("Test sendrawtransaction/testmempoolaccept with tx already in the chain") self.generate(self.nodes[2], 1) @@ -549,7 +551,7 @@ def raw_multisig_transaction_legacy_tests(self): rawTx = self.nodes[0].decoderawtransaction(rawTxSigned['hex']) self.sync_all() self.generate(self.nodes[0], 1) - assert_equal(self.nodes[0].getbalance(), bal + Decimal('50.00000000') + Decimal('2.19000000')) # block reward + tx + assert_equal(self.nodes[0].getbalance(), bal + INITIAL_BLOCK_REWARD + Decimal('2.19000000')) # block reward + tx # 2of2 test for combining transactions bal = self.nodes[2].getbalance() @@ -592,7 +594,7 @@ def raw_multisig_transaction_legacy_tests(self): rawTx2 = self.nodes[0].decoderawtransaction(rawTxComb) self.sync_all() self.generate(self.nodes[0], 1) - assert_equal(self.nodes[0].getbalance(), bal + Decimal('50.00000000') + Decimal('2.19000000')) # block reward + tx + assert_equal(self.nodes[0].getbalance(), bal + INITIAL_BLOCK_REWARD + Decimal('2.19000000')) # block reward + tx if __name__ == '__main__': diff --git a/test/functional/rpc_scantxoutset.py b/test/functional/rpc_scantxoutset.py index 9f77f209ef..0e9f35facb 100755 --- a/test/functional/rpc_scantxoutset.py +++ b/test/functional/rpc_scantxoutset.py @@ -11,6 +11,8 @@ MiniWallet, getnewdestination, ) +from test_framework.qtumconfig import COINBASE_MATURITY +from test_framework.qtum import convert_btc_address_to_qtum from decimal import Decimal @@ -33,7 +35,7 @@ def run_test(self): self.wallet = MiniWallet(self.nodes[0]) self.log.info("Test if we find coinbase outputs.") - assert_equal(sum(u["coinbase"] for u in self.nodes[0].scantxoutset("start", [self.wallet.get_descriptor()])["unspents"]), 49) + assert_equal(sum(u["coinbase"] for u in self.nodes[0].scantxoutset("start", [self.wallet.get_descriptor()])["unspents"]), 25) self.log.info("Create UTXOs...") pubk1, spk_P2SH_SEGWIT, addr_P2SH_SEGWIT = getnewdestination("p2sh-segwit") @@ -44,18 +46,18 @@ def run_test(self): self.sendtodestination(spk_BECH32, 0.004) #send to child keys of tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK - self.sendtodestination("mkHV1C6JLheLoUSSZYk7x3FH5tnx9bu7yc", 0.008) # (m/0'/0'/0') - self.sendtodestination("mipUSRmJAj2KrjSvsPQtnP8ynUon7FhpCR", 0.016) # (m/0'/0'/1') - self.sendtodestination("n37dAGe6Mq1HGM9t4b6rFEEsDGq7Fcgfqg", 0.032) # (m/0'/0'/1500') - self.sendtodestination("mqS9Rpg8nNLAzxFExsgFLCnzHBsoQ3PRM6", 0.064) # (m/0'/0'/0) - self.sendtodestination("mnTg5gVWr3rbhHaKjJv7EEEc76ZqHgSj4S", 0.128) # (m/0'/0'/1) - self.sendtodestination("mketCd6B9U9Uee1iCsppDJJBHfvi6U6ukC", 0.256) # (m/0'/0'/1500) - self.sendtodestination("mj8zFzrbBcdaWXowCQ1oPZ4qioBVzLzAp7", 0.512) # (m/1/1/0') - self.sendtodestination("mfnKpKQEftniaoE1iXuMMePQU3PUpcNisA", 1.024) # (m/1/1/1') - self.sendtodestination("mou6cB1kaP1nNJM1sryW6YRwnd4shTbXYQ", 2.048) # (m/1/1/1500') - self.sendtodestination("mtfUoUax9L4tzXARpw1oTGxWyoogp52KhJ", 4.096) # (m/1/1/0) - self.sendtodestination("mxp7w7j8S1Aq6L8StS2PqVvtt4HGxXEvdy", 8.192) # (m/1/1/1) - self.sendtodestination("mpQ8rokAhp1TAtJQR6F6TaUmjAWkAWYYBq", 16.384) # (m/1/1/1500) + self.sendtodestination(convert_btc_address_to_qtum("mkHV1C6JLheLoUSSZYk7x3FH5tnx9bu7yc"), 0.008) # (m/0'/0'/0') + self.sendtodestination(convert_btc_address_to_qtum("mipUSRmJAj2KrjSvsPQtnP8ynUon7FhpCR"), 0.016) # (m/0'/0'/1') + self.sendtodestination(convert_btc_address_to_qtum("n37dAGe6Mq1HGM9t4b6rFEEsDGq7Fcgfqg"), 0.032) # (m/0'/0'/1500') + self.sendtodestination(convert_btc_address_to_qtum("mqS9Rpg8nNLAzxFExsgFLCnzHBsoQ3PRM6"), 0.064) # (m/0'/0'/0) + self.sendtodestination(convert_btc_address_to_qtum("mnTg5gVWr3rbhHaKjJv7EEEc76ZqHgSj4S"), 0.128) # (m/0'/0'/1) + self.sendtodestination(convert_btc_address_to_qtum("mketCd6B9U9Uee1iCsppDJJBHfvi6U6ukC"), 0.256) # (m/0'/0'/1500) + self.sendtodestination(convert_btc_address_to_qtum("mj8zFzrbBcdaWXowCQ1oPZ4qioBVzLzAp7"), 0.512) # (m/1/1/0') + self.sendtodestination(convert_btc_address_to_qtum("mfnKpKQEftniaoE1iXuMMePQU3PUpcNisA"), 1.024) # (m/1/1/1') + self.sendtodestination(convert_btc_address_to_qtum("mou6cB1kaP1nNJM1sryW6YRwnd4shTbXYQ"), 2.048) # (m/1/1/1500') + self.sendtodestination(convert_btc_address_to_qtum("mtfUoUax9L4tzXARpw1oTGxWyoogp52KhJ"), 4.096) # (m/1/1/0) + self.sendtodestination(convert_btc_address_to_qtum("mxp7w7j8S1Aq6L8StS2PqVvtt4HGxXEvdy"), 8.192) # (m/1/1/1) + self.sendtodestination(convert_btc_address_to_qtum("mpQ8rokAhp1TAtJQR6F6TaUmjAWkAWYYBq"), 16.384) # (m/1/1/1500) self.generate(self.nodes[0], 1) diff --git a/test/functional/rpc_signer.py b/test/functional/rpc_signer.py index 488682e959..610d8ca02f 100755 --- a/test/functional/rpc_signer.py +++ b/test/functional/rpc_signer.py @@ -48,7 +48,7 @@ def clear_mock_result(self, node): def run_test(self): self.log.debug(f"-signer={self.mock_signer_path()}") - assert_raises_rpc_error(-1, 'Error: restart bitcoind with -signer=', + assert_raises_rpc_error(-1, 'Error: restart qtumd with -signer=', self.nodes[0].enumeratesigners ) diff --git a/test/functional/rpc_signmessagewithprivkey.py b/test/functional/rpc_signmessagewithprivkey.py index c5df22157d..86a7980e02 100755 --- a/test/functional/rpc_signmessagewithprivkey.py +++ b/test/functional/rpc_signmessagewithprivkey.py @@ -12,6 +12,7 @@ assert_equal, assert_raises_rpc_error, ) +from test_framework.qtum import convert_btc_address_to_qtum class SignMessagesWithPrivTest(BitcoinTestFramework): @@ -30,13 +31,13 @@ def run_test(self): self.log.info('test signing with priv_key') priv_key = 'cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N' - expected_signature = 'INbVnW4e6PeRmsv2Qgu8NuopvrVjkcxob+sX8OcZG0SALhWybUjzMLPdAsXI46YZGb0KQTRii+wWIQzRpG/U+S0=' + expected_signature = 'H82vbb1DFcGX32hHYCrWxCxo9aQCSSm4caa/+rvV2rdrT3YrZgkIQOIydNkd8F9rI94tTCgjzL/rplldv0ImR4I=' signature = self.nodes[0].signmessagewithprivkey(priv_key, message) assert_equal(expected_signature, signature) self.log.info('test that verifying with P2PKH address succeeds') addresses = self.addresses_from_privkey(priv_key) - assert_equal(addresses[0], 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB') + assert_equal(addresses[0], convert_btc_address_to_qtum('mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB')) assert self.nodes[0].verifymessage(addresses[0], signature, message) self.log.info('test that verifying with non-P2PKH addresses throws error') @@ -56,7 +57,7 @@ def run_test(self): assert_raises_rpc_error(-5, "Invalid private key", self.nodes[0].signmessagewithprivkey, "invalid_key", message) assert_raises_rpc_error(-5, "Invalid address", self.nodes[0].verifymessage, "invalid_addr", signature, message) # malformed signature provided - assert_raises_rpc_error(-3, "Malformed base64 encoding", self.nodes[0].verifymessage, 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB', "invalid_sig", message) + assert_raises_rpc_error(-3, "Malformed base64 encoding", self.nodes[0].verifymessage, convert_btc_address_to_qtum('mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB'), "invalid_sig", message) if __name__ == '__main__': diff --git a/test/functional/rpc_signrawtransactionwithkey.py b/test/functional/rpc_signrawtransactionwithkey.py index 0913f5057e..c3aadfb3dd 100755 --- a/test/functional/rpc_signrawtransactionwithkey.py +++ b/test/functional/rpc_signrawtransactionwithkey.py @@ -33,6 +33,8 @@ from decimal import ( Decimal, ) +from test_framework.qtum import convert_btc_address_to_qtum +from test_framework.wallet import MiniWallet INPUTS = [ # Valid pay-to-pubkey scripts @@ -41,13 +43,19 @@ {'txid': '83a4f6a6b73660e13ee6cb3c6063fa3759c50c9b7521d0536022961898f4fb02', 'vout': 0, 'scriptPubKey': '76a914669b857c03a5ed269d5d85a1ffac9ed5d663072788ac'}, ] -OUTPUTS = {'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB': 0.1} +OUTPUTS = {convert_btc_address_to_qtum('mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB'): 0.1} class SignRawTransactionWithKeyTest(BitcoinTestFramework): + def add_options(self, parser): + self.add_wallet_options(parser) + def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 + def skip_test_if_missing_module(self): + self.skip_if_no_wallet() + def send_to_address(self, addr, amount): input = {"txid": self.nodes[0].getblock(self.block_hash[self.blk_idx])["tx"][0], "vout": 0} output = {addr: amount} @@ -79,6 +87,7 @@ def witness_script_test(self): self.log.info("Test signing transaction to P2SH-P2WSH addresses without wallet") # Create a new P2SH-P2WSH 1-of-1 multisig address: embedded_privkey, embedded_pubkey = generate_keypair(wif=True) + self.wallet = MiniWallet(self.nodes[0]) p2sh_p2wsh_address = self.nodes[1].createmultisig(1, [embedded_pubkey.hex()], "p2sh-segwit") # send transaction to P2SH-P2WSH 1-of-1 multisig address self.block_hash = self.generate(self.nodes[0], COINBASE_MATURITY + 1) diff --git a/test/functional/rpc_txoutproof.py b/test/functional/rpc_txoutproof.py index 60b7ce8d20..757b305666 100755 --- a/test/functional/rpc_txoutproof.py +++ b/test/functional/rpc_txoutproof.py @@ -4,6 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test gettxoutproof and verifytxoutproof RPCs.""" +from test_framework.blocktools import COINBASE_MATURITY from test_framework.messages import ( CMerkleBlock, from_hex, @@ -28,7 +29,7 @@ def run_test(self): miniwallet = MiniWallet(self.nodes[0]) chain_height = self.nodes[1].getblockcount() - assert_equal(chain_height, 200) + assert_equal(chain_height, COINBASE_MATURITY+100) txid1 = miniwallet.send_self_transfer(from_node=self.nodes[0])['txid'] txid2 = miniwallet.send_self_transfer(from_node=self.nodes[0])['txid'] diff --git a/test/functional/rpc_users.py b/test/functional/rpc_users.py index 66cdd7cf9a..56b7af4c55 100755 --- a/test/functional/rpc_users.py +++ b/test/functional/rpc_users.py @@ -61,11 +61,11 @@ def conf_setup(self): rpcauth3 = lines[1] self.password = lines[3] - with open(self.nodes[0].datadir_path / "bitcoin.conf", "a", encoding="utf8") as f: + with open(self.nodes[0].datadir_path / "qtum.conf", "a", encoding="utf8") as f: f.write(rpcauth + "\n") f.write(rpcauth2 + "\n") f.write(rpcauth3 + "\n") - with open(self.nodes[1].datadir_path / "bitcoin.conf", "a", encoding="utf8") as f: + with open(self.nodes[1].datadir_path / "qtum.conf", "a", encoding="utf8") as f: f.write("rpcuser={}\n".format(self.rpcuser)) f.write("rpcpassword={}\n".format(self.rpcpassword)) self.restart_node(0) diff --git a/test/functional/rpc_whitelist.py b/test/functional/rpc_whitelist.py index fb404fb479..30f8e0d862 100755 --- a/test/functional/rpc_whitelist.py +++ b/test/functional/rpc_whitelist.py @@ -52,7 +52,7 @@ def run_test(self): ] # These commands shouldn't be allowed for any user to test failures self.never_allowed = ["getnetworkinfo"] - with open(self.nodes[0].datadir_path / "bitcoin.conf", "a", encoding="utf8") as f: + with open(self.nodes[0].datadir_path / "qtum.conf", "a", encoding="utf8") as f: f.write("\nrpcwhitelistdefault=0\n") for user in self.users: f.write("rpcauth=" + user[0] + ":" + user[1] + "\n") diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 148902032f..623c84c459 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -86,9 +86,10 @@ EXTENDED_SCRIPTS = [ # These tests are not run by default. # Longest test should go first, to favor running tests in parallel + 'qtum_evm_london_activation.py', + 'qtum_evm_shanghai_activation.py', 'feature_pruning.py', 'feature_dbcrash.py', - 'feature_index_prune.py', 'wallet_pruning.py --legacy-wallet', ] @@ -145,7 +146,7 @@ 'rpc_bind.py --nonloopback', 'p2p_headers_sync_with_minchainwork.py', 'p2p_feefilter.py', - 'feature_csv_activation.py', + #'feature_csv_activation.py', 'p2p_sendheaders.py', 'wallet_listtransactions.py --legacy-wallet', 'wallet_listtransactions.py --descriptors', @@ -220,7 +221,8 @@ 'feature_proxy.py', 'wallet_signrawtransactionwithwallet.py --legacy-wallet', 'wallet_signrawtransactionwithwallet.py --descriptors', - 'rpc_signrawtransactionwithkey.py', + 'rpc_signrawtransactionwithkey.py --legacy-wallet', + 'rpc_signrawtransactionwithkey.py --descriptors', 'rpc_rawtransaction.py --legacy-wallet', 'wallet_transactiontime_rescan.py --descriptors', 'wallet_transactiontime_rescan.py --legacy-wallet', @@ -289,7 +291,8 @@ 'wallet_balance.py --legacy-wallet', 'wallet_balance.py --descriptors', 'p2p_initial_headers_sync.py', - 'feature_nulldummy.py', + 'feature_nulldummy.py --legacy-wallet', + 'feature_nulldummy.py --descriptors', 'mempool_accept.py', 'mempool_expiry.py', 'wallet_import_with_label.py --legacy-wallet', @@ -310,7 +313,7 @@ 'wallet_encryption.py --legacy-wallet', 'wallet_encryption.py --descriptors', 'feature_dersig.py', - 'feature_cltv.py', + #'feature_cltv.py', 'rpc_uptime.py', 'feature_discover.py', 'wallet_resendwallettransactions.py --legacy-wallet', @@ -338,7 +341,7 @@ 'feature_filelock.py', 'feature_loadblock.py', 'feature_assumeutxo.py', - 'p2p_dos_header_tree.py', + #'p2p_dos_header_tree.py', 'p2p_add_connections.py', 'feature_bind_port_discover.py', 'p2p_unrequested_blocks.py', @@ -365,7 +368,7 @@ 'feature_anchors.py', 'mempool_datacarrier.py', 'feature_coinstatsindex.py', - 'wallet_orphanedreward.py', + # 'wallet_orphanedreward.py', // N/A in Qtum due to rolling checkpoints 'wallet_timelock.py', 'p2p_node_network_limited.py', 'p2p_permissions.py', @@ -385,8 +388,135 @@ 'feature_shutdown.py', 'wallet_migration.py', 'p2p_ibd_txrelay.py', + 'feature_index_prune.py', # Don't append tests at the end to avoid merge conflicts # Put them in a random line within the section that fits their approximate run-time + # qtum + 'qtum_evm_london_gas_usage.py --legacy-wallet', + 'qtum_evm_london_gas_usage.py --descriptors', + 'qtum_dgp.py --legacy-wallet', + 'qtum_dgp.py --descriptors', + 'qtum_pos.py --legacy-wallet', + 'qtum_pos.py --descriptors', + 'qtum_opcall.py --legacy-wallet', + 'qtum_opcall.py --descriptors', + 'qtum_opcreate.py --legacy-wallet', + 'qtum_opcreate.py --descriptors', + 'qtum_8mb_block.py --legacy-wallet', + 'qtum_8mb_block.py --descriptors', + 'qtum_gas_limit.py --legacy-wallet', + 'qtum_gas_limit.py --descriptors', + 'qtum_searchlog.py --legacy-wallet', + 'qtum_searchlog.py --descriptors', + 'qtum_pos_segwit.py --legacy-wallet', + 'qtum_pos_segwit.py --descriptors', + 'qtum_state_root.py --legacy-wallet', + 'qtum_state_root.py --descriptors', + 'qtum_evm_globals.py --legacy-wallet', + 'qtum_evm_globals.py --descriptors', + 'qtum_null_sender.py --legacy-wallet', + 'qtum_null_sender.py --descriptors', + 'qtum_waitforlogs.py --legacy-wallet', + 'qtum_waitforlogs.py --descriptors', + 'qtum_block_header.py --legacy-wallet', + 'qtum_block_header.py --descriptors', + 'qtum_callcontract.py --legacy-wallet', + 'qtum_callcontract.py --descriptors', + 'qtum_spend_op_call.py --legacy-wallet', + 'qtum_spend_op_call.py --descriptors', + 'qtum_condensing_txs.py --legacy-wallet', + 'qtum_condensing_txs.py --descriptors', + 'qtum_createcontract.py --legacy-wallet', + 'qtum_createcontract.py --descriptors', + 'qtum_sendtocontract.py --legacy-wallet', + 'qtum_sendtocontract.py --descriptors', + 'qtum_identical_refunds.py --legacy-wallet', + 'qtum_identical_refunds.py --descriptors', + 'qtum_create_eth_op_code.py --legacy-wallet', + 'qtum_create_eth_op_code.py --descriptors', + 'qtum_gas_limit_overflow.py --legacy-wallet', + 'qtum_gas_limit_overflow.py --descriptors', + 'qtum_call_empty_contract.py --legacy-wallet', + 'qtum_call_empty_contract.py --descriptors', + 'qtum_dgp_block_size_sync.py --legacy-wallet', + 'qtum_dgp_block_size_sync.py --descriptors', + 'qtum_pos_conflicting_txs.py --legacy-wallet', + 'qtum_pos_conflicting_txs.py --descriptors', + 'qtum_globals_state_changer.py --legacy-wallet', + 'qtum_globals_state_changer.py --descriptors', + 'qtum_no_exec_call_disabled.py --legacy-wallet', + 'qtum_no_exec_call_disabled.py --descriptors', + 'qtum_soft_block_gas_limits.py --legacy-wallet', + 'qtum_soft_block_gas_limits.py --descriptors', + 'qtum_dgp_block_size_restart.py --legacy-wallet', + 'qtum_dgp_block_size_restart.py --descriptors', + 'qtum_searchlog_restart_node.py --legacy-wallet', + 'qtum_searchlog_restart_node.py --descriptors', + 'qtum_immature_coinstake_spend.py --legacy-wallet', + 'qtum_immature_coinstake_spend.py --descriptors', + 'qtum_transaction_prioritization.py --legacy-wallet', + 'qtum_transaction_prioritization.py --descriptors', + 'qtum_assign_mpos_fees_to_gas_refund.py --legacy-wallet', + 'qtum_assign_mpos_fees_to_gas_refund.py --descriptors', + 'qtum_ignore_mpos_participant_reward.py --legacy-wallet', + 'qtum_ignore_mpos_participant_reward.py --descriptors', + 'qtum_evm_constantinople_activation.py --legacy-wallet', + 'qtum_evm_constantinople_activation.py --descriptors', + 'qtum_many_value_refunds_from_same_tx.py --legacy-wallet', + 'qtum_many_value_refunds_from_same_tx.py --descriptors', + 'qtum_combined_outputs_exceed_gas_limit.py --legacy-wallet', + 'qtum_combined_outputs_exceed_gas_limit.py --descriptors', + 'qtum_dgp_gas_price_lingering_mempool_tx.py --legacy-wallet', + 'qtum_dgp_gas_price_lingering_mempool_tx.py --descriptors', + 'qtum_dgp_gas_schedule.py --legacy-wallet', + 'qtum_dgp_gas_schedule.py --descriptors', + 'qtum_header_spam.py --dos-same-height --legacy-wallet', + 'qtum_header_spam.py --dos-variable-height --legacy-wallet', + 'qtum_header_spam.py --run-standard-tests --legacy-wallet', + 'qtum_header_spam.py --dos-same-height --descriptors', + 'qtum_header_spam.py --dos-variable-height --descriptors', + 'qtum_header_spam.py --run-standard-tests --descriptors', + 'qtum_divergence_dos.py --legacy-wallet', + 'qtum_divergence_dos.py --descriptors', + 'qtum_prioritize_create_over_call.py --legacy-wallet', + 'qtum_prioritize_create_over_call.py --descriptors', + 'qtum_callcontract_timestamp.py --legacy-wallet', + 'qtum_callcontract_timestamp.py --descriptors', + 'qtum_transaction_receipt_origin_contract_address.py --legacy-wallet', + 'qtum_transaction_receipt_origin_contract_address.py --descriptors', + 'qtum_block_number_corruption.py --legacy-wallet', + 'qtum_block_number_corruption.py --descriptors', + 'qtum_duplicate_stake.py --legacy-wallet', + 'qtum_duplicate_stake.py --descriptors', + 'qtum_rpc_bitcore.py --legacy-wallet', + 'qtum_rpc_bitcore.py --descriptors', + 'qtum_faulty_header_chain.py --legacy-wallet', + 'qtum_faulty_header_chain.py --descriptors', + 'qtum_signrawsender.py --legacy-wallet', + 'qtum_op_sender.py --legacy-wallet', + 'qtum_evm_revert.py --legacy-wallet', + 'qtum_evm_revert.py --descriptors', + 'qtum_evm_create2.py --legacy-wallet', + 'qtum_evm_create2.py --descriptors', + 'qtum_evm_staticcall.py --legacy-wallet', + 'qtum_evm_staticcall.py --descriptors', + 'qtum_evm_constantinople_precompiles.py --legacy-wallet', + 'qtum_evm_constantinople_precompiles.py --descriptors', + 'qtum_evm_constantinople_opcodes.py --legacy-wallet', + 'qtum_evm_constantinople_opcodes.py --descriptors', + 'qtum_block_index_cleanup.py --legacy-wallet', + 'qtum_block_index_cleanup.py --descriptors', + 'qtum_pod.py --legacy-wallet', + 'qtum_simple_delegation_contract.py --legacy-wallet', + 'qtum_delegation_contract.py --legacy-wallet', + 'qtum_qrc20.py --legacy-wallet', +] +# scripts irreleveant for Qtum +DISABLED_SCRIPTS = [ + 'wallet_orphanedreward.py', + 'feature_cltv.py', + 'feature_csv_activation.py', + 'p2p_dos_header_tree.py' ] # Place EXTENDED_SCRIPTS first since it has the 3 longest running tests @@ -790,7 +920,7 @@ def was_successful(self): def check_script_prefixes(): """Check that test scripts start with one of the allowed name prefixes.""" - good_prefixes_re = re.compile("^(example|feature|interface|mempool|mining|p2p|rpc|wallet|tool)_") + good_prefixes_re = re.compile("^(example|feature|interface|mempool|mining|p2p|rpc|wallet|tool|qtum)_") bad_script_names = [script for script in ALL_SCRIPTS if good_prefixes_re.match(script) is None] if bad_script_names: @@ -806,7 +936,7 @@ def check_script_list(*, src_dir, fail_on_warn): as a test script or meta script.""" script_dir = src_dir + '/test/functional/' python_files = set([test_file for test_file in os.listdir(script_dir) if test_file.endswith(".py")]) - missed_tests = list(python_files - set(map(lambda x: x.split()[0], ALL_SCRIPTS + NON_SCRIPTS))) + missed_tests = list(python_files - set(map(lambda x: x.split()[0], ALL_SCRIPTS + NON_SCRIPTS + DISABLED_SCRIPTS))) if len(missed_tests) != 0: print("%sWARNING!%s The following scripts are not being run: %s. Check the test lists in test_runner.py." % (BOLD[1], BOLD[0], str(missed_tests))) if fail_on_warn: diff --git a/test/functional/tool_wallet.py b/test/functional/tool_wallet.py index fc042bca66..f57aa5f270 100755 --- a/test/functional/tool_wallet.py +++ b/test/functional/tool_wallet.py @@ -16,6 +16,7 @@ assert_equal, sha256sum_file, ) +from test_framework.qtumconfig import COINBASE_MATURITY class ToolWalletTest(BitcoinTestFramework): @@ -68,7 +69,7 @@ def log_wallet_timestamp_comparison(self, old, new): def get_expected_info_output(self, name="", transactions=0, keypool=2, address=0, imported_privs=0): wallet_name = self.default_wallet_name if name == "" else name if self.options.descriptors: - output_types = 4 # p2pkh, p2sh, segwit, bech32m + output_types = 5 # p2pkh, p2sh, segwit, bech32m return textwrap.dedent('''\ Wallet info =========== @@ -170,7 +171,7 @@ def do_tool_createfromdump(self, wallet_name, dumpfile, file_format=None): self.assert_tool_output(load_output, *args) assert (self.nodes[0].wallets_path / wallet_name).is_dir() - self.assert_tool_output("The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n", '-wallet={}'.format(wallet_name), '-dumpfile={}'.format(rt_dumppath), 'dump') + self.assert_tool_output("The dumpfile may contain private keys. To ensure the safety of your Qtum, do not share the dumpfile.\n", '-wallet={}'.format(wallet_name), '-dumpfile={}'.format(rt_dumppath), 'dump') rt_dump_data = self.read_dump(rt_dumppath) wallet_dat = self.nodes[0].wallets_path / wallet_name / "wallet.dat" @@ -186,7 +187,7 @@ def test_invalid_tool_commands_and_args(self): self.assert_raises_tool_error("Error parsing command line arguments: Invalid command 'help'", 'help') self.assert_raises_tool_error('Error: Additional arguments provided (create). Methods do not take arguments. Please refer to `-help`.', 'info', 'create') self.assert_raises_tool_error('Error parsing command line arguments: Invalid parameter -foo', '-foo') - self.assert_raises_tool_error('No method provided. Run `bitcoin-wallet -help` for valid methods.') + self.assert_raises_tool_error('No method provided. Run `qtum-wallet -help` for valid methods.') self.assert_raises_tool_error('Wallet name must be provided when creating a new wallet.', 'create') locked_dir = self.nodes[0].wallets_path error = 'Error initializing wallet database environment "{}"!'.format(locked_dir) @@ -296,8 +297,8 @@ def test_getwalletinfo_on_different_wallet(self): assert_equal(1000, out['keypoolsize_hd_internal']) assert_equal(True, 'hdseedid' in out) else: - assert_equal(4000, out['keypoolsize']) - assert_equal(4000, out['keypoolsize_hd_internal']) + assert_equal(5000, out['keypoolsize']) + assert_equal(5000, out['keypoolsize_hd_internal']) self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after) assert_equal(timestamp_before, timestamp_after) @@ -325,7 +326,7 @@ def test_dump_createfromdump(self): self.log.info('Checking basic dump') wallet_dump = self.nodes[0].datadir_path / "wallet.dump" - self.assert_tool_output('The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n', '-wallet=todump', '-dumpfile={}'.format(wallet_dump), 'dump') + self.assert_tool_output('The dumpfile may contain private keys. To ensure the safety of your Qtum, do not share the dumpfile.\n', '-wallet=todump', '-dumpfile={}'.format(wallet_dump), 'dump') dump_data = self.read_dump(wallet_dump) orig_dump = dump_data.copy() @@ -357,12 +358,12 @@ def test_dump_createfromdump(self): bad_ver_wallet_dump = self.nodes[0].datadir_path / "wallet-bad_ver1.dump" dump_data["BITCOIN_CORE_WALLET_DUMP"] = "0" self.write_dump(dump_data, bad_ver_wallet_dump) - self.assert_raises_tool_error('Error: Dumpfile version is not supported. This version of bitcoin-wallet only supports version 1 dumpfiles. Got dumpfile with version 0', '-wallet=badload', '-dumpfile={}'.format(bad_ver_wallet_dump), 'createfromdump') + self.assert_raises_tool_error('Error: Dumpfile version is not supported. This version of qtum-wallet only supports version 1 dumpfiles. Got dumpfile with version 0', '-wallet=badload', '-dumpfile={}'.format(bad_ver_wallet_dump), 'createfromdump') assert not (self.nodes[0].wallets_path / "badload").is_dir() bad_ver_wallet_dump = self.nodes[0].datadir_path / "wallet-bad_ver2.dump" dump_data["BITCOIN_CORE_WALLET_DUMP"] = "2" self.write_dump(dump_data, bad_ver_wallet_dump) - self.assert_raises_tool_error('Error: Dumpfile version is not supported. This version of bitcoin-wallet only supports version 1 dumpfiles. Got dumpfile with version 2', '-wallet=badload', '-dumpfile={}'.format(bad_ver_wallet_dump), 'createfromdump') + self.assert_raises_tool_error('Error: Dumpfile version is not supported. This version of qtum-wallet only supports version 1 dumpfiles. Got dumpfile with version 2', '-wallet=badload', '-dumpfile={}'.format(bad_ver_wallet_dump), 'createfromdump') assert not (self.nodes[0].wallets_path / "badload").is_dir() bad_magic_wallet_dump = self.nodes[0].datadir_path / "wallet-bad_magic.dump" del dump_data["BITCOIN_CORE_WALLET_DUMP"] @@ -397,7 +398,7 @@ def test_dump_createfromdump(self): def test_chainless_conflicts(self): self.log.info("Test wallet tool when wallet contains conflicting transactions") self.restart_node(0) - self.generate(self.nodes[0], 101) + self.generate(self.nodes[0], COINBASE_MATURITY+1) def_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name) @@ -426,7 +427,7 @@ def test_chainless_conflicts(self): locktime += 1 # conflict with parent - conflict_unsigned = self.nodes[0].createrawtransaction(inputs=[conflict_utxo], outputs=[{wallet.getnewaddress(): 9.9999}]) + conflict_unsigned = self.nodes[0].createrawtransaction(inputs=[conflict_utxo], outputs=[{wallet.getnewaddress(): 9.8999}]) conflict_signed = wallet.signrawtransactionwithwallet(conflict_unsigned)["hex"] conflict_txid = self.nodes[0].sendrawtransaction(conflict_signed) self.generate(self.nodes[0], 1) @@ -445,7 +446,7 @@ def test_chainless_conflicts(self): Descriptors: {"yes" if self.options.descriptors else "no"} Encrypted: no HD (hd seed available): yes - Keypool Size: {"8" if self.options.descriptors else "1"} + Keypool Size: {"10" if self.options.descriptors else "1"} Transactions: 4 Address Book: 4 ''') diff --git a/test/functional/wallet_abandonconflict.py b/test/functional/wallet_abandonconflict.py index 2691507773..ef3cef259b 100755 --- a/test/functional/wallet_abandonconflict.py +++ b/test/functional/wallet_abandonconflict.py @@ -40,7 +40,7 @@ def run_test(self): self.nodes[0].createwallet(wallet_name="bob") bob = self.nodes[0].get_wallet_rpc("bob") - self.generate(self.nodes[1], COINBASE_MATURITY) + self.nodes[1].generate(COINBASE_MATURITY) balance = alice.getbalance() txA = alice.sendtoaddress(alice.getnewaddress(), Decimal("10")) txB = alice.sendtoaddress(alice.getnewaddress(), Decimal("10")) @@ -54,7 +54,7 @@ def run_test(self): assert_raises_rpc_error(-5, 'Transaction not eligible for abandonment', lambda: alice.abandontransaction(txid=txA)) newbalance = alice.getbalance() - assert balance - newbalance < Decimal("0.001") #no more than fees lost + assert balance - newbalance < Decimal("0.01") #no more than fees lost balance = newbalance # Disconnect nodes so node0's transactions don't get into node1's mempool @@ -178,7 +178,7 @@ def run_test(self): inputs = [] inputs.append({"txid": txA, "vout": nA}) outputs = {} - outputs[self.nodes[1].getnewaddress()] = Decimal("3.9999") + outputs[self.nodes[1].getnewaddress()] = Decimal("3.99") outputs[bob.getnewaddress()] = Decimal("5.9999") tx = alice.createrawtransaction(inputs, outputs) signed = alice.signrawtransactionwithwallet(tx) diff --git a/test/functional/wallet_address_types.py b/test/functional/wallet_address_types.py index be5b3ebadb..c8964a798f 100755 --- a/test/functional/wallet_address_types.py +++ b/test/functional/wallet_address_types.py @@ -229,7 +229,12 @@ def test_change_output_type(self, node_sender, destinations, expected_type): def run_test(self): # Mine 101 blocks on node5 to bring nodes out of IBD and make sure that # no coinbases are maturing for the nodes-under-test during the test - self.generate(self.nodes[5], COINBASE_MATURITY + 1) + # send the new blocks in parts. + for i in range(0, COINBASE_MATURITY, 100): + self.nodes[5].generate(100) + self.sync_blocks() + self.nodes[5].generate(1) + self.sync_blocks() uncompressed_1 = "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee" uncompressed_2 = "047211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073dee6c89064984f03385237d92167c13e236446b417ab79a0fcae412ae3316b77" diff --git a/test/functional/wallet_avoid_mixing_output_types.py b/test/functional/wallet_avoid_mixing_output_types.py index 861765f452..a62629f1a9 100755 --- a/test/functional/wallet_avoid_mixing_output_types.py +++ b/test/functional/wallet_avoid_mixing_output_types.py @@ -130,7 +130,7 @@ def skip_test_if_missing_module(self): self.skip_if_no_sqlite() def make_payment(self, A, B, v, addr_type): - fee_rate = random.randint(1, 20) + fee_rate = random.randint(400, 420) self.log.debug(f"Making payment of {v} BTC at fee_rate {fee_rate}") tx = B.sendtoaddress( address=A.getnewaddress(address_type=addr_type), diff --git a/test/functional/wallet_avoidreuse.py b/test/functional/wallet_avoidreuse.py index c257bda452..11e6882586 100755 --- a/test/functional/wallet_avoidreuse.py +++ b/test/functional/wallet_avoidreuse.py @@ -43,7 +43,7 @@ def count_unspent(node): r["reused"]["supported"] = supports_reused return r -def assert_unspent(node, total_count=None, total_sum=None, reused_supported=None, reused_count=None, reused_sum=None, margin=0.001): +def assert_unspent(node, total_count=None, total_sum=None, reused_supported=None, reused_count=None, reused_sum=None, margin=0.01): '''Make assertions about a node's unspent output statistics''' stats = count_unspent(node) if total_count is not None: @@ -219,11 +219,11 @@ def test_sending_from_reused_address_without_avoid_reuse(self): # listunspent should show 1 total outputs (5 btc), unused assert_unspent(self.nodes[1], total_count=1, total_sum=5, reused_count=0) # getbalances should show no used, 5 btc trusted - assert_balances(self.nodes[1], mine={"used": 0, "trusted": 5}) + assert_balances(self.nodes[1], mine={"used": 0, "trusted": 5}, margin=0.01) # node 1 should now have about 5 btc left (for both cases) - assert_approx(self.nodes[1].getbalance(), 5, 0.001) - assert_approx(self.nodes[1].getbalance(avoid_reuse=False), 5, 0.001) + assert_approx(self.nodes[1].getbalance(), 5, 0.01) + assert_approx(self.nodes[1].getbalance(avoid_reuse=False), 5, 0.01) def test_sending_from_reused_address_fails(self, second_addr_type): ''' @@ -277,8 +277,8 @@ def test_sending_from_reused_address_fails(self, second_addr_type): assert_balances(self.nodes[1], mine={"used": 10, "trusted": 5}) # node 1 should now have a balance of 5 (no dirty) or 15 (including dirty) - assert_approx(self.nodes[1].getbalance(), 5, 0.001) - assert_approx(self.nodes[1].getbalance(avoid_reuse=False), 15, 0.001) + assert_approx(self.nodes[1].getbalance(), 5, 0.01) + assert_approx(self.nodes[1].getbalance(avoid_reuse=False), 15, 0.01) assert_raises_rpc_error(-6, "Insufficient funds", self.nodes[1].sendtoaddress, retaddr, 10) @@ -287,11 +287,11 @@ def test_sending_from_reused_address_fails(self, second_addr_type): # listunspent should show 2 total outputs (1, 10 btc), one unused (1), one reused (10) assert_unspent(self.nodes[1], total_count=2, total_sum=11, reused_count=1, reused_sum=10) # getbalances should show 10 used, 1 btc trusted - assert_balances(self.nodes[1], mine={"used": 10, "trusted": 1}) + assert_balances(self.nodes[1], mine={"used": 10, "trusted": 1}, margin=0.01) # node 1 should now have about 1 btc left (no dirty) and 11 (including dirty) - assert_approx(self.nodes[1].getbalance(), 1, 0.001) - assert_approx(self.nodes[1].getbalance(avoid_reuse=False), 11, 0.001) + assert_approx(self.nodes[1].getbalance(), 1, 0.01) + assert_approx(self.nodes[1].getbalance(avoid_reuse=False), 11, 0.01) def test_getbalances_used(self): ''' @@ -319,8 +319,8 @@ def test_getbalances_used(self): # getbalances and listunspent should show the remaining outputs # in the reused address as used/reused - assert_unspent(self.nodes[1], total_count=2, total_sum=96, reused_count=1, reused_sum=1, margin=0.01) - assert_balances(self.nodes[1], mine={"used": 1, "trusted": 95}, margin=0.01) + assert_unspent(self.nodes[1], total_count=2, total_sum=96, reused_count=1, reused_sum=1, margin=0.06) + assert_balances(self.nodes[1], mine={"used": 1, "trusted": 95}, margin=0.06) def test_full_destination_group_is_preferred(self): ''' diff --git a/test/functional/wallet_backup.py b/test/functional/wallet_backup.py index eb3e0ae728..836e0ec87b 100755 --- a/test/functional/wallet_backup.py +++ b/test/functional/wallet_backup.py @@ -41,6 +41,8 @@ assert_equal, assert_raises_rpc_error, ) +from test_framework.qtumconfig import INITIAL_BLOCK_REWARD +from test_framework.qtum import generatesynchronized class WalletBackupTest(BitcoinTestFramework): @@ -144,11 +146,11 @@ def run_test(self): self.generate(self.nodes[0], 1) self.generate(self.nodes[1], 1) self.generate(self.nodes[2], 1) - self.generate(self.nodes[3], COINBASE_MATURITY) + generatesynchronized(self.nodes[3], COINBASE_MATURITY, None, self.nodes) - assert_equal(self.nodes[0].getbalance(), 50) - assert_equal(self.nodes[1].getbalance(), 50) - assert_equal(self.nodes[2].getbalance(), 50) + assert_equal(self.nodes[0].getbalance(), INITIAL_BLOCK_REWARD) + assert_equal(self.nodes[1].getbalance(), INITIAL_BLOCK_REWARD) + assert_equal(self.nodes[2].getbalance(), INITIAL_BLOCK_REWARD) assert_equal(self.nodes[3].getbalance(), 0) self.log.info("Creating transactions") @@ -170,7 +172,7 @@ def run_test(self): self.do_one_round() # Generate 101 more blocks, so any fees paid mature - self.generate(self.nodes[3], COINBASE_MATURITY + 1) + generatesynchronized(self.nodes[3], COINBASE_MATURITY + 1, None, self.nodes) balance0 = self.nodes[0].getbalance() balance1 = self.nodes[1].getbalance() @@ -180,7 +182,7 @@ def run_test(self): # At this point, there are 214 blocks (103 for setup, then 10 rounds, then 101.) # 114 are mature, so the sum of all wallets should be 114 * 50 = 5700. - assert_equal(total, 5700) + assert_equal(total, (COINBASE_MATURITY+14)*INITIAL_BLOCK_REWARD) ## # Test restoring spender wallets from backups diff --git a/test/functional/wallet_change_address.py b/test/functional/wallet_change_address.py index f8bfe9eebf..ce58527402 100755 --- a/test/functional/wallet_change_address.py +++ b/test/functional/wallet_change_address.py @@ -59,14 +59,14 @@ def run_test(self): addrs = addr1 + addr2 # Send 1 + 0.5 coin to each address - [self.nodes[0].sendtoaddress(addr, 1.0) for addr in addrs] - [self.nodes[0].sendtoaddress(addr, 0.5) for addr in addrs] + [self.nodes[0].sendtoaddress(addr, 100.0) for addr in addrs] + [self.nodes[0].sendtoaddress(addr, 50) for addr in addrs] self.generate(self.nodes[0], 1) for i in range(20): for n in [1, 2]: self.log.debug(f"Send transaction from node {n}: expected change index {i}") - txid = self.nodes[n].sendtoaddress(self.nodes[0].getnewaddress(), 0.2) + txid = self.nodes[n].sendtoaddress(self.nodes[0].getnewaddress(), 2) tx = self.nodes[n].getrawtransaction(txid, True) # find the change output and ensure that expected change index was used self.assert_change_index(self.nodes[n], tx, i) @@ -78,10 +78,10 @@ def run_test(self): w2 = self.nodes[2].get_wallet_rpc("w2") addr1 = w1.getnewaddress() addr2 = w2.getnewaddress() - self.nodes[0].sendtoaddress(addr1, 3.0) - self.nodes[0].sendtoaddress(addr1, 0.1) - self.nodes[0].sendtoaddress(addr2, 3.0) - self.nodes[0].sendtoaddress(addr2, 0.1) + self.nodes[0].sendtoaddress(addr1, 30) + self.nodes[0].sendtoaddress(addr1, 15) + self.nodes[0].sendtoaddress(addr2, 30) + self.nodes[0].sendtoaddress(addr2, 15) self.generate(self.nodes[0], 1) sendTo1 = self.nodes[0].getnewaddress() @@ -90,7 +90,7 @@ def run_test(self): # The avoid partial spends wallet will always create a change output node = self.nodes[2] - res = w2.send({sendTo1: "1.0", sendTo2: "1.0", sendTo3: "0.9999"}, options={"change_position": 0}) + res = w2.send({sendTo1: "10.0", sendTo2: "10.0", sendTo3: "9.9999"}, options={"change_position": 0}) tx = node.getrawtransaction(res["txid"], True) self.assert_change_pos(w2, tx, 0) @@ -98,7 +98,7 @@ def run_test(self): # then create a second candidate using APS that requires a change output. # Ensure that the user-configured change position is kept node = self.nodes[1] - res = w1.send({sendTo1: "1.0", sendTo2: "1.0", sendTo3: "0.9999"}, options={"change_position": 0}) + res = w1.send({sendTo1: "10.0", sendTo2: "10.0", sendTo3: "9.9999"}, options={"change_position": 0}) tx = node.getrawtransaction(res["txid"], True) # If the wallet ignores the user's change_position there is still a 25% # that the random change position passes the test diff --git a/test/functional/wallet_coinbase_category.py b/test/functional/wallet_coinbase_category.py index c2cb0bf3b0..07418f0fc0 100755 --- a/test/functional/wallet_coinbase_category.py +++ b/test/functional/wallet_coinbase_category.py @@ -11,6 +11,7 @@ from test_framework.util import ( assert_array_result ) +from test_framework.qtumconfig import COINBASE_MATURITY class CoinbaseCategoryTest(BitcoinTestFramework): def add_options(self, parser): @@ -45,19 +46,19 @@ def run_test(self): self.assert_category("immature", address, txid, 0) # Mine another 99 blocks on top - self.generate(self.nodes[0], 99) + self.nodes[0].generate(COINBASE_MATURITY-1) # Coinbase transaction is still immature after 100 confirmations - self.assert_category("immature", address, txid, 99) + self.assert_category("immature", address, txid, COINBASE_MATURITY-1) # Mine one more block self.generate(self.nodes[0], 1) # Coinbase transaction is now matured, so category is "generate" - self.assert_category("generate", address, txid, 100) + self.assert_category("generate", address, txid, COINBASE_MATURITY) # Orphan block that paid to address self.nodes[0].invalidateblock(hash) # Coinbase transaction is now orphaned - self.assert_category("orphan", address, txid, 100) + self.assert_category("orphan", address, txid, COINBASE_MATURITY) if __name__ == '__main__': CoinbaseCategoryTest().main() diff --git a/test/functional/wallet_create_tx.py b/test/functional/wallet_create_tx.py index 4e31b48ec0..005cada154 100755 --- a/test/functional/wallet_create_tx.py +++ b/test/functional/wallet_create_tx.py @@ -11,6 +11,7 @@ from test_framework.blocktools import ( TIME_GENESIS_BLOCK, ) +from test_framework.qtumconfig import COINBASE_MATURITY class CreateTxWalletTest(BitcoinTestFramework): @@ -27,7 +28,7 @@ def skip_test_if_missing_module(self): def run_test(self): self.log.info('Create some old blocks') self.nodes[0].setmocktime(TIME_GENESIS_BLOCK) - self.generate(self.nodes[0], 200) + self.nodes[0].generate(COINBASE_MATURITY+100) self.nodes[0].setmocktime(0) self.test_anti_fee_sniping() @@ -36,7 +37,7 @@ def run_test(self): def test_anti_fee_sniping(self): self.log.info('Check that we have some (old) blocks and that anti-fee-sniping is disabled') - assert_equal(self.nodes[0].getblockchaininfo()['blocks'], 200) + assert_equal(self.nodes[0].getblockchaininfo()['blocks'], COINBASE_MATURITY+100) txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) tx = self.nodes[0].gettransaction(txid=txid, verbose=True)['decoded'] assert_equal(tx['locktime'], 0) @@ -45,16 +46,16 @@ def test_anti_fee_sniping(self): self.generate(self.nodes[0], 1) txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) tx = self.nodes[0].gettransaction(txid=txid, verbose=True)['decoded'] - assert 0 < tx['locktime'] <= 201 + assert 0 < tx['locktime'] <= COINBASE_MATURITY+101 def test_tx_size_too_large(self): # More than 10kB of outputs, so that we hit -maxtxfee with a high feerate - outputs = {self.nodes[0].getnewaddress(address_type='bech32'): 0.000025 for _ in range(400)} + outputs = {self.nodes[0].getnewaddress(address_type='bech32'): 0.0025 for _ in range(400)} raw_tx = self.nodes[0].createrawtransaction(inputs=[], outputs=outputs) for fee_setting in ['-minrelaytxfee=0.01', '-mintxfee=0.01', '-paytxfee=0.01']: self.log.info('Check maxtxfee in combination with {}'.format(fee_setting)) - self.restart_node(0, extra_args=[fee_setting]) + self.restart_node(0, extra_args=[fee_setting] + ['-maxtxfee=0.01']) assert_raises_rpc_error( -6, "Fee exceeds maximum configured by user (e.g. -maxtxfee, maxfeerate)", @@ -67,7 +68,7 @@ def test_tx_size_too_large(self): ) self.log.info('Check maxtxfee in combination with settxfee') - self.restart_node(0) + self.restart_node(0, extra_args=['-maxtxfee=0.01']) self.nodes[0].settxfee(0.01) assert_raises_rpc_error( -6, diff --git a/test/functional/wallet_createwallet.py b/test/functional/wallet_createwallet.py index 8e07021e03..a5e3299836 100755 --- a/test/functional/wallet_createwallet.py +++ b/test/functional/wallet_createwallet.py @@ -25,6 +25,7 @@ def add_options(self, parser): def set_test_params(self): self.num_nodes = 1 + self.extra_args = [["-addresstype=bech32"]] def skip_test_if_missing_module(self): self.skip_if_no_wallet() @@ -156,7 +157,7 @@ def run_test(self): w6.keypoolrefill(1) # There should only be 1 key for legacy, 3 for descriptors walletinfo = w6.getwalletinfo() - keys = 4 if self.options.descriptors else 1 + keys = 5 if self.options.descriptors else 1 assert_equal(walletinfo['keypoolsize'], keys) assert_equal(walletinfo['keypoolsize_hd_internal'], keys) # Allow empty passphrase, but there should be a warning diff --git a/test/functional/wallet_descriptor.py b/test/functional/wallet_descriptor.py index e9321b72e2..7f5a6b491d 100755 --- a/test/functional/wallet_descriptor.py +++ b/test/functional/wallet_descriptor.py @@ -9,7 +9,7 @@ except ImportError: pass -from test_framework.blocktools import COINBASE_MATURITY +from test_framework.qtumconfig import COINBASE_MATURITY from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, @@ -51,8 +51,8 @@ def run_test(self): self.log.info("Checking wallet info") wallet_info = self.nodes[0].getwalletinfo() assert_equal(wallet_info['format'], 'sqlite') - assert_equal(wallet_info['keypoolsize'], 400) - assert_equal(wallet_info['keypoolsize_hd_internal'], 400) + assert_equal(wallet_info['keypoolsize'], 500) + assert_equal(wallet_info['keypoolsize_hd_internal'], 500) assert 'keypoololdest' not in wallet_info # Check that getnewaddress works @@ -60,43 +60,43 @@ def run_test(self): addr = self.nodes[0].getnewaddress("", "legacy") addr_info = self.nodes[0].getaddressinfo(addr) assert addr_info['desc'].startswith('pkh(') - assert_equal(addr_info['hdkeypath'], 'm/44h/1h/0h/0/0') + assert_equal(addr_info['hdkeypath'], 'm/44h/88h/0h/0/0') addr = self.nodes[0].getnewaddress("", "p2sh-segwit") addr_info = self.nodes[0].getaddressinfo(addr) assert addr_info['desc'].startswith('sh(wpkh(') - assert_equal(addr_info['hdkeypath'], 'm/49h/1h/0h/0/0') + assert_equal(addr_info['hdkeypath'], 'm/49h/88h/0h/0/0') addr = self.nodes[0].getnewaddress("", "bech32") addr_info = self.nodes[0].getaddressinfo(addr) assert addr_info['desc'].startswith('wpkh(') - assert_equal(addr_info['hdkeypath'], 'm/84h/1h/0h/0/0') + assert_equal(addr_info['hdkeypath'], 'm/84h/88h/0h/0/0') addr = self.nodes[0].getnewaddress("", "bech32m") addr_info = self.nodes[0].getaddressinfo(addr) assert addr_info['desc'].startswith('tr(') - assert_equal(addr_info['hdkeypath'], 'm/86h/1h/0h/0/0') + assert_equal(addr_info['hdkeypath'], 'm/86h/88h/0h/0/0') # Check that getrawchangeaddress works addr = self.nodes[0].getrawchangeaddress("legacy") addr_info = self.nodes[0].getaddressinfo(addr) assert addr_info['desc'].startswith('pkh(') - assert_equal(addr_info['hdkeypath'], 'm/44h/1h/0h/1/0') + assert_equal(addr_info['hdkeypath'], 'm/44h/88h/0h/1/0') addr = self.nodes[0].getrawchangeaddress("p2sh-segwit") addr_info = self.nodes[0].getaddressinfo(addr) assert addr_info['desc'].startswith('sh(wpkh(') - assert_equal(addr_info['hdkeypath'], 'm/49h/1h/0h/1/0') + assert_equal(addr_info['hdkeypath'], 'm/49h/88h/0h/1/0') addr = self.nodes[0].getrawchangeaddress("bech32") addr_info = self.nodes[0].getaddressinfo(addr) assert addr_info['desc'].startswith('wpkh(') - assert_equal(addr_info['hdkeypath'], 'm/84h/1h/0h/1/0') + assert_equal(addr_info['hdkeypath'], 'm/84h/88h/0h/1/0') addr = self.nodes[0].getrawchangeaddress("bech32m") addr_info = self.nodes[0].getaddressinfo(addr) assert addr_info['desc'].startswith('tr(') - assert_equal(addr_info['hdkeypath'], 'm/86h/1h/0h/1/0') + assert_equal(addr_info['hdkeypath'], 'm/86h/88h/0h/1/0') # Make a wallet to receive coins at self.nodes[0].createwallet(wallet_name="desc2", descriptors=True) @@ -176,14 +176,14 @@ def run_test(self): self.nodes[0].createwallet(wallet_name='desc_import', disable_private_keys=True, descriptors=True) imp_rpc = self.nodes[0].get_wallet_rpc('desc_import') - addr_types = [('legacy', False, 'pkh(', '44h/1h/0h', -13), - ('p2sh-segwit', False, 'sh(wpkh(', '49h/1h/0h', -14), - ('bech32', False, 'wpkh(', '84h/1h/0h', -13), - ('bech32m', False, 'tr(', '86h/1h/0h', -13), - ('legacy', True, 'pkh(', '44h/1h/0h', -13), - ('p2sh-segwit', True, 'sh(wpkh(', '49h/1h/0h', -14), - ('bech32', True, 'wpkh(', '84h/1h/0h', -13), - ('bech32m', True, 'tr(', '86h/1h/0h', -13)] + addr_types = [('legacy', False, 'pkh(', '44h/88h/0h', -13), + ('p2sh-segwit', False, 'sh(wpkh(', '49h/88h/0h', -14), + ('bech32', False, 'wpkh(', '84h/88h/0h', -13), + ('bech32m', False, 'tr(', '86h/88h/0h', -13), + ('legacy', True, 'pkh(', '44h/88h/0h', -13), + ('p2sh-segwit', True, 'sh(wpkh(', '49h/88h/0h', -14), + ('bech32', True, 'wpkh(', '84h/88h/0h', -13), + ('bech32m', True, 'tr(', '86h/88h/0h', -13)] for addr_type, internal, desc_prefix, deriv_path, int_idx in addr_types: int_str = 'internal' if internal else 'external' @@ -196,7 +196,7 @@ def run_test(self): desc = exp_rpc.getaddressinfo(addr)['parent_desc'] assert_equal(desc_prefix, desc[0:len(desc_prefix)]) idx = desc.index('/') + 1 - assert_equal(deriv_path, desc[idx:idx + 9]) + assert_equal(deriv_path, desc[idx:idx + 10]) if internal: assert_equal('1', desc[int_idx]) else: diff --git a/test/functional/wallet_disable.py b/test/functional/wallet_disable.py index 9c73f7dead..40062458e1 100755 --- a/test/functional/wallet_disable.py +++ b/test/functional/wallet_disable.py @@ -10,6 +10,7 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_raises_rpc_error +from test_framework.qtum import convert_btc_address_to_qtum class DisableWalletTest (BitcoinTestFramework): def set_test_params(self): @@ -23,7 +24,7 @@ def run_test (self): assert_raises_rpc_error(-32601, 'Method not found', self.nodes[0].getwalletinfo) x = self.nodes[0].validateaddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy') assert x['isvalid'] == False - x = self.nodes[0].validateaddress('mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ') + x = self.nodes[0].validateaddress(convert_btc_address_to_qtum('mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')) assert x['isvalid'] == True diff --git a/test/functional/wallet_dump.py b/test/functional/wallet_dump.py index f50aae0c53..87232ce011 100755 --- a/test/functional/wallet_dump.py +++ b/test/functional/wallet_dump.py @@ -67,13 +67,13 @@ def read_dump(file_name, addrs, script_addrs, hd_master_addr_old): # count key types for addrObj in addrs: if addrObj['address'] == addr.split(",")[0] and addrObj['hdkeypath'] == keypath and keytype == "label=": - if addr.startswith('m') or addr.startswith('n'): + if addr.startswith('q') and not addr.startswith('qcrt'): # P2PKH address found_legacy_addr += 1 - elif addr.startswith('2'): + elif addr.startswith('m'): # P2SH-segwit address found_p2sh_segwit_addr += 1 - elif addr.startswith('bcrt1'): + elif addr.startswith('qcrt'): found_bech32_addr += 1 break elif keytype == "change=1": @@ -212,6 +212,8 @@ def run_test(self): with self.nodes[0].assert_debug_log(['Flushing wallet.dat'], timeout=20): self.nodes[0].getnewaddress() + # Overwriting should fail + assert_raises_rpc_error(-8, "already exists", lambda: self.nodes[0].dumpwallet(wallet_enc_dump)) # Make sure that dumpwallet doesn't have a lock order issue when there is an unconfirmed tx and it is reloaded # See https://github.com/bitcoin/bitcoin/issues/22489 self.nodes[0].createwallet("w3") diff --git a/test/functional/wallet_fast_rescan.py b/test/functional/wallet_fast_rescan.py index 2f9c924e71..e14e624c38 100755 --- a/test/functional/wallet_fast_rescan.py +++ b/test/functional/wallet_fast_rescan.py @@ -16,7 +16,7 @@ KEYPOOL_SIZE = 100 # smaller than default size to speed-up test -NUM_DESCRIPTORS = 9 # number of descriptors (8 default ranged ones + 1 fixed non-ranged one) +NUM_DESCRIPTORS = 11 # number of descriptors (10 default ranged ones + 1 fixed non-ranged one) NUM_BLOCKS = 6 # number of blocks to mine @@ -63,7 +63,7 @@ def run_test(self): else: spk = bytes.fromhex(fixed_key.p2wpkh_script) self.log.info(f"-> fixed non-range descriptor address {fixed_key.p2wpkh_addr}") - wallet.send_to(from_node=node, scriptPubKey=spk, amount=10000) + wallet.send_to(from_node=node, scriptPubKey=spk, amount=100000) self.generate(node, 1) self.log.info("Import wallet backup with block filter index") diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py index 0f4b7cfcb1..d9186ecaf5 100755 --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -12,7 +12,7 @@ assert_equal, assert_raises_rpc_error, ) - +from test_framework.qtum import generatesynchronized, convert_btc_bech32_address_to_qtum class WalletHDTest(BitcoinTestFramework): def add_options(self, parser): @@ -40,12 +40,12 @@ def run_test(self): change_addr = self.nodes[1].getrawchangeaddress() change_addrV = self.nodes[1].getaddressinfo(change_addr) if self.options.descriptors: - assert_equal(change_addrV["hdkeypath"], "m/84h/1h/0h/1/0") + assert_equal(change_addrV["hdkeypath"], "m/44h/88h/0h/1/0") else: - assert_equal(change_addrV["hdkeypath"], "m/0'/1'/0'") #first internal child key + assert_equal(change_addrV["hdkeypath"], "m/88'/1'/0'") #first internal child key # Import a non-HD private key in the HD wallet - non_hd_add = 'bcrt1qmevj8zfx0wdvp05cqwkmr6mxkfx60yezwjksmt' + non_hd_add = convert_btc_bech32_address_to_qtum('bcrt1qmevj8zfx0wdvp05cqwkmr6mxkfx60yezwjksmt') non_hd_key = 'cS9umN9w6cDMuRVYdbkfE4c7YUFLJRoXMfhQ569uY4odiQbVN8Rt' self.nodes[1].importprivkey(non_hd_key) @@ -55,16 +55,16 @@ def run_test(self): # Derive some HD addresses and remember the last # Also send funds to each add - self.generate(self.nodes[0], COINBASE_MATURITY + 1) + generatesynchronized(self.nodes[0], COINBASE_MATURITY + 1, None, self.nodes) hd_add = None NUM_HD_ADDS = 10 for i in range(1, NUM_HD_ADDS + 1): hd_add = self.nodes[1].getnewaddress() hd_info = self.nodes[1].getaddressinfo(hd_add) if self.options.descriptors: - assert_equal(hd_info["hdkeypath"], "m/84h/1h/0h/0/" + str(i)) + assert_equal(hd_info["hdkeypath"], "m/44h/88h/0h/0/" + str(i)) else: - assert_equal(hd_info["hdkeypath"], "m/0'/0'/" + str(i) + "'") + assert_equal(hd_info["hdkeypath"], "m/88'/0'/" + str(i) + "'") assert_equal(hd_info["hdmasterfingerprint"], hd_fingerprint) self.nodes[0].sendtoaddress(hd_add, 1) self.generate(self.nodes[0], 1) @@ -75,9 +75,9 @@ def run_test(self): change_addr = self.nodes[1].getrawchangeaddress() change_addrV = self.nodes[1].getaddressinfo(change_addr) if self.options.descriptors: - assert_equal(change_addrV["hdkeypath"], "m/84h/1h/0h/1/1") + assert_equal(change_addrV["hdkeypath"], "m/44h/88h/0h/1/1") else: - assert_equal(change_addrV["hdkeypath"], "m/0'/1'/1'") #second internal child key + assert_equal(change_addrV["hdkeypath"], "m/88'/1'/1'") #second internal child key self.sync_all() assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1) @@ -100,9 +100,9 @@ def run_test(self): hd_add_2 = self.nodes[1].getnewaddress() hd_info_2 = self.nodes[1].getaddressinfo(hd_add_2) if self.options.descriptors: - assert_equal(hd_info_2["hdkeypath"], "m/84h/1h/0h/0/" + str(i)) + assert_equal(hd_info_2["hdkeypath"], "m/44h/88h/0h/0/" + str(i)) else: - assert_equal(hd_info_2["hdkeypath"], "m/0'/0'/" + str(i) + "'") + assert_equal(hd_info_2["hdkeypath"], "m/88'/0'/" + str(i) + "'") assert_equal(hd_info_2["hdmasterfingerprint"], hd_fingerprint) assert_equal(hd_add, hd_add_2) self.connect_nodes(0, 1) @@ -142,9 +142,9 @@ def run_test(self): keypath = self.nodes[1].getaddressinfo(out['scriptPubKey']['address'])['hdkeypath'] if self.options.descriptors: - assert_equal(keypath[0:14], "m/84h/1h/0h/1/") + assert_equal(keypath[0:15], "m/44h/88h/0h/1/") else: - assert_equal(keypath[0:7], "m/0'/1'") + assert_equal(keypath[0:8], "m/88'/1'") if not self.options.descriptors: # Generate a new HD seed on node 1 and make sure it is set @@ -154,7 +154,7 @@ def run_test(self): assert orig_masterkeyid != new_masterkeyid addr = self.nodes[1].getnewaddress() # Make sure the new address is the first from the keypool - assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/0\'') + assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/88\'/0\'/0\'') self.nodes[1].keypoolrefill(1) # Fill keypool with 1 key # Set a new HD seed on node 1 without flushing the keypool @@ -166,14 +166,14 @@ def run_test(self): addr = self.nodes[1].getnewaddress() assert_equal(orig_masterkeyid, self.nodes[1].getaddressinfo(addr)['hdseedid']) # Make sure the new address continues previous keypool - assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/1\'') + assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/88\'/0\'/1\'') # Check that the next address is from the new seed self.nodes[1].keypoolrefill(1) next_addr = self.nodes[1].getnewaddress() assert_equal(new_masterkeyid, self.nodes[1].getaddressinfo(next_addr)['hdseedid']) # Make sure the new address is not from previous keypool - assert_equal(self.nodes[1].getaddressinfo(next_addr)['hdkeypath'], 'm/0\'/0\'/0\'') + assert_equal(self.nodes[1].getaddressinfo(next_addr)['hdkeypath'], 'm/88\'/0\'/0\'') assert next_addr != addr # Sethdseed parameter validity diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py index ad5ae111aa..53fcbff707 100755 --- a/test/functional/wallet_importdescriptors.py +++ b/test/functional/wallet_importdescriptors.py @@ -31,6 +31,7 @@ test_address, ) +from test_framework.qtum import convert_btc_address_to_qtum, convert_btc_bech32_address_to_qtum class ImportDescriptorsTest(BitcoinTestFramework): def add_options(self, parser): self.add_wallet_options(parser, legacy=False) @@ -194,8 +195,8 @@ def run_test(self): # # Test ranged descriptors xpriv = "tprv8ZgxMBicQKsPeuVhWwi6wuMQGfPKi9Li5GtX35jVNknACgqe3CY4g5xgkfDDJcmtF7o1QnxWDRYw4H5P26PXq7sbcUkEqeR4fg3Kxp2tigg" xpub = "tpubD6NzVbkrYhZ4YNXVQbNhMK1WqguFsUXceaVJKbmno2aZ3B6QfbMeraaYvnBSGpV3vxLyTTK9DYT1yoEck4XUScMzXoQ2U2oSmE2JyMedq3H" - addresses = ["2N7yv4p8G8yEaPddJxY41kPihnWvs39qCMf", "2MsHxyb2JS3pAySeNUsJ7mNnurtpeenDzLA"] # hdkeypath=m/0'/0'/0' and 1' - addresses += ["bcrt1qrd3n235cj2czsfmsuvqqpr3lu6lg0ju7scl8gn", "bcrt1qfqeppuvj0ww98r6qghmdkj70tv8qpchehegrg8"] # wpkh subscripts corresponding to the above addresses + addresses = [convert_btc_address_to_qtum(a) for a in ["2N7yv4p8G8yEaPddJxY41kPihnWvs39qCMf", "2MsHxyb2JS3pAySeNUsJ7mNnurtpeenDzLA"]] # hdkeypath=m/0'/0'/0' and 1' + addresses += [convert_btc_bech32_address_to_qtum(a) for a in ["bcrt1qrd3n235cj2czsfmsuvqqpr3lu6lg0ju7scl8gn", "bcrt1qfqeppuvj0ww98r6qghmdkj70tv8qpchehegrg8"]] # wpkh subscripts corresponding to the above addresses desc = "sh(wpkh(" + xpub + "/0/0/*" + "))" self.log.info("Ranged descriptors cannot have labels") @@ -300,11 +301,11 @@ def run_test(self): self.log.info('Key ranges should be imported in order') 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 + convert_btc_bech32_address_to_qtum('bcrt1qtmp74ayg7p24uslctssvjm06q5phz4yrxucgnv'), # m/0'/0'/0 + convert_btc_bech32_address_to_qtum('bcrt1q8vprchan07gzagd5e6v9wd7azyucksq2xc76k8'), # m/0'/0'/1 + convert_btc_bech32_address_to_qtum('bcrt1qtuqdtha7zmqgcrr26n2rqxztv5y8rafjp9lulu'), # m/0'/0'/2 + convert_btc_bech32_address_to_qtum('bcrt1qau64272ymawq26t90md6an0ps99qkrse58m640'), # m/0'/0'/3 + convert_btc_bech32_address_to_qtum('bcrt1qsg97266hrh6cpmutqen8s4s962aryy77jp0fg0'), # m/0'/0'/4 ] self.test_importdesc({'desc': descsum_create('wpkh([80002067/0h/0h]' + xpub + '/*)'), @@ -377,7 +378,7 @@ def run_test(self): }, success=True) address = w1.getrawchangeaddress('legacy') - assert_equal(address, "mpA2Wh9dvZT7yfELq1UnrUmAoc5qCkMetg") + assert_equal(address, convert_btc_address_to_qtum("mpA2Wh9dvZT7yfELq1UnrUmAoc5qCkMetg")) self.log.info('Check can deactivate active descriptor') self.test_importdesc({'desc': descsum_create('pkh([12345678]' + xpub + '/*)'), @@ -396,7 +397,7 @@ def run_test(self): # # Test importing a descriptor containing a WIF private key wif_priv = "cTe1f5rdT8A8DFgVWTjyPwACsDPJM9ff4QngFxUixCSvvbg1x6sh" - address = "2MuhcG52uHPknxDgmGPsV18jSHFBnnRgjPg" + address = convert_btc_address_to_qtum("2MuhcG52uHPknxDgmGPsV18jSHFBnnRgjPg") desc = "sh(wpkh(" + wif_priv + "))" self.log.info("Should import a descriptor with a WIF private key as spendable") self.test_importdesc({"desc": descsum_create(desc), @@ -413,7 +414,8 @@ def run_test(self): ismine=True) txid = w0.sendtoaddress(address, 49.99995540) self.generatetoaddress(self.nodes[0], 6, w0.getnewaddress()) - tx = wpriv.createrawtransaction([{"txid": txid, "vout": 0}], {w0.getnewaddress(): 49.999}) + unspent=wpriv.listunspent()[0] + tx = wpriv.createrawtransaction([{"txid": unspent["txid"], "vout": unspent["vout"]}], {w0.getnewaddress(): 49.96}) signed_tx = wpriv.signrawtransactionwithwallet(tx) w1.sendrawtransaction(signed_tx['hex']) @@ -452,9 +454,9 @@ def run_test(self): assert_equal(wmulti_priv.getwalletinfo()['keypoolsize'], 1001) # Range end (1000) is inclusive, so 1001 addresses generated addr = wmulti_priv.getnewaddress('', 'bech32') # uses receive 0 - assert_equal(addr, 'bcrt1qdt0qy5p7dzhxzmegnn4ulzhard33s2809arjqgjndx87rv5vd0fq2czhy8') # Derived at m/84'/0'/0'/0 + assert_equal(addr, convert_btc_bech32_address_to_qtum('bcrt1qdt0qy5p7dzhxzmegnn4ulzhard33s2809arjqgjndx87rv5vd0fq2czhy8')) # Derived at m/84'/0'/0'/0 change_addr = wmulti_priv.getrawchangeaddress('bech32') # uses change 0 - assert_equal(change_addr, 'bcrt1qt9uhe3a9hnq7vajl7a094z4s3crm9ttf8zw3f5v9gr2nyd7e3lnsy44n8e') # Derived at m/84'/1'/0'/0 + assert_equal(change_addr, convert_btc_bech32_address_to_qtum('bcrt1qt9uhe3a9hnq7vajl7a094z4s3crm9ttf8zw3f5v9gr2nyd7e3lnsy44n8e')) # Derived at m/84'/1'/0'/0 assert_equal(wmulti_priv.getwalletinfo()['keypoolsize'], 1000) txid = w0.sendtoaddress(addr, 10) self.generate(self.nodes[0], 6) @@ -485,9 +487,9 @@ def run_test(self): assert_equal(wmulti_pub.getwalletinfo()['keypoolsize'], 1000) # The first one was already consumed by previous import and is detected as used addr = wmulti_pub.getnewaddress('', 'bech32') # uses receive 1 - assert_equal(addr, 'bcrt1qp8s25ckjl7gr6x2q3dx3tn2pytwp05upkjztk6ey857tt50r5aeqn6mvr9') # Derived at m/84'/0'/0'/1 + assert_equal(addr, convert_btc_bech32_address_to_qtum('bcrt1qp8s25ckjl7gr6x2q3dx3tn2pytwp05upkjztk6ey857tt50r5aeqn6mvr9')) # Derived at m/84'/0'/0'/1 change_addr = wmulti_pub.getrawchangeaddress('bech32') # uses change 2 - assert_equal(change_addr, 'bcrt1qp6j3jw8yetefte7kw6v5pc89rkgakzy98p6gf7ayslaveaxqyjusnw580c') # Derived at m/84'/1'/0'/2 + assert_equal(change_addr, convert_btc_bech32_address_to_qtum('bcrt1qp6j3jw8yetefte7kw6v5pc89rkgakzy98p6gf7ayslaveaxqyjusnw580c')) # Derived at m/84'/1'/0'/2 assert send_txid in self.nodes[0].getrawmempool(True) assert send_txid in (x['txid'] for x in wmulti_pub.listunspent(0)) assert_equal(wmulti_pub.getwalletinfo()['keypoolsize'], 999) @@ -589,7 +591,7 @@ def run_test(self): w0.sendtoaddress(addr, 10) self.generate(self.nodes[0], 1) # It is standard and would relay. - txid = wmulti_priv_big.sendtoaddress(w0.getnewaddress(), 9.999) + txid = wmulti_priv_big.sendtoaddress(w0.getnewaddress(), 9.9) decoded = wmulti_priv_big.gettransaction(txid=txid, verbose=True)['decoded'] # 20 sigs + dummy + witness script assert_equal(len(decoded['vin'][0]['txinwitness']), 22) @@ -668,7 +670,8 @@ def run_test(self): "range": 1, "timestamp": "now"}, success=True, - warnings=["Unknown output type, cannot set descriptor to active."]) + # warnings=["Unknown output type, cannot set descriptor to active."] + ) self.log.info("Test importing a descriptor to an encrypted wallet") diff --git a/test/functional/wallet_importmulti.py b/test/functional/wallet_importmulti.py index 31013f6323..647ebc53f3 100755 --- a/test/functional/wallet_importmulti.py +++ b/test/functional/wallet_importmulti.py @@ -22,6 +22,7 @@ ) from test_framework.test_framework import BitcoinTestFramework from test_framework.descriptors import descsum_create +from test_framework.qtumconfig import * from test_framework.util import ( assert_equal, assert_greater_than, @@ -32,7 +33,7 @@ get_multisig, test_address, ) - +from test_framework.qtum import convert_btc_bech32_address_to_qtum, convert_btc_address_to_qtum class ImportMultiTest(BitcoinTestFramework): def add_options(self, parser): @@ -578,8 +579,8 @@ def run_test(self): # Test ranged descriptor fails if range is not specified xpriv = "tprv8ZgxMBicQKsPeuVhWwi6wuMQGfPKi9Li5GtX35jVNknACgqe3CY4g5xgkfDDJcmtF7o1QnxWDRYw4H5P26PXq7sbcUkEqeR4fg3Kxp2tigg" - addresses = ["2N7yv4p8G8yEaPddJxY41kPihnWvs39qCMf", "2MsHxyb2JS3pAySeNUsJ7mNnurtpeenDzLA"] # hdkeypath=m/0'/0'/0' and 1' - addresses += ["bcrt1qrd3n235cj2czsfmsuvqqpr3lu6lg0ju7scl8gn", "bcrt1qfqeppuvj0ww98r6qghmdkj70tv8qpchehegrg8"] # wpkh subscripts corresponding to the above addresses + addresses = [convert_btc_address_to_qtum("2N7yv4p8G8yEaPddJxY41kPihnWvs39qCMf"), convert_btc_address_to_qtum("2MsHxyb2JS3pAySeNUsJ7mNnurtpeenDzLA")] # hdkeypath=m/0'/0'/0' and 1' + addresses += [convert_btc_bech32_address_to_qtum("bcrt1qrd3n235cj2czsfmsuvqqpr3lu6lg0ju7scl8gn"), convert_btc_bech32_address_to_qtum("bcrt1qfqeppuvj0ww98r6qghmdkj70tv8qpchehegrg8")] # wpkh subscripts corresponding to the above addresses desc = "sh(wpkh(" + xpriv + "/0'/0'/*'" + "))" self.log.info("Ranged descriptor import should fail without a specified range") self.test_importmulti({"desc": descsum_create(desc), @@ -617,7 +618,7 @@ def run_test(self): # Test importing a descriptor containing a WIF private key wif_priv = "cTe1f5rdT8A8DFgVWTjyPwACsDPJM9ff4QngFxUixCSvvbg1x6sh" - address = "2MuhcG52uHPknxDgmGPsV18jSHFBnnRgjPg" + address = convert_btc_address_to_qtum("2MuhcG52uHPknxDgmGPsV18jSHFBnnRgjPg") desc = "sh(wpkh(" + wif_priv + "))" self.log.info("Should import a descriptor with a WIF private key as spendable") self.test_importmulti({"desc": descsum_create(desc), @@ -748,7 +749,7 @@ def run_test(self): self.log.info("Bech32m addresses and descriptors cannot be imported") self.test_importmulti( { - "scriptPubKey": {"address": "bcrt1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqc8gma6"}, + "scriptPubKey": {"address": convert_btc_bech32_address_to_qtum("bcrt1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqc8gma6")}, "timestamp": "now", }, success=False, @@ -859,11 +860,11 @@ def run_test(self): 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 + convert_btc_bech32_address_to_qtum('bcrt1qtmp74ayg7p24uslctssvjm06q5phz4yrxucgnv'), # m/0'/0'/0 + convert_btc_bech32_address_to_qtum('bcrt1q8vprchan07gzagd5e6v9wd7azyucksq2xc76k8'), # m/0'/0'/1 + convert_btc_bech32_address_to_qtum('bcrt1qtuqdtha7zmqgcrr26n2rqxztv5y8rafjp9lulu'), # m/0'/0'/2 + convert_btc_bech32_address_to_qtum('bcrt1qau64272ymawq26t90md6an0ps99qkrse58m640'), # m/0'/0'/3 + convert_btc_bech32_address_to_qtum('bcrt1qsg97266hrh6cpmutqen8s4s962aryy77jp0fg0'), # m/0'/0'/4 ] result = wrpc.importmulti( [{ diff --git a/test/functional/wallet_importprunedfunds.py b/test/functional/wallet_importprunedfunds.py index 5fe7c4b591..92659adc1e 100755 --- a/test/functional/wallet_importprunedfunds.py +++ b/test/functional/wallet_importprunedfunds.py @@ -32,7 +32,7 @@ def skip_test_if_missing_module(self): def run_test(self): self.log.info("Mining blocks...") - self.generate(self.nodes[0], COINBASE_MATURITY + 1) + self.nodes[0].generate(COINBASE_MATURITY + 1) # address address1 = self.nodes[0].getnewaddress() diff --git a/test/functional/wallet_keypool.py b/test/functional/wallet_keypool.py index d2341fb12e..7c835d6175 100755 --- a/test/functional/wallet_keypool.py +++ b/test/functional/wallet_keypool.py @@ -17,6 +17,7 @@ def add_options(self, parser): def set_test_params(self): self.num_nodes = 1 + self.extra_args = [['-addresstype=bech32']] def skip_test_if_missing_module(self): self.skip_if_no_wallet() @@ -90,8 +91,8 @@ def run_test(self): nodes[0].keypoolrefill(6) wi = nodes[0].getwalletinfo() if self.options.descriptors: - assert_equal(wi['keypoolsize_hd_internal'], 24) - assert_equal(wi['keypoolsize'], 24) + assert_equal(wi['keypoolsize_hd_internal'], 30) + assert_equal(wi['keypoolsize'], 30) else: assert_equal(wi['keypoolsize_hd_internal'], 6) assert_equal(wi['keypoolsize'], 6) @@ -135,8 +136,8 @@ def run_test(self): nodes[0].keypoolrefill(100) wi = nodes[0].getwalletinfo() if self.options.descriptors: - assert_equal(wi['keypoolsize_hd_internal'], 400) - assert_equal(wi['keypoolsize'], 400) + assert_equal(wi['keypoolsize_hd_internal'], 500) + assert_equal(wi['keypoolsize'], 500) else: assert_equal(wi['keypoolsize_hd_internal'], 100) assert_equal(wi['keypoolsize'], 100) @@ -152,8 +153,8 @@ def run_test(self): # The new keypath index should be 100 more than the old one new_index = int(start_keypath.rsplit('/', 1)[1][:-1]) + 100 new_change_index = int(start_change_keypath.rsplit('/', 1)[1][:-1]) + 100 - assert_equal(end_keypath, "m/0'/0'/" + str(new_index) + "'") - assert_equal(end_change_keypath, "m/0'/1'/" + str(new_change_index) + "'") + assert_equal(end_keypath, "m/88'/0'/" + str(new_index) + "'") + assert_equal(end_change_keypath, "m/88'/1'/" + str(new_change_index) + "'") # create a blank wallet nodes[0].createwallet(wallet_name='w2', blank=True, disable_private_keys=True) @@ -172,36 +173,36 @@ def run_test(self): assert_equal(res[0]['success'], True) with WalletUnlock(w1, 'test'): - res = w1.sendtoaddress(address=address, amount=0.00010000) + res = w1.sendtoaddress(address=address, amount=0.10000) self.generate(nodes[0], 1) destination = addr.pop() # Using a fee rate (10 sat / byte) well above the minimum relay rate # creating a 5,000 sat transaction with change should not be possible - assert_raises_rpc_error(-4, "Transaction needs a change address, but we can't generate it.", w2.walletcreatefundedpsbt, inputs=[], outputs=[{addr.pop(): 0.00005000}], subtractFeeFromOutputs=[0], feeRate=0.00010) + assert_raises_rpc_error(-4, "Transaction needs a change address, but we can't generate it.", w2.walletcreatefundedpsbt, inputs=[], outputs=[{addr.pop(): 0.05000000}], subtractFeeFromOutputs=[0], feeRate=0.0040) # creating a 10,000 sat transaction without change, with a manual input, should still be possible - res = w2.walletcreatefundedpsbt(inputs=w2.listunspent(), outputs=[{destination: 0.00010000}], subtractFeeFromOutputs=[0], feeRate=0.00010) + res = w2.walletcreatefundedpsbt(inputs=w2.listunspent(), outputs=[{destination: 0.10000000}], subtractFeeFromOutputs=[0], feeRate=0.00010) assert_equal("psbt" in res, True) # creating a 10,000 sat transaction without change should still be possible - res = w2.walletcreatefundedpsbt(inputs=[], outputs=[{destination: 0.00010000}], subtractFeeFromOutputs=[0], feeRate=0.00010) + res = w2.walletcreatefundedpsbt(inputs=[], outputs=[{destination: 0.10000000}], subtractFeeFromOutputs=[0], feeRate=0.0040) assert_equal("psbt" in res, True) # should work without subtractFeeFromOutputs if the exact fee is subtracted from the amount - res = w2.walletcreatefundedpsbt(inputs=[], outputs=[{destination: 0.00008900}], feeRate=0.00010) + res = w2.walletcreatefundedpsbt(inputs=[], outputs=[{destination: 0.09900000}], feeRate=0.0040) assert_equal("psbt" in res, True) # dust change should be removed - res = w2.walletcreatefundedpsbt(inputs=[], outputs=[{destination: 0.00008800}], feeRate=0.00010) + res = w2.walletcreatefundedpsbt(inputs=[], outputs=[{destination: 0.09900}], feeRate=0.0040) assert_equal("psbt" in res, True) # create a transaction without change at the maximum fee rate, such that the output is still spendable: - res = w2.walletcreatefundedpsbt(inputs=[], outputs=[{destination: 0.00010000}], subtractFeeFromOutputs=[0], feeRate=0.0008823) + res = w2.walletcreatefundedpsbt(inputs=[], outputs=[{destination: 0.10000}], subtractFeeFromOutputs=[0], feeRate=0.0008823) assert_equal("psbt" in res, True) assert_equal(res["fee"], Decimal("0.00009706")) # creating a 10,000 sat transaction with a manual change address should be possible - res = w2.walletcreatefundedpsbt(inputs=[], outputs=[{destination: 0.00010000}], subtractFeeFromOutputs=[0], feeRate=0.00010, changeAddress=addr.pop()) + res = w2.walletcreatefundedpsbt(inputs=[], outputs=[{destination: 0.010000}], subtractFeeFromOutputs=[0], feeRate=0.0040, changeAddress=addr.pop()) assert_equal("psbt" in res, True) if not self.options.descriptors: diff --git a/test/functional/wallet_keypool_topup.py b/test/functional/wallet_keypool_topup.py index 48180e8294..4f41f7041c 100755 --- a/test/functional/wallet_keypool_topup.py +++ b/test/functional/wallet_keypool_topup.py @@ -82,13 +82,13 @@ def run_test(self): # Check that we have marked all keys up to the used keypool key as used if self.options.descriptors: if output_type == 'legacy': - assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/44h/1h/0h/0/110") + assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/44h/88h/0h/0/110") elif output_type == 'p2sh-segwit': - assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/49h/1h/0h/0/110") + assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/49h/88h/0h/0/110") elif output_type == 'bech32': - assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/84h/1h/0h/0/110") + assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/84h/88h/0h/0/110") else: - assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/0'/0'/110'") + assert_equal(self.nodes[idx].getaddressinfo(self.nodes[idx].getnewaddress(address_type=output_type))['hdkeypath'], "m/88'/0'/110'") if __name__ == '__main__': diff --git a/test/functional/wallet_labels.py b/test/functional/wallet_labels.py index f074339a2b..e8f0fbf1d5 100755 --- a/test/functional/wallet_labels.py +++ b/test/functional/wallet_labels.py @@ -16,6 +16,8 @@ from test_framework.util import assert_equal, assert_raises_rpc_error from test_framework.wallet_util import test_address +from test_framework.qtumconfig import COINBASE_MATURITY, INITIAL_BLOCK_REWARD +from test_framework.qtum import convert_btc_address_to_qtum, convert_btc_bech32_address_to_qtum class WalletLabelsTest(BitcoinTestFramework): def add_options(self, parser): @@ -79,7 +81,7 @@ def run_test(self): # the same address, so we call twice to get two addresses w/50 each self.generatetoaddress(node, nblocks=1, address=node.getnewaddress(label='coinbase')) self.generatetoaddress(node, nblocks=COINBASE_MATURITY + 1, address=node.getnewaddress(label='coinbase')) - assert_equal(node.getbalance(), 100) + assert_equal(node.getbalance(), 2*INITIAL_BLOCK_REWARD) # there should be 2 address groups # each with 1 address with a balance of 50 Bitcoins @@ -91,14 +93,14 @@ def run_test(self): for address_group in address_groups: assert_equal(len(address_group), 1) assert_equal(len(address_group[0]), 3) - assert_equal(address_group[0][1], 50) + assert_equal(address_group[0][1], INITIAL_BLOCK_REWARD) assert_equal(address_group[0][2], 'coinbase') linked_addresses.add(address_group[0][0]) # send 50 from each address to a third address not in this wallet - common_address = "msf4WtN1YQKXvNtvdFYt9JBnUD2FB41kjr" + common_address = convert_btc_address_to_qtum("msf4WtN1YQKXvNtvdFYt9JBnUD2FB41kjr") node.sendmany( - amounts={common_address: 100}, + amounts={common_address: 2*INITIAL_BLOCK_REWARD}, subtractfeefrom=[common_address], minconf=1, ) @@ -157,6 +159,7 @@ def run_test(self): assert_equal(node.getreceivedbylabel(label.name), 2) label.verify(node) self.generate(node, COINBASE_MATURITY + 1) + expected_account_balances = {"": 504*INITIAL_BLOCK_REWARD} # Check that setlabel can assign a label to a new unused address. for label in labels: @@ -194,13 +197,13 @@ def run_test(self): node.createwallet(wallet_name='watch_only', disable_private_keys=True) wallet_watch_only = node.get_wallet_rpc('watch_only') BECH32_VALID = { - '✔️_VER15_PROG40': 'bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqxkg7fn', - '✔️_VER16_PROG03': 'bcrt1sqqqqq8uhdgr', - '✔️_VER16_PROB02': 'bcrt1sqqqq4wstyw', + '✔️_VER15_PROG40': convert_btc_bech32_address_to_qtum('bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqxkg7fn'), + '✔️_VER16_PROG03': convert_btc_bech32_address_to_qtum('bcrt1sqqqqq8uhdgr'), + '✔️_VER16_PROB02': convert_btc_bech32_address_to_qtum('bcrt1sqqqq4wstyw'), } BECH32_INVALID = { - '❌_VER15_PROG41': 'bcrt1sqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqajlxj8', - '❌_VER16_PROB01': 'bcrt1sqq5r4036', + '❌_VER15_PROG41': convert_btc_bech32_address_to_qtum('bcrt1sqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqajlxj8'), + '❌_VER16_PROB01': convert_btc_bech32_address_to_qtum('bcrt1sqq5r4036'), } for l in BECH32_VALID: ad = BECH32_VALID[l] @@ -212,7 +215,7 @@ def run_test(self): ad = BECH32_INVALID[l] assert_raises_rpc_error( -5, - "Address is not valid" if self.options.descriptors else "Invalid Bitcoin address or script", + "Address is not valid" if self.options.descriptors else "Invalid Qtum address or script", lambda: wallet_watch_only.importaddress(label=l, rescan=False, address=ad), ) diff --git a/test/functional/wallet_listdescriptors.py b/test/functional/wallet_listdescriptors.py index 712b881322..594e26a545 100755 --- a/test/functional/wallet_listdescriptors.py +++ b/test/functional/wallet_listdescriptors.py @@ -49,8 +49,8 @@ def run_test(self): node.createwallet(wallet_name='w3', descriptors=True) result = node.get_wallet_rpc('w3').listdescriptors() assert_equal("w3", result['wallet_name']) - assert_equal(8, len(result['descriptors'])) - assert_equal(8, len([d for d in result['descriptors'] if d['active']])) + assert_equal(10, len(result['descriptors'])) + assert_equal(10, len([d for d in result['descriptors'] if d['active']])) assert_equal(4, len([d for d in result['descriptors'] if d['internal']])) for item in result['descriptors']: assert item['desc'] != '' diff --git a/test/functional/wallet_listreceivedby.py b/test/functional/wallet_listreceivedby.py index 8ec21484d1..dadc5dca52 100755 --- a/test/functional/wallet_listreceivedby.py +++ b/test/functional/wallet_listreceivedby.py @@ -179,7 +179,7 @@ def run_test(self): label = "label" address = self.nodes[0].getnewaddress(label) - reward = Decimal("25") + reward = Decimal("20000") self.generatetoaddress(self.nodes[0], 1, address) hash = self.nodes[0].getbestblockhash() diff --git a/test/functional/wallet_listsinceblock.py b/test/functional/wallet_listsinceblock.py index a19a3ac2cb..dd93ae481a 100755 --- a/test/functional/wallet_listsinceblock.py +++ b/test/functional/wallet_listsinceblock.py @@ -17,6 +17,7 @@ from test_framework.wallet_util import generate_keypair from decimal import Decimal +from test_framework.qtum import generatesynchronized class ListSinceBlockTest(BitcoinTestFramework): def add_options(self, parser): @@ -35,7 +36,7 @@ def run_test(self): # All nodes are in IBD from genesis, so they'll need the miner (node2) to be an outbound connection, or have # only one connection. (See fPreferredDownload in net_processing) self.connect_nodes(1, 2) - self.generate(self.nodes[2], COINBASE_MATURITY + 1) + generatesynchronized(self.nodes[2], COINBASE_MATURITY+1, None, self.nodes) self.test_no_blockhash() self.test_invalid_blockhash() @@ -214,9 +215,9 @@ def test_double_spend(self): self.split_network() # send from nodes[1] using utxo to nodes[0] - change = '%.8f' % (float(utxo['amount']) - 1.0003) + change = '%.8f' % (float(utxo['amount']) - 1.03) recipient_dict = { - self.nodes[0].getnewaddress(): 1, + self.nodes[0].getnewaddress("", "bech32"): 1, self.nodes[1].getnewaddress(): change, } utxo_dicts = [{ @@ -290,7 +291,7 @@ def test_double_send(self): # create and sign a transaction utxos = self.nodes[2].listunspent() utxo = utxos[0] - change = '%.8f' % (float(utxo['amount']) - 1.0003) + change = '%.8f' % (float(utxo['amount']) - 1.03) recipient_dict = { self.nodes[0].getnewaddress(): 1, self.nodes[2].getnewaddress(): change, @@ -356,8 +357,8 @@ def double_spends_filtered(self): tx_input = dict( sequence=MAX_BIP125_RBF_SEQUENCE, **next(u for u in spending_node.listunspent())) rawtx = spending_node.createrawtransaction( - [tx_input], {dest_address: tx_input["amount"] - Decimal("0.00051000"), - spending_node.getrawchangeaddress(): Decimal("0.00050000")}) + [tx_input], {dest_address: tx_input["amount"] - Decimal("0.05100000"), + spending_node.getrawchangeaddress(): Decimal("0.05000000")}) signedtx = spending_node.signrawtransactionwithwallet(rawtx) orig_tx_id = spending_node.sendrawtransaction(signedtx["hex"]) original_tx = spending_node.gettransaction(orig_tx_id) diff --git a/test/functional/wallet_miniscript.py b/test/functional/wallet_miniscript.py index d174b525b3..8de38cac1d 100755 --- a/test/functional/wallet_miniscript.py +++ b/test/functional/wallet_miniscript.py @@ -209,6 +209,9 @@ def add_options(self, parser): def set_test_params(self): self.num_nodes = 1 + self.extra_args = [ + ["-addresstype=bech32"], + ] def skip_test_if_missing_module(self): self.skip_if_no_wallet() @@ -241,7 +244,7 @@ def watchonly_test(self, desc): ) self.log.info("Testing we detect funds sent to one of them") - addr = self.ms_wo_wallet.getnewaddress() + addr = self.ms_wo_wallet.getnewaddress(address_type="bech32") txid = self.funder.sendtoaddress(addr, 0.01) self.wait_until( lambda: len(self.ms_wo_wallet.listunspent(minconf=0, addresses=[addr])) == 1 diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py index 10bc516d8f..d7385e60b6 100755 --- a/test/functional/wallet_multiwallet.py +++ b/test/functional/wallet_multiwallet.py @@ -23,6 +23,7 @@ assert_raises_rpc_error, get_rpc_proxy, ) +from test_framework.qtumconfig import INITIAL_BLOCK_REWARD got_loading_error = False @@ -197,7 +198,7 @@ def wallet_file(name): assert_equal(set(node.listwallets()), {"w4", "w5"}) w5 = wallet("w5") w5_info = w5.getwalletinfo() - assert_equal(w5_info['immature_balance'], 50) + assert_equal(w5_info['immature_balance'], INITIAL_BLOCK_REWARD) competing_wallet_dir = os.path.join(self.options.tmpdir, 'competing_walletdir') os.mkdir(competing_wallet_dir) @@ -222,7 +223,7 @@ def wallet_file(name): self.generatetoaddress(node, nblocks=1, address=wallets[0].getnewaddress(), sync_fun=self.no_op) for wallet_name, wallet in zip(wallet_names, wallets): info = wallet.getwalletinfo() - assert_equal(info['immature_balance'], 50 if wallet is wallets[0] else 0) + assert_equal(info['immature_balance'], INITIAL_BLOCK_REWARD if wallet is wallets[0] else 0) assert_equal(info['walletname'], wallet_name) # accessing invalid wallet fails @@ -233,7 +234,7 @@ def wallet_file(name): w1, w2, w3, w4, *_ = wallets self.generatetoaddress(node, nblocks=COINBASE_MATURITY + 1, address=w1.getnewaddress(), sync_fun=self.no_op) - assert_equal(w1.getbalance(), 100) + assert_equal(w1.getbalance(), 2 * INITIAL_BLOCK_REWARD) assert_equal(w2.getbalance(), 0) assert_equal(w3.getbalance(), 0) assert_equal(w4.getbalance(), 0) @@ -253,9 +254,9 @@ def wallet_file(name): self.log.info('Check for per-wallet settxfee call') assert_equal(w1.getwalletinfo()['paytxfee'], 0) assert_equal(w2.getwalletinfo()['paytxfee'], 0) - w2.settxfee(0.001) + w2.settxfee(0.01) assert_equal(w1.getwalletinfo()['paytxfee'], 0) - assert_equal(w2.getwalletinfo()['paytxfee'], Decimal('0.00100000')) + assert_equal(w2.getwalletinfo()['paytxfee'], Decimal('0.0100000')) self.log.info("Test dynamic wallet loading") diff --git a/test/functional/wallet_reorgsrestore.py b/test/functional/wallet_reorgsrestore.py index 86a2905c72..52e2bd7cec 100755 --- a/test/functional/wallet_reorgsrestore.py +++ b/test/functional/wallet_reorgsrestore.py @@ -57,8 +57,8 @@ def run_test(self): outputs_2 = {} # Create a conflicted tx broadcast on node0 chain and conflicting tx broadcast on node1 chain. Both spend from txid_conflict_from - outputs_1[self.nodes[0].getnewaddress()] = Decimal("9.99998") - outputs_2[self.nodes[0].getnewaddress()] = Decimal("9.99998") + outputs_1[self.nodes[0].getnewaddress()] = Decimal("9.998") + outputs_2[self.nodes[0].getnewaddress()] = Decimal("9.998") conflicted = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs, outputs_1)) conflicting = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs, outputs_2)) diff --git a/test/functional/wallet_signer.py b/test/functional/wallet_signer.py index 32a1887153..d523419da4 100755 --- a/test/functional/wallet_signer.py +++ b/test/functional/wallet_signer.py @@ -16,6 +16,8 @@ assert_greater_than, assert_raises_rpc_error, ) +from test_framework.qtum import convert_btc_bech32_address_to_qtum, convert_btc_address_to_qtum +from test_framework.segwit_addr import Encoding class WalletSignerTest(BitcoinTestFramework): @@ -102,28 +104,28 @@ def test_valid_signer(self): assert_equal(hww.getwalletinfo()["keypoolsize"], 40) address1 = hww.getnewaddress(address_type="bech32") - assert_equal(address1, "bcrt1qm90ugl4d48jv8n6e5t9ln6t9zlpm5th68x4f8g") + assert_equal(address1, convert_btc_bech32_address_to_qtum("bcrt1qm90ugl4d48jv8n6e5t9ln6t9zlpm5th68x4f8g")) address_info = hww.getaddressinfo(address1) assert_equal(address_info['solvable'], True) assert_equal(address_info['ismine'], True) assert_equal(address_info['hdkeypath'], "m/84h/1h/0h/0/0") address2 = hww.getnewaddress(address_type="p2sh-segwit") - assert_equal(address2, "2N2gQKzjUe47gM8p1JZxaAkTcoHPXV6YyVp") + assert_equal(address2, convert_btc_address_to_qtum("2N2gQKzjUe47gM8p1JZxaAkTcoHPXV6YyVp")) address_info = hww.getaddressinfo(address2) assert_equal(address_info['solvable'], True) assert_equal(address_info['ismine'], True) assert_equal(address_info['hdkeypath'], "m/49h/1h/0h/0/0") address3 = hww.getnewaddress(address_type="legacy") - assert_equal(address3, "n1LKejAadN6hg2FrBXoU1KrwX4uK16mco9") + assert_equal(address3, convert_btc_address_to_qtum("n1LKejAadN6hg2FrBXoU1KrwX4uK16mco9")) address_info = hww.getaddressinfo(address3) assert_equal(address_info['solvable'], True) assert_equal(address_info['ismine'], True) assert_equal(address_info['hdkeypath'], "m/44h/1h/0h/0/0") address4 = hww.getnewaddress(address_type="bech32m") - assert_equal(address4, "bcrt1phw4cgpt6cd30kz9k4wkpwm872cdvhss29jga2xpmftelhqll62ms4e9sqj") + assert_equal(address4, convert_btc_bech32_address_to_qtum("bcrt1phw4cgpt6cd30kz9k4wkpwm872cdvhss29jga2xpmftelhqll62ms4e9sqj", encoding=Encoding.BECH32M)) address_info = hww.getaddressinfo(address4) assert_equal(address_info['solvable'], True) assert_equal(address_info['ismine'], True) @@ -167,7 +169,7 @@ def test_valid_signer(self): assert_equal(result[1], {'success': True}) assert_equal(mock_wallet.getwalletinfo()["txcount"], 1) dest = self.nodes[0].getnewaddress(address_type='bech32') - mock_psbt = mock_wallet.walletcreatefundedpsbt([], {dest:0.5}, 0, {'replaceable': True}, True)['psbt'] + mock_psbt = mock_wallet.walletcreatefundedpsbt([], {dest:0.5}, 0, {'replaceable': True, 'change_type': 'bech32'}, True)['psbt'] mock_psbt_signed = mock_wallet.walletprocesspsbt(psbt=mock_psbt, sign=True, sighashtype="ALL", bip32derivs=True) mock_tx = mock_psbt_signed["hex"] assert mock_wallet.testmempoolaccept([mock_tx])[0]["allowed"] diff --git a/test/functional/wallet_signrawtransactionwithwallet.py b/test/functional/wallet_signrawtransactionwithwallet.py index d560dfdc11..463ce3e347 100755 --- a/test/functional/wallet_signrawtransactionwithwallet.py +++ b/test/functional/wallet_signrawtransactionwithwallet.py @@ -33,6 +33,7 @@ getcontext, ) +from test_framework.qtum import convert_btc_address_to_qtum RAW_TX = '020000000156b958f78e3f24e0b2f4e4db1255426b0902027cb37e3ddadb52e37c3557dddb0000000000ffffffff01c0a6b929010000001600149a2ee8c77140a053f36018ac8124a6ececc1668a00000000' @@ -88,7 +89,7 @@ def script_verification_error_test(self): 'scriptPubKey': 'badbadbadbad'} ] - outputs = {'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB': 0.1} + outputs = {convert_btc_address_to_qtum('mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB'): 0.1} rawTx = self.nodes[0].createrawtransaction(inputs, outputs) @@ -198,7 +199,7 @@ def test_signing_with_csv(self): vout = find_vout_for_address(self.nodes[0], txid, address) self.generate(self.nodes[0], 1) utxo = self.nodes[0].listunspent()[0] - amt = Decimal(1) + utxo["amount"] - Decimal(0.00001) + amt = Decimal(1) + utxo["amount"] - Decimal(0.001) tx = self.nodes[0].createrawtransaction( [{"txid": txid, "vout": vout, "sequence": 1},{"txid": utxo["txid"], "vout": utxo["vout"]}], [{self.nodes[0].getnewaddress(): amt}], @@ -233,7 +234,7 @@ def test_signing_with_cltv(self): vout = find_vout_for_address(self.nodes[0], txid, address) self.generate(self.nodes[0], 1) utxo = self.nodes[0].listunspent()[0] - amt = Decimal(1) + utxo["amount"] - Decimal(0.00001) + amt = Decimal(1) + utxo["amount"] - Decimal(0.001) tx = self.nodes[0].createrawtransaction( [{"txid": txid, "vout": vout},{"txid": utxo["txid"], "vout": utxo["vout"]}], [{self.nodes[0].getnewaddress(): amt}],