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 '/'
21+
22+
23+ def notify_outputname (walletname , txid ):
24+ return txid if os .name == 'nt' else '{}_{}' .format (walletname , txid )
25+
1626
1727class NotificationsTest (BitcoinTestFramework ):
1828 def set_test_params (self ):
1929 self .num_nodes = 2
2030 self .setup_clean_chain = True
2131
2232 def setup_network (self ):
33+ self .wallet = '' .join (chr (i ) for i in range (FILE_CHAR_START , FILE_CHAR_END ) if chr (i ) not in FILE_CHAR_BLACKLIST )
2334 self .alertnotify_dir = os .path .join (self .options .tmpdir , "alertnotify" )
2435 self .blocknotify_dir = os .path .join (self .options .tmpdir , "blocknotify" )
2536 self .walletnotify_dir = os .path .join (self .options .tmpdir , "walletnotify" )
@@ -33,7 +44,8 @@ def setup_network(self):
3344 "-blocknotify=echo > {}" .format (os .path .join (self .blocknotify_dir , '%s' ))],
3445 ["-blockversion=211" ,
3546 "-rescan" ,
36- "-walletnotify=echo > {}" .format (os .path .join (self .walletnotify_dir , '%s' ))]]
47+ "-wallet={}" .format (self .wallet ),
48+ "-walletnotify=echo > {}" .format (os .path .join (self .walletnotify_dir , notify_outputname ('%w' , '%s' )))]]
3749 super ().setup_network ()
3850
3951 def run_test (self ):
@@ -53,7 +65,7 @@ def run_test(self):
5365 wait_until (lambda : len (os .listdir (self .walletnotify_dir )) == block_count , timeout = 10 )
5466
5567 # directory content should equal the generated transaction hashes
56- txids_rpc = list (map (lambda t : t ['txid' ], self .nodes [1 ].listtransactions ("*" , block_count )))
68+ txids_rpc = list (map (lambda t : notify_outputname ( self . wallet , t ['txid' ]) , self .nodes [1 ].listtransactions ("*" , block_count )))
5769 assert_equal (sorted (txids_rpc ), sorted (os .listdir (self .walletnotify_dir )))
5870 self .stop_node (1 )
5971 for tx_file in os .listdir (self .walletnotify_dir ):
@@ -67,7 +79,7 @@ def run_test(self):
6779 wait_until (lambda : len (os .listdir (self .walletnotify_dir )) == block_count , timeout = 10 )
6880
6981 # directory content should equal the generated transaction hashes
70- txids_rpc = list (map (lambda t : t ['txid' ], self .nodes [1 ].listtransactions ("*" , block_count )))
82+ txids_rpc = list (map (lambda t : notify_outputname ( self . wallet , t ['txid' ]) , self .nodes [1 ].listtransactions ("*" , block_count )))
7183 assert_equal (sorted (txids_rpc ), sorted (os .listdir (self .walletnotify_dir )))
7284
7385 # TODO: add test for `-alertnotify` large fork notifications
0 commit comments