|
|
@ -24,8 +24,8 @@ from .util import ( |
|
|
|
check_json_precision, |
|
|
|
check_json_precision, |
|
|
|
connect_nodes_bi, |
|
|
|
connect_nodes_bi, |
|
|
|
disconnect_nodes, |
|
|
|
disconnect_nodes, |
|
|
|
|
|
|
|
get_datadir_path, |
|
|
|
initialize_datadir, |
|
|
|
initialize_datadir, |
|
|
|
log_filename, |
|
|
|
|
|
|
|
p2p_port, |
|
|
|
p2p_port, |
|
|
|
set_node_times, |
|
|
|
set_node_times, |
|
|
|
sync_blocks, |
|
|
|
sync_blocks, |
|
|
@ -374,7 +374,7 @@ class BitcoinTestFramework(): |
|
|
|
assert self.num_nodes <= MAX_NODES |
|
|
|
assert self.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(self.options.cachedir, 'node' + str(i))): |
|
|
|
if not os.path.isdir(get_datadir_path(self.options.cachedir, i)): |
|
|
|
create_cache = True |
|
|
|
create_cache = True |
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
@ -383,8 +383,8 @@ class BitcoinTestFramework(): |
|
|
|
|
|
|
|
|
|
|
|
# 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(self.options.cachedir, "node" + str(i))): |
|
|
|
if os.path.isdir(get_datadir_path(self.options.cachedir, i)): |
|
|
|
shutil.rmtree(os.path.join(self.options.cachedir, "node" + str(i))) |
|
|
|
shutil.rmtree(get_datadir_path(self.options.cachedir, i)) |
|
|
|
|
|
|
|
|
|
|
|
# Create cache directories, run bitcoinds: |
|
|
|
# Create cache directories, run bitcoinds: |
|
|
|
for i in range(MAX_NODES): |
|
|
|
for i in range(MAX_NODES): |
|
|
@ -422,15 +422,18 @@ class BitcoinTestFramework(): |
|
|
|
self.stop_nodes() |
|
|
|
self.stop_nodes() |
|
|
|
self.nodes = [] |
|
|
|
self.nodes = [] |
|
|
|
self.disable_mocktime() |
|
|
|
self.disable_mocktime() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cache_path(n, *paths): |
|
|
|
|
|
|
|
return os.path.join(get_datadir_path(self.options.cachedir, n), "regtest", *paths) |
|
|
|
|
|
|
|
|
|
|
|
for i in range(MAX_NODES): |
|
|
|
for i in range(MAX_NODES): |
|
|
|
os.remove(log_filename(self.options.cachedir, i, "debug.log")) |
|
|
|
for entry in os.listdir(cache_path(i)): |
|
|
|
os.remove(log_filename(self.options.cachedir, i, "wallets/db.log")) |
|
|
|
if entry not in ['wallets', 'chainstate', 'blocks']: |
|
|
|
os.remove(log_filename(self.options.cachedir, i, "peers.dat")) |
|
|
|
os.remove(cache_path(i, entry)) |
|
|
|
os.remove(log_filename(self.options.cachedir, i, "fee_estimates.dat")) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in range(self.num_nodes): |
|
|
|
for i in range(self.num_nodes): |
|
|
|
from_dir = os.path.join(self.options.cachedir, "node" + str(i)) |
|
|
|
from_dir = get_datadir_path(self.options.cachedir, i) |
|
|
|
to_dir = os.path.join(self.options.tmpdir, "node" + str(i)) |
|
|
|
to_dir = get_datadir_path(self.options.tmpdir, i) |
|
|
|
shutil.copytree(from_dir, to_dir) |
|
|
|
shutil.copytree(from_dir, to_dir) |
|
|
|
initialize_datadir(self.options.tmpdir, i) # Overwrite port/rpcport in bitcoin.conf |
|
|
|
initialize_datadir(self.options.tmpdir, i) # Overwrite port/rpcport in bitcoin.conf |
|
|
|
|
|
|
|
|
|
|
|