@@ -193,7 +193,7 @@ def wait_for_bitcoind_start(process, url, i):
193
193
raise # unkown JSON RPC exception
194
194
time .sleep (0.25 )
195
195
196
- def initialize_chain (test_dir , num_nodes ):
196
+ def initialize_chain (test_dir , num_nodes , cachedir ):
197
197
"""
198
198
Create a cache of a 200-block-long chain (with wallet) for MAX_NODES
199
199
Afterward, create num_nodes copies from the cache
@@ -202,20 +202,20 @@ def initialize_chain(test_dir, num_nodes):
202
202
assert num_nodes <= MAX_NODES
203
203
create_cache = False
204
204
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 ))):
206
206
create_cache = True
207
207
break
208
208
209
209
if create_cache :
210
210
211
211
#find and delete old cache directories if any exist
212
212
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 )))
215
215
216
216
# Create cache directories, run bitcoinds:
217
217
for i in range (MAX_NODES ):
218
- datadir = initialize_datadir ("cache" , i )
218
+ datadir = initialize_datadir (cachedir , i )
219
219
args = [ os .getenv ("BITCOIND" , "bitcoind" ), "-server" , "-keypool=1" , "-datadir=" + datadir , "-discover=0" ]
220
220
if i > 0 :
221
221
args .append ("-connect=127.0.0.1:" + str (p2p_port (0 )))
@@ -257,13 +257,13 @@ def initialize_chain(test_dir, num_nodes):
257
257
wait_bitcoinds ()
258
258
disable_mocktime ()
259
259
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" ))
264
264
265
265
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 ))
267
267
to_dir = os .path .join (test_dir , "node" + str (i ))
268
268
shutil .copytree (from_dir , to_dir )
269
269
initialize_datadir (test_dir , i ) # Overwrite port/rpcport in bitcoin.conf
0 commit comments