Skip to content

Commit

Permalink
bcoin test: add wallet directory and .conf see issue bcoin-org/bcoin#645
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed Nov 26, 2019
1 parent 1bc9988 commit 9270d7b
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,30 +292,46 @@ def rpc_url(datadir, i, chain, rpchost):
################

def initialize_datadir(dirname, n, chain):
datadir = get_datadir_path(dirname, n)
if not os.path.isdir(datadir):
os.makedirs(datadir)
# Translate chain name to config name
if chain == 'testnet3':
chain_name_conf_arg = 'testnet'
chain_name_conf_section = 'test'
else:
chain_name_conf_arg = chain
chain_name_conf_section = chain
with open(os.path.join(datadir, "bitcoin.conf"), 'w', encoding='utf8') as f:
f.write("{}=1\n".format(chain_name_conf_arg))
f.write("[{}]\n".format(chain_name_conf_section))
f.write("port=" + str(p2p_port(n)) + "\n")
f.write("rpcport=" + str(rpc_port(n)) + "\n")
f.write("server=1\n")
f.write("keypool=1\n")
f.write("discover=0\n")
f.write("dnsseed=0\n")
f.write("listenonion=0\n")
f.write("printtoconsole=0\n")
f.write("upnp=0\n")

datadir = get_datadir_path(dirname, n)
if not os.path.isdir(datadir):
os.makedirs(datadir)
walletdatadir = os.path.join(datadir, chain_name_conf_arg)
if not os.path.isdir(walletdatadir):
os.makedirs(walletdatadir)

with open(os.path.join(datadir, "bcoin.conf"), 'w', encoding='utf8') as f:
f.write("network: {}".format(chain_name_conf_arg) + "\n")
# f.write("[{}]\n".format(chain_name_conf_section))
f.write("port: " + str(p2p_port(n)) + "\n")
f.write("http-port: " + str(rpc_port(n)) + "\n")
f.write("rpcuser: user" + str(rpc_port(n)) + "\n")
f.write("rpcpassword: pass" + str(rpc_port(n)) + "\n")
f.write("api-key: pass" + str(rpc_port(n)) + "\n")
f.write("log-level: spam" + "\n")
# f.write("fallbackfee: 0.0002\n")
# f.write("server=1\n")
# f.write("keypool=1\n")
# f.write("discover=0\n")
# f.write("dnsseed=0\n")
# f.write("listenonion=0\n")
# f.write("printtoconsole=0\n")
# f.write("upnp=0\n")
# f.write("shrinkdebugfile=0\n")
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
with open(os.path.join(walletdatadir, "wallet.conf"), 'w', encoding='utf8') as f:
f.write("network: {}".format(chain_name_conf_arg) + "\n")
f.write("http-port: " + str(rpc_port(n) + 1000) + "\n")
f.write("prefix: " + datadir + "\n")

return datadir

def get_datadir_path(dirname, n):
Expand Down

0 comments on commit 9270d7b

Please sign in to comment.