More debugging trying to make getblockcount work and not have komodod hang the test

This commit is contained in:
Jonathan "Duke" Leto
2018-08-07 09:22:40 +02:00
parent 32829f6d6f
commit 5ec4373ca4
2 changed files with 18 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, assert_greater_than, \ from test_framework.util import assert_equal, assert_greater_than, \
initialize_chain_clean, start_nodes, start_node, connect_nodes_bi, \ initialize_chain_clean, start_nodes, start_node, connect_nodes_bi, \
stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port
import time import time
from decimal import Decimal from decimal import Decimal
@@ -24,7 +24,11 @@ class CryptoConditionsTest (BitcoinTestFramework):
self.pubkey = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" self.pubkey = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D"
self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9"
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
extra_args=[[ extra_args=[[
'-regtest',
'-server=1',
'-rpcport=64368',
'-conf='+self.options.tmpdir+'/node0/REGTEST.conf',
'-ac_name=REGTEST', '-ac_name=REGTEST',
'-addressindex=1', '-addressindex=1',
'-spentindex=1', '-spentindex=1',

View File

@@ -76,6 +76,7 @@ def initialize_datadir(dirname, n):
datadir = os.path.join(dirname, "node"+str(n)) datadir = os.path.join(dirname, "node"+str(n))
if not os.path.isdir(datadir): if not os.path.isdir(datadir):
os.makedirs(datadir) os.makedirs(datadir)
print("Writing to " + os.path.join(datadir,"komodo.conf"))
with open(os.path.join(datadir, "komodo.conf"), 'w') as f: with open(os.path.join(datadir, "komodo.conf"), 'w') as f:
f.write("regtest=1\n"); f.write("regtest=1\n");
f.write("txindex=1\n"); f.write("txindex=1\n");
@@ -84,7 +85,9 @@ def initialize_datadir(dirname, n):
f.write("rpcuser=rt\n"); f.write("rpcuser=rt\n");
f.write("rpcpassword=rt\n"); f.write("rpcpassword=rt\n");
f.write("port="+str(p2p_port(n))+"\n"); f.write("port="+str(p2p_port(n))+"\n");
f.write("rpcport="+str(rpc_port(n))+"\n"); rpcport = str(rpc_port(n))
f.write("rpcport="+rpcport+"\n");
print "RPC port=" + rpcport
f.write("listenonion=0\n"); f.write("listenonion=0\n");
# TODO: maybe make these optional, defaulted to on for now # TODO: maybe make these optional, defaulted to on for now
f.write("addressindex=1\n"); f.write("addressindex=1\n");
@@ -108,10 +111,12 @@ def initialize_chain(test_dir):
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)))
bitcoind_processes[i] = subprocess.Popen(args) bitcoind_processes[i] = subprocess.Popen(args)
cmd = os.getenv("BITCOINCLI", "komodo-cli")
cmd_args = cmd + " -datadir="+datadir + " -rpcwait getblockcount"
if os.getenv("PYTHON_DEBUG", ""): if os.getenv("PYTHON_DEBUG", ""):
print "initialize_chain: komodod started, calling komodo-cli -rpcwait getblockcount" print "initialize_chain: komodod started, calling: " + cmd_args
subprocess.check_call([ os.getenv("BITCOINCLI", "komodo-cli"), "-datadir="+datadir, subprocess.check_call([ cmd, "-datadir="+datadir,
"-rpcwait", "getblockcount"], stdout=devnull) "-rpcwait", "getblockcount"]) #, stdout=devnull)
if os.getenv("PYTHON_DEBUG", ""): if os.getenv("PYTHON_DEBUG", ""):
print "initialize_chain: komodo-cli -rpcwait getblockcount completed" print "initialize_chain: komodo-cli -rpcwait getblockcount completed"
devnull.close() devnull.close()
@@ -193,8 +198,10 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
if extra_args is not None: args.extend(extra_args) if extra_args is not None: args.extend(extra_args)
bitcoind_processes[i] = subprocess.Popen(args) bitcoind_processes[i] = subprocess.Popen(args)
devnull = open("/dev/null", "w+") devnull = open("/dev/null", "w+")
cmd = os.getenv("BITCOINCLI", "komodo-cli")
cmd_args = cmd + "-datadir="+datadir + " -rpcwait getblockcount"
if os.getenv("PYTHON_DEBUG", ""): if os.getenv("PYTHON_DEBUG", ""):
print "start_node: komodod started, calling komodo-cli -rpcwait getblockcount" print "start_node: komodod started, calling : " + cmd_args
subprocess.check_call([ os.getenv("BITCOINCLI", "komodo-cli"), "-datadir="+datadir] + subprocess.check_call([ os.getenv("BITCOINCLI", "komodo-cli"), "-datadir="+datadir] +
_rpchost_to_args(rpchost) + _rpchost_to_args(rpchost) +
["-rpcwait", "getblockcount"], stdout=devnull) ["-rpcwait", "getblockcount"], stdout=devnull)