test: Pass down correct chain name in tests
This commit is contained in:
parent
aed15edf17
commit
fa31dc1bf4
3 changed files with 12 additions and 4 deletions
|
@ -111,7 +111,7 @@ class P2PConnection(asyncio.Protocol):
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
return self._transport is not None
|
return self._transport is not None
|
||||||
|
|
||||||
def peer_connect(self, dstaddr, dstport, net="regtest"):
|
def peer_connect(self, dstaddr, dstport, *, net):
|
||||||
assert not self.is_connected
|
assert not self.is_connected
|
||||||
self.dstaddr = dstaddr
|
self.dstaddr = dstaddr
|
||||||
self.dstport = dstport
|
self.dstport = dstport
|
||||||
|
|
|
@ -480,7 +480,7 @@ class TestNode():
|
||||||
if 'dstaddr' not in kwargs:
|
if 'dstaddr' not in kwargs:
|
||||||
kwargs['dstaddr'] = '127.0.0.1'
|
kwargs['dstaddr'] = '127.0.0.1'
|
||||||
|
|
||||||
p2p_conn.peer_connect(**kwargs)()
|
p2p_conn.peer_connect(**kwargs, net=self.chain)()
|
||||||
self.p2ps.append(p2p_conn)
|
self.p2ps.append(p2p_conn)
|
||||||
if wait_for_verack:
|
if wait_for_verack:
|
||||||
p2p_conn.wait_for_verack()
|
p2p_conn.wait_for_verack()
|
||||||
|
|
|
@ -283,14 +283,22 @@ def initialize_datadir(dirname, n, chain):
|
||||||
datadir = get_datadir_path(dirname, n)
|
datadir = get_datadir_path(dirname, n)
|
||||||
if not os.path.isdir(datadir):
|
if not os.path.isdir(datadir):
|
||||||
os.makedirs(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:
|
with open(os.path.join(datadir, "bitcoin.conf"), 'w', encoding='utf8') as f:
|
||||||
f.write("{}=1\n".format(chain))
|
f.write("{}=1\n".format(chain_name_conf_arg))
|
||||||
f.write("[{}]\n".format(chain))
|
f.write("[{}]\n".format(chain_name_conf_section))
|
||||||
f.write("port=" + str(p2p_port(n)) + "\n")
|
f.write("port=" + str(p2p_port(n)) + "\n")
|
||||||
f.write("rpcport=" + str(rpc_port(n)) + "\n")
|
f.write("rpcport=" + str(rpc_port(n)) + "\n")
|
||||||
f.write("server=1\n")
|
f.write("server=1\n")
|
||||||
f.write("keypool=1\n")
|
f.write("keypool=1\n")
|
||||||
f.write("discover=0\n")
|
f.write("discover=0\n")
|
||||||
|
f.write("dnsseed=0\n")
|
||||||
f.write("listenonion=0\n")
|
f.write("listenonion=0\n")
|
||||||
f.write("printtoconsole=0\n")
|
f.write("printtoconsole=0\n")
|
||||||
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
|
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
|
||||||
|
|
Loading…
Add table
Reference in a new issue