mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 17:24:58 +02:00
test: functional: drop rmtree usage and add lint check
`shutil.rmtree` is dangerous because it recursively deletes. There are not likely to be any issues with it's current uses, but it is possible that some of the assumptions being made now won't always be true, e.g. about what some of the variables being passed to `rmtree` represent. For some remaining uses of rmtree that can't be avoided for now, use `cleanup_dir` which asserts that the recursively deleted folder is a child of the the `tmpdir` of the test run. Otherwise, `tempfile.TemporaryDirectory` should be used which does it's own deleting on being garbage collected, or old fashioned unlinking and rmdir in the case of directories with known contents.
This commit is contained in:
@@ -303,7 +303,8 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
||||
# Copy back to master
|
||||
wallet.unloadwallet()
|
||||
if n == node:
|
||||
shutil.rmtree(node_master.wallets_path / wallet_name)
|
||||
(node_master.wallets_path / wallet_name / "wallet.dat").unlink()
|
||||
(node_master.wallets_path / wallet_name).rmdir()
|
||||
shutil.copytree(
|
||||
n.wallets_path / wallet_name,
|
||||
node_master.wallets_path / wallet_name,
|
||||
|
||||
Reference in New Issue
Block a user