Skip to content

Commit c4929cf

Browse files
committed
test: wallet_backup.py, fix intermittent failure in "restore using dumped 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.
1 parent 8372ab0 commit c4929cf

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

test/functional/wallet_backup.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@ def restore_wallet_existent_name(self):
140140
assert_raises_rpc_error(-36, error_message, node.restorewallet, wallet_name, backup_file)
141141
assert os.path.exists(wallet_file)
142142

143-
def init_three(self):
144-
self.init_wallet(node=0)
145-
self.init_wallet(node=1)
146-
self.init_wallet(node=2)
147-
148143
def run_test(self):
149144
self.log.info("Generating initial blockchain")
150145
self.generate(self.nodes[0], 1)
@@ -230,7 +225,10 @@ def run_test(self):
230225
shutil.rmtree(os.path.join(self.nodes[2].chain_path, 'chainstate'))
231226

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

235233
assert_equal(self.nodes[0].getbalance(), 0)
236234
assert_equal(self.nodes[1].getbalance(), 0)

0 commit comments

Comments
 (0)