diff --git a/test/functional/feature_dbcrash.py b/test/functional/feature_dbcrash.py --- a/test/functional/feature_dbcrash.py +++ b/test/functional/feature_dbcrash.py @@ -79,6 +79,7 @@ def setup_network(self): self.add_nodes(self.num_nodes, extra_args=self.extra_args) self.start_nodes() + self.import_deterministic_coinbase_privkeys() # Leave them unconnected, we'll use submitblock directly in this test def restart_node(self, node_index, expected_tip): diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -125,6 +125,11 @@ def setup_nodes(self): self.add_nodes(self.num_nodes, self.extra_args) self.start_nodes() + for n in self.nodes: + n.importprivkey( + privkey=n.get_deterministic_priv_key().key, + label='coinbase', + rescan=False) def create_big_chain(self): # Start by creating some coinbases we can spend later diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py --- a/test/functional/interface_zmq.py +++ b/test/functional/interface_zmq.py @@ -70,6 +70,7 @@ ] self.add_nodes(self.num_nodes, self.extra_args) self.start_nodes() + self.import_deterministic_coinbase_privkeys() def run_test(self): try: diff --git a/test/functional/p2p_node_network_limited.py b/test/functional/p2p_node_network_limited.py --- a/test/functional/p2p_node_network_limited.py +++ b/test/functional/p2p_node_network_limited.py @@ -65,8 +65,8 @@ disconnect_nodes(self.nodes[1], self.nodes[2]) def setup_network(self): - super(NodeNetworkLimitedTest, self).setup_network() - self.disconnect_all() + self.add_nodes(self.num_nodes, self.extra_args) + self.start_nodes() def run_test(self): node = self.nodes[0].add_p2p_connection(P2PIgnoreInv()) diff --git a/test/functional/rpc_signrawtransaction.py b/test/functional/rpc_signrawtransaction.py --- a/test/functional/rpc_signrawtransaction.py +++ b/test/functional/rpc_signrawtransaction.py @@ -14,8 +14,7 @@ class SignRawTransactionsTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True - self.num_nodes = 2 - self.extra_args = [[], ["-wallet=w1", "-wallet=w2"]] + self.num_nodes = 1 def skip_test_if_missing_module(self): self.skip_if_no_wallet() @@ -216,7 +215,7 @@ outputs = {'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB': 0.1} - multiwallet_node = self.nodes[1] + multiwallet_node = self.nodes[0] rawTx = multiwallet_node.createrawtransaction(inputs, outputs) @@ -248,9 +247,13 @@ self.successful_signing_test() self.script_verification_error_test() self.test_sighashes() - self.multiwallet_signing_test() self.test_with_lock_outputs() + # The multiwalet require the node to use different flags, so we run it + # last. + self.restart_node(0, ["-wallet=w1", "-wallet=w2"]) + self.multiwallet_signing_test() + if __name__ == '__main__': SignRawTransactionsTest().main() diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -162,7 +162,6 @@ self.skip_test_if_missing_module() self.setup_chain() self.setup_network() - self.import_deterministic_coinbase_privkeys() self.run_test() success = TestStatus.PASSED except JSONRPCException: @@ -259,11 +258,9 @@ extra_args = self.extra_args self.add_nodes(self.num_nodes, extra_args) self.start_nodes() + self.import_deterministic_coinbase_privkeys() def import_deterministic_coinbase_privkeys(self): - if self.setup_clean_chain: - return - for n in self.nodes: try: n.getwalletinfo() @@ -271,7 +268,9 @@ assert str(e).startswith('Method not found') continue - n.importprivkey(n.get_deterministic_priv_key().key) + n.importprivkey( + privkey=n.get_deterministic_priv_key().key, + label='coinbase') def run_test(self): """Tests must override this method to define test logic""" diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -273,26 +273,6 @@ def generate(self, nblocks, maxtries=1000000): self.log.debug( "TestNode.generate() dispatches `generate` call to `generatetoaddress`") - # Try to import the node's deterministic private key. This is a no-op if the private key - # has already been imported. - try: - if self.rpc is not None: - self.rpc.importprivkey( - privkey=self.get_deterministic_priv_key().key, - label='coinbase', - rescan=False) - except JSONRPCException as e: - # This may fail if: - # - wallet is disabled ('Method not found') - # - there are multiple wallets to import to ('Wallet file not specified') - # - wallet is locked ('Error: Please enter the wallet passphrase with walletpassphrase first') - # Just ignore those errors. We can make this tidier by importing the privkey during TestFramework.setup_nodes - # TODO: tidy up deterministic privkey import. - assert str(e).startswith('Method not found') or \ - str(e).startswith('Wallet file not specified') or \ - str(e).startswith( - 'Error: Please enter the wallet passphrase with walletpassphrase first') - return self.generatetoaddress( nblocks=nblocks, address=self.get_deterministic_priv_key().address, maxtries=maxtries) diff --git a/test/functional/tool_wallet.py b/test/functional/tool_wallet.py --- a/test/functional/tool_wallet.py +++ b/test/functional/tool_wallet.py @@ -78,7 +78,7 @@ HD (hd seed available): yes Keypool Size: 2 Transactions: 0 - Address Book: 0 + Address Book: 1 ''') self.assert_tool_output(out, '-wallet=wallet.dat', 'info') diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -32,10 +32,9 @@ self.skip_if_no_wallet() def setup_network(self): - self.add_nodes(4) - self.start_node(0, self.extra_args[0]) - self.start_node(1, self.extra_args[1]) - self.start_node(2, self.extra_args[2]) + self.setup_nodes() + # Only need nodes 0-2 running at start of test + self.stop_node(3) connect_nodes_bi(self.nodes[0], self.nodes[1]) connect_nodes_bi(self.nodes[1], self.nodes[2]) connect_nodes_bi(self.nodes[0], self.nodes[2]) diff --git a/test/functional/wallet_import_rescan.py b/test/functional/wallet_import_rescan.py --- a/test/functional/wallet_import_rescan.py +++ b/test/functional/wallet_import_rescan.py @@ -161,16 +161,16 @@ # Import keys with pruning disabled self.start_nodes(extra_args=[[]] * self.num_nodes) - super().import_deterministic_coinbase_privkeys() + for n in self.nodes: + n.importprivkey( + privkey=n.get_deterministic_priv_key().key, + label='coinbase') self.stop_nodes() self.start_nodes() for i in range(1, self.num_nodes): connect_nodes(self.nodes[i], self.nodes[0]) - def import_deterministic_coinbase_privkeys(self): - pass - def run_test(self): # Create one transaction on node 0 with a unique amount for # each possible type of wallet import RPC. diff --git a/test/functional/wallet_listreceivedby.py b/test/functional/wallet_listreceivedby.py --- a/test/functional/wallet_listreceivedby.py +++ b/test/functional/wallet_listreceivedby.py @@ -19,13 +19,6 @@ def set_test_params(self): self.num_nodes = 2 - def import_deterministic_coinbase_privkeys(self): - assert_equal(0, len(self.nodes[1].listreceivedbyaddress( - minconf=0, include_empty=True, include_watchonly=True))) - super().import_deterministic_coinbase_privkeys() - self.num_cb_reward_addresses = len(self.nodes[1].listreceivedbyaddress( - minconf=0, include_empty=True, include_watchonly=True)) - def skip_test_if_missing_module(self): self.skip_if_no_wallet() self.skip_if_no_cli() @@ -35,6 +28,13 @@ self.nodes[0].generate(1) sync_blocks(self.nodes) + # save the number of coinbase reward addresses so far + num_cb_reward_addresses = len( + self.nodes[1].listreceivedbyaddress( + minconf=0, + include_empty=True, + include_watchonly=True)) + self.log.info("listreceivedbyaddress Test") # Send from node 0 to 1 @@ -82,7 +82,7 @@ # Another address receive money res = self.nodes[1].listreceivedbyaddress(0, True, True) # Right now 2 entries - assert_equal(len(res), 2 + self.num_cb_reward_addresses) + assert_equal(len(res), 2 + num_cb_reward_addresses) other_addr = self.nodes[1].getnewaddress() txid2 = self.nodes[0].sendtoaddress(other_addr, 0.1) self.nodes[0].generate(1) @@ -102,7 +102,7 @@ # Should be two entries though without filter res = self.nodes[1].listreceivedbyaddress(0, True, True) # Became 3 entries - assert_equal(len(res), 3 + self.num_cb_reward_addresses) + assert_equal(len(res), 3 + num_cb_reward_addresses) # Not on random addr # note on node[0]! just a random addr