I like this new test, but I think it can be improved in a couple of ways:
- test that a non-empty file without the magic bytes is excluded
- there’s an implicit assumption that the symlink and folder created earlier in the test are still around. You could explicitly assert that. If the earlier parts of this test get change, eg the file names are changed, then this check will continue to succeed but won’t be testing anything.
What do you think about:
0--- a/test/functional/multiwallet.py
1+++ b/test/functional/multiwallet.py
2@@ -65,8 +65,20 @@ class MultiWalletTest(BitcoinTestFramework):
3 self.start_node(0, self.extra_args[0])
4
5 # ensure listwallets only names BDB files, not symlinks, other files or directories
6- open(os.path.join(wallet_dir, 'w01.dat'), 'a').close()
7- assert_equal(set(self.nodes[0].listwallets()['available']), {"w22"})
8+ with open(os.path.join(wallet_dir, 'w01.dat'), 'a') as wallet_file:
9+ # Create a file containing a long string
10+ print("a" * 2000, file=wallet_file)
11+
12+ available_wallets = self.nodes[0].listwallets()['available']
13+
14+ assert os.path.islink(os.path.join(wallet_dir, 'w12'))
15+ assert 'w12' not in available_wallets
16+
17+ assert os.path.isdir(os.path.join(wallet_dir, 'w11'))
18+ assert 'w11' not in available_wallets
19+
20+ assert os.path.isfile(os.path.join(wallet_dir, 'w01.dat'))
21+ assert 'w01.dat' not in available_wallets