test: add coverage for wallet creation in non-writable directory

This commit is contained in:
furszy
2025-12-29 14:34:09 -05:00
parent bc0090f1d6
commit 0218966c0d
2 changed files with 31 additions and 0 deletions

View File

@@ -749,3 +749,13 @@ def wallet_importprivkey(wallet_rpc, privkey, timestamp, *, label=""):
}]
import_res = wallet_rpc.importdescriptors(req)
assert_equal(import_res[0]["success"], True)
def is_dir_writable(dir_path: pathlib.Path) -> bool:
"""Return True if we can create a file in the directory, False otherwise"""
try:
tmp = dir_path / f".tmp_{random.randrange(1 << 32)}"
tmp.touch()
tmp.unlink()
return True
except OSError:
return False