From 9b85a5e2f7e003ca8621feaac9bdd304d19081b4 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Sun, 18 Jul 2021 23:06:08 -0400 Subject: 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. --- test/functional/wallet_dump.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/functional/wallet_dump.py b/test/functional/wallet_dump.py index eb54da99f5..91d6121679 100755 --- a/test/functional/wallet_dump.py +++ b/test/functional/wallet_dump.py @@ -209,6 +209,15 @@ class WalletDumpTest(BitcoinTestFramework): with self.nodes[0].assert_debug_log(['Flushing wallet.dat'], timeout=20): self.nodes[0].getnewaddress() + # 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") + w3 = self.nodes[0].get_wallet_rpc("w3") + w3.importprivkey(privkey=self.nodes[0].get_deterministic_priv_key().key, label="coinbase_import") + w3.sendtoaddress(w3.getnewaddress(), 10) + w3.unloadwallet() + self.nodes[0].loadwallet("w3") + w3.dumpwallet(os.path.join(self.nodes[0].datadir, "w3.dump")) if __name__ == '__main__': WalletDumpTest().main() -- cgit v1.2.3