Skip to content

Commit 9b85a5e

Browse files
committed
tests: Test for dumpwallet lock order issue
Adds a test for the condition which can trigger a lock order assertion. Specifically, there must be an unconfirmed transaction in the mempool which belongs to the wallet being loaded. This will establish the order of cs_wallet -> cs_main -> cs_KeyStore. Then dumpwallet is called on that wallet. Previously, this would have used a lock order of cs_wallet -> cs_KeyStore -> cs_main, but this should be fixed now. The test ensures that.
1 parent 25d99e6 commit 9b85a5e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/functional/wallet_dump.py

+9
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ def run_test(self):
209209
with self.nodes[0].assert_debug_log(['Flushing wallet.dat'], timeout=20):
210210
self.nodes[0].getnewaddress()
211211

212+
# Make sure that dumpwallet doesn't have a lock order issue when there is an unconfirmed tx and it is reloaded
213+
# See https://github.com/bitcoin/bitcoin/issues/22489
214+
self.nodes[0].createwallet("w3")
215+
w3 = self.nodes[0].get_wallet_rpc("w3")
216+
w3.importprivkey(privkey=self.nodes[0].get_deterministic_priv_key().key, label="coinbase_import")
217+
w3.sendtoaddress(w3.getnewaddress(), 10)
218+
w3.unloadwallet()
219+
self.nodes[0].loadwallet("w3")
220+
w3.dumpwallet(os.path.join(self.nodes[0].datadir, "w3.dump"))
212221

213222
if __name__ == '__main__':
214223
WalletDumpTest().main()

0 commit comments

Comments
 (0)