Skip to content

Commit

Permalink
test: wallet_backup.py, fix intermittent failure in "restore using du…
Browse files Browse the repository at this point in the history
…mped wallet"

The failure arises because the test expects 'init_wallet()' (the test
framework function) creating a wallet with no keys. However, the function
also imports the deterministic private key used to receive the coinbase coins.

This causes a race within the "restore using dumped wallet" case, where we
intend to have a new wallet (with no existing keys) to test the
'importwallet()' RPC result.
The reason behind the intermittent failures might be other peers delivering
the chain right after node2 startup (sync of the validation queue included)
and prior to the 'node2.getbalance()' check.
  • Loading branch information
furszy committed Aug 23, 2023
1 parent 8372ab0 commit c4929cf
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/functional/wallet_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ def restore_wallet_existent_name(self):
assert_raises_rpc_error(-36, error_message, node.restorewallet, wallet_name, backup_file)
assert os.path.exists(wallet_file)

def init_three(self):
self.init_wallet(node=0)
self.init_wallet(node=1)
self.init_wallet(node=2)

def run_test(self):
self.log.info("Generating initial blockchain")
self.generate(self.nodes[0], 1)
Expand Down Expand Up @@ -230,7 +225,10 @@ def run_test(self):
shutil.rmtree(os.path.join(self.nodes[2].chain_path, 'chainstate'))

self.start_three(["-nowallet"])
self.init_three()
# Create new wallets for the three nodes.
# We will use this empty wallets to test the 'importwallet()' RPC command below.
for node_num in range(3):
self.nodes[node_num].createwallet(wallet_name=self.default_wallet_name, descriptors=self.options.descriptors, load_on_startup=True)

assert_equal(self.nodes[0].getbalance(), 0)
assert_equal(self.nodes[1].getbalance(), 0)
Expand Down

0 comments on commit c4929cf

Please sign in to comment.