From b7113e6f42c220792c2a9808943b714eb72c4f3e Mon Sep 17 00:00:00 2001 From: Robert Hamilton Date: Sat, 5 Sep 2026 19:58:40 -0500 Subject: [PATCH] test: characterize disabled wallet settings Wallet RPCs report errors with -nosettings after changing wallet state. Check these results alongside wallet usability, unchanged settings.json, and restored startup preferences when settings are enabled again. Reuse an existing wallet for loading and check explicit unloading last, so the sequence does not depend on the skipped unload completion wait. --- test/functional/wallet_startup.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/functional/wallet_startup.py b/test/functional/wallet_startup.py index 2c5fb259059..bc281c23b50 100755 --- a/test/functional/wallet_startup.py +++ b/test/functional/wallet_startup.py @@ -64,6 +64,35 @@ class WalletStartupTest(BitcoinTestFramework): # Reset directory permissions for cleanup dir_path.chmod(original_dir_perms) + def test_disabled_settings(self, node): + self.log.info("Test wallet startup preferences with dynamic settings disabled") + load_message = "Attempt to write settings file when dynamic settings are disabled." + + settings_path = node.chain_path / "settings.json" + settings_before = settings_path.read_bytes() + self.restart_node(0, extra_args=["-nosettings"]) + assert_equal(node.listwallets(), ['']) + + assert_raises_rpc_error(-1, load_message, node.createwallet, wallet_name="no_settings", load_on_startup=True) # TODO: Report a warning after creating the wallet + assert_equal(set(node.listwallets()), {'', 'no_settings'}) + + # Leaving the startup preference unchanged does not warn, and the wallet remains usable. + assert_equal(node.unloadwallet(wallet_name="no_settings"), {}) + assert_equal(node.loadwallet(filename="no_settings"), {"name": "no_settings"}) + assert_equal(node.get_wallet_rpc("no_settings").getwalletinfo()["walletname"], "no_settings") + + assert_raises_rpc_error(-1, load_message, node.loadwallet, filename="w2", load_on_startup=True) # TODO: Report a warning after loading the wallet + assert_equal(set(node.listwallets()), {'', 'no_settings', 'w2'}) + + assert_raises_rpc_error(-1, "Attempt to write settings file when dynamic settings are disabled.", node.unloadwallet, wallet_name="no_settings", load_on_startup=False) # TODO: Report a warning after unloading the wallet + assert_equal(set(node.listwallets()), {'', 'w2'}) + self.stop_node(0) + assert_equal(settings_path.read_bytes(), settings_before) + + # Re-enabling settings restores the original startup preferences. + self.start_node(0) + assert_equal(set(node.listwallets()), {'w2', 'w3'}) + def run_test(self): self.log.info('Should start without any wallets') assert_equal(self.nodes[0].listwallets(), []) @@ -94,6 +123,7 @@ class WalletStartupTest(BitcoinTestFramework): assert_equal(set(self.nodes[0].listwallets()), set(('w2', 'w3'))) self.test_load_unwritable_wallet(self.nodes[0]) + self.test_disabled_settings(self.nodes[0]) if __name__ == '__main__': WalletStartupTest(__file__).main()