1313 connect_nodes ,
1414)
1515
16+ # Linux allow all characters other than \x00
17+ # Windows disallow control characters (0-31) and /\?%:|"<>
18+ FILE_CHAR_START = 32 if os .name == 'nt' else 1
19+ FILE_CHAR_END = 128
20+ FILE_CHAR_BLACKLIST = '/\\ ?%*:|"<>' if os .name == 'nt' else '/'
1621
1722class NotificationsTest (BitcoinTestFramework ):
1823 def set_test_params (self ):
1924 self .num_nodes = 2
2025 self .setup_clean_chain = True
2126
2227 def setup_network (self ):
28+ self .wallet = '' .join (chr (i ) for i in range (FILE_CHAR_START , FILE_CHAR_END ) if chr (i ) not in FILE_CHAR_BLACKLIST )
2329 self .alertnotify_dir = os .path .join (self .options .tmpdir , "alertnotify" )
2430 self .blocknotify_dir = os .path .join (self .options .tmpdir , "blocknotify" )
2531 self .walletnotify_dir = os .path .join (self .options .tmpdir , "walletnotify" )
@@ -33,7 +39,8 @@ def setup_network(self):
3339 "-blocknotify=echo > {}" .format (os .path .join (self .blocknotify_dir , '%s' ))],
3440 ["-blockversion=211" ,
3541 "-rescan" ,
36- "-walletnotify=echo > {}" .format (os .path .join (self .walletnotify_dir , '%s' ))]]
42+ "-wallet={}" .format (self .wallet ),
43+ "-walletnotify=echo > {}" .format (os .path .join (self .walletnotify_dir , '%w_%s' ))]]
3744 super ().setup_network ()
3845
3946 def run_test (self ):
@@ -53,7 +60,7 @@ def run_test(self):
5360 wait_until (lambda : len (os .listdir (self .walletnotify_dir )) == block_count , timeout = 10 )
5461
5562 # directory content should equal the generated transaction hashes
56- txids_rpc = list (map (lambda t : t ['txid' ], self .nodes [1 ].listtransactions ("*" , block_count )))
63+ txids_rpc = list (map (lambda t : '{}_{}' . format ( self . wallet , t ['txid' ]) , self .nodes [1 ].listtransactions ("*" , block_count )))
5764 assert_equal (sorted (txids_rpc ), sorted (os .listdir (self .walletnotify_dir )))
5865 self .stop_node (1 )
5966 for tx_file in os .listdir (self .walletnotify_dir ):
@@ -67,7 +74,7 @@ def run_test(self):
6774 wait_until (lambda : len (os .listdir (self .walletnotify_dir )) == block_count , timeout = 10 )
6875
6976 # directory content should equal the generated transaction hashes
70- txids_rpc = list (map (lambda t : t ['txid' ], self .nodes [1 ].listtransactions ("*" , block_count )))
77+ txids_rpc = list (map (lambda t : '{}_{}' . format ( self . wallet , t ['txid' ]) , self .nodes [1 ].listtransactions ("*" , block_count )))
7178 assert_equal (sorted (txids_rpc ), sorted (os .listdir (self .walletnotify_dir )))
7279
7380 # TODO: add test for `-alertnotify` large fork notifications
0 commit comments