|
|
@ -193,7 +193,7 @@ def wait_for_bitcoind_start(process, url, i): |
|
|
|
raise # unkown JSON RPC exception |
|
|
|
raise # unkown JSON RPC exception |
|
|
|
time.sleep(0.25) |
|
|
|
time.sleep(0.25) |
|
|
|
|
|
|
|
|
|
|
|
def initialize_chain(test_dir, num_nodes): |
|
|
|
def initialize_chain(test_dir, num_nodes, cachedir): |
|
|
|
""" |
|
|
|
""" |
|
|
|
Create a cache of a 200-block-long chain (with wallet) for MAX_NODES |
|
|
|
Create a cache of a 200-block-long chain (with wallet) for MAX_NODES |
|
|
|
Afterward, create num_nodes copies from the cache |
|
|
|
Afterward, create num_nodes copies from the cache |
|
|
@ -202,7 +202,7 @@ def initialize_chain(test_dir, num_nodes): |
|
|
|
assert num_nodes <= MAX_NODES |
|
|
|
assert num_nodes <= MAX_NODES |
|
|
|
create_cache = False |
|
|
|
create_cache = False |
|
|
|
for i in range(MAX_NODES): |
|
|
|
for i in range(MAX_NODES): |
|
|
|
if not os.path.isdir(os.path.join('cache', 'node'+str(i))): |
|
|
|
if not os.path.isdir(os.path.join(cachedir, 'node'+str(i))): |
|
|
|
create_cache = True |
|
|
|
create_cache = True |
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
@ -210,12 +210,12 @@ def initialize_chain(test_dir, num_nodes): |
|
|
|
|
|
|
|
|
|
|
|
#find and delete old cache directories if any exist |
|
|
|
#find and delete old cache directories if any exist |
|
|
|
for i in range(MAX_NODES): |
|
|
|
for i in range(MAX_NODES): |
|
|
|
if os.path.isdir(os.path.join("cache","node"+str(i))): |
|
|
|
if os.path.isdir(os.path.join(cachedir,"node"+str(i))): |
|
|
|
shutil.rmtree(os.path.join("cache","node"+str(i))) |
|
|
|
shutil.rmtree(os.path.join(cachedir,"node"+str(i))) |
|
|
|
|
|
|
|
|
|
|
|
# Create cache directories, run bitcoinds: |
|
|
|
# Create cache directories, run bitcoinds: |
|
|
|
for i in range(MAX_NODES): |
|
|
|
for i in range(MAX_NODES): |
|
|
|
datadir=initialize_datadir("cache", i) |
|
|
|
datadir=initialize_datadir(cachedir, i) |
|
|
|
args = [ os.getenv("BITCOIND", "bitcoind"), "-server", "-keypool=1", "-datadir="+datadir, "-discover=0" ] |
|
|
|
args = [ os.getenv("BITCOIND", "bitcoind"), "-server", "-keypool=1", "-datadir="+datadir, "-discover=0" ] |
|
|
|
if i > 0: |
|
|
|
if i > 0: |
|
|
|
args.append("-connect=127.0.0.1:"+str(p2p_port(0))) |
|
|
|
args.append("-connect=127.0.0.1:"+str(p2p_port(0))) |
|
|
@ -257,13 +257,13 @@ def initialize_chain(test_dir, num_nodes): |
|
|
|
wait_bitcoinds() |
|
|
|
wait_bitcoinds() |
|
|
|
disable_mocktime() |
|
|
|
disable_mocktime() |
|
|
|
for i in range(MAX_NODES): |
|
|
|
for i in range(MAX_NODES): |
|
|
|
os.remove(log_filename("cache", i, "debug.log")) |
|
|
|
os.remove(log_filename(cachedir, i, "debug.log")) |
|
|
|
os.remove(log_filename("cache", i, "db.log")) |
|
|
|
os.remove(log_filename(cachedir, i, "db.log")) |
|
|
|
os.remove(log_filename("cache", i, "peers.dat")) |
|
|
|
os.remove(log_filename(cachedir, i, "peers.dat")) |
|
|
|
os.remove(log_filename("cache", i, "fee_estimates.dat")) |
|
|
|
os.remove(log_filename(cachedir, i, "fee_estimates.dat")) |
|
|
|
|
|
|
|
|
|
|
|
for i in range(num_nodes): |
|
|
|
for i in range(num_nodes): |
|
|
|
from_dir = os.path.join("cache", "node"+str(i)) |
|
|
|
from_dir = os.path.join(cachedir, "node"+str(i)) |
|
|
|
to_dir = os.path.join(test_dir, "node"+str(i)) |
|
|
|
to_dir = os.path.join(test_dir, "node"+str(i)) |
|
|
|
shutil.copytree(from_dir, to_dir) |
|
|
|
shutil.copytree(from_dir, to_dir) |
|
|
|
initialize_datadir(test_dir, i) # Overwrite port/rpcport in bitcoin.conf |
|
|
|
initialize_datadir(test_dir, i) # Overwrite port/rpcport in bitcoin.conf |
|
|
|