aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_dump.py
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2021-07-18 23:06:08 -0400
committerAndrew Chow <achow101-github@achow101.com>2021-07-19 12:25:11 -0400
commit9b85a5e2f7e003ca8621feaac9bdd304d19081b4 (patch)
tree20d5936850ecd2ae274cf30eb03b43110addce56 /test/functional/wallet_dump.py
parent25d99e6511d8c43b2025a89bcd8295de755346a7 (diff)
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.
Diffstat (limited to 'test/functional/wallet_dump.py')
-rwxr-xr-xtest/functional/wallet_dump.py9
1 files changed, 9 insertions, 0 deletions
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()