@@ -193,7 +193,7 @@ def wait_for_bitcoind_start(process, url, i):
193193 raise # unkown JSON RPC exception
194194 time .sleep (0.25 )
195195
196- def initialize_chain (test_dir , num_nodes ):
196+ def initialize_chain (test_dir , num_nodes , cachedir ):
197197 """
198198 Create a cache of a 200-block-long chain (with wallet) for MAX_NODES
199199 Afterward, create num_nodes copies from the cache
@@ -202,20 +202,20 @@ def initialize_chain(test_dir, num_nodes):
202202 assert num_nodes <= MAX_NODES
203203 create_cache = False
204204 for i in range (MAX_NODES ):
205- if not os .path .isdir (os .path .join ('cache' , 'node' + str (i ))):
205+ if not os .path .isdir (os .path .join (cachedir , 'node' + str (i ))):
206206 create_cache = True
207207 break
208208
209209 if create_cache :
210210
211211 #find and delete old cache directories if any exist
212212 for i in range (MAX_NODES ):
213- if os .path .isdir (os .path .join ("cache" ,"node" + str (i ))):
214- shutil .rmtree (os .path .join ("cache" ,"node" + str (i )))
213+ if os .path .isdir (os .path .join (cachedir ,"node" + str (i ))):
214+ shutil .rmtree (os .path .join (cachedir ,"node" + str (i )))
215215
216216 # Create cache directories, run bitcoinds:
217217 for i in range (MAX_NODES ):
218- datadir = initialize_datadir ("cache" , i )
218+ datadir = initialize_datadir (cachedir , i )
219219 args = [ os .getenv ("BITCOIND" , "bitcoind" ), "-server" , "-keypool=1" , "-datadir=" + datadir , "-discover=0" ]
220220 if i > 0 :
221221 args .append ("-connect=127.0.0.1:" + str (p2p_port (0 )))
@@ -257,13 +257,13 @@ def initialize_chain(test_dir, num_nodes):
257257 wait_bitcoinds ()
258258 disable_mocktime ()
259259 for i in range (MAX_NODES ):
260- os .remove (log_filename ("cache" , i , "debug.log" ))
261- os .remove (log_filename ("cache" , i , "db.log" ))
262- os .remove (log_filename ("cache" , i , "peers.dat" ))
263- os .remove (log_filename ("cache" , i , "fee_estimates.dat" ))
260+ os .remove (log_filename (cachedir , i , "debug.log" ))
261+ os .remove (log_filename (cachedir , i , "db.log" ))
262+ os .remove (log_filename (cachedir , i , "peers.dat" ))
263+ os .remove (log_filename (cachedir , i , "fee_estimates.dat" ))
264264
265265 for i in range (num_nodes ):
266- from_dir = os .path .join ("cache" , "node" + str (i ))
266+ from_dir = os .path .join (cachedir , "node" + str (i ))
267267 to_dir = os .path .join (test_dir , "node" + str (i ))
268268 shutil .copytree (from_dir , to_dir )
269269 initialize_datadir (test_dir , i ) # Overwrite port/rpcport in bitcoin.conf
0 commit comments