mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Drop redirect_stderr and pass stderr instead
This commit is contained in:
parent
badfdb451c
commit
23114cdb20
@ -250,7 +250,7 @@ class DIP3Test(BitcoinTestFramework):
|
|||||||
while len(self.nodes) <= mn.idx:
|
while len(self.nodes) <= mn.idx:
|
||||||
self.nodes.append(None)
|
self.nodes.append(None)
|
||||||
extra_args = ['-masternode=1', '-masternodeblsprivkey=%s' % mn.blsMnkey]
|
extra_args = ['-masternode=1', '-masternodeblsprivkey=%s' % mn.blsMnkey]
|
||||||
n = start_node(mn.idx, self.options.tmpdir, self.extra_args + extra_args, redirect_stderr=True)
|
n = start_node(mn.idx, self.options.tmpdir, self.extra_args + extra_args, stderr=sys.stdout)
|
||||||
self.nodes[mn.idx] = n
|
self.nodes[mn.idx] = n
|
||||||
for i in range(0, self.num_nodes):
|
for i in range(0, self.num_nodes):
|
||||||
if i < len(self.nodes) and self.nodes[i] is not None and i != mn.idx:
|
if i < len(self.nodes) and self.nodes[i] is not None and i != mn.idx:
|
||||||
|
@ -15,7 +15,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
self.num_nodes = 4
|
self.num_nodes = 4
|
||||||
|
|
||||||
def setup_network(self, split=False):
|
def setup_network(self, split=False):
|
||||||
self.nodes = start_nodes(4, self.options.tmpdir, [['-usehd=1']] * self.num_nodes, redirect_stderr=True)
|
self.nodes = start_nodes(4, self.options.tmpdir, [['-usehd=1']] * self.num_nodes, stderr=sys.stdout)
|
||||||
|
|
||||||
connect_nodes_bi(self.nodes,0,1)
|
connect_nodes_bi(self.nodes,0,1)
|
||||||
connect_nodes_bi(self.nodes,1,2)
|
connect_nodes_bi(self.nodes,1,2)
|
||||||
@ -446,7 +446,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
stop_node(self.nodes[1], 2)
|
stop_node(self.nodes[1], 2)
|
||||||
stop_node(self.nodes[2], 3)
|
stop_node(self.nodes[2], 3)
|
||||||
|
|
||||||
self.nodes = start_nodes(4, self.options.tmpdir, [['-usehd=1']] * self.num_nodes, redirect_stderr=True)
|
self.nodes = start_nodes(4, self.options.tmpdir, [['-usehd=1']] * self.num_nodes, stderr=sys.stdout)
|
||||||
# This test is not meant to test fee estimation and we'd like
|
# This test is not meant to test fee estimation and we'd like
|
||||||
# to be sure all txs are sent at a consistent desired feerate
|
# to be sure all txs are sent at a consistent desired feerate
|
||||||
for node in self.nodes:
|
for node in self.nodes:
|
||||||
|
@ -28,7 +28,7 @@ class KeyPoolTest(BitcoinTestFramework):
|
|||||||
nodes[0].encryptwallet('test')
|
nodes[0].encryptwallet('test')
|
||||||
bitcoind_processes[0].wait()
|
bitcoind_processes[0].wait()
|
||||||
# Restart node 0
|
# Restart node 0
|
||||||
nodes[0] = start_node(0, self.options.tmpdir, ['-usehd=1'], redirect_stderr=True)
|
nodes[0] = start_node(0, self.options.tmpdir, ['-usehd=1'], stderr=sys.stdout)
|
||||||
# Keep creating keys
|
# Keep creating keys
|
||||||
addr = nodes[0].getnewaddress()
|
addr = nodes[0].getnewaddress()
|
||||||
addr_data = nodes[0].validateaddress(addr)
|
addr_data = nodes[0].validateaddress(addr)
|
||||||
@ -104,7 +104,7 @@ class KeyPoolTest(BitcoinTestFramework):
|
|||||||
assert_equal(wi['keypoolsize'], 100)
|
assert_equal(wi['keypoolsize'], 100)
|
||||||
|
|
||||||
def setup_network(self):
|
def setup_network(self):
|
||||||
self.nodes = start_nodes(1, self.options.tmpdir, [['-usehd=1']], redirect_stderr=True)
|
self.nodes = start_nodes(1, self.options.tmpdir, [['-usehd=1']], stderr=sys.stdout)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
KeyPoolTest().main()
|
KeyPoolTest().main()
|
||||||
|
@ -218,13 +218,13 @@ class PruneTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
def manual_test(self, node_number, use_timestamp):
|
def manual_test(self, node_number, use_timestamp):
|
||||||
# at this point, node has 995 blocks and has not yet run in prune mode
|
# at this point, node has 995 blocks and has not yet run in prune mode
|
||||||
node = self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-litemode","-txindex=0"], redirect_stderr=True, timewait=900)
|
node = self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-litemode","-txindex=0"], stderr=sys.stdout, timewait=900)
|
||||||
assert_equal(node.getblockcount(), 995)
|
assert_equal(node.getblockcount(), 995)
|
||||||
assert_raises_jsonrpc(-1, "not in prune mode", node.pruneblockchain, 500)
|
assert_raises_jsonrpc(-1, "not in prune mode", node.pruneblockchain, 500)
|
||||||
self.stop_node(node_number)
|
self.stop_node(node_number)
|
||||||
|
|
||||||
# now re-start in manual pruning mode
|
# now re-start in manual pruning mode
|
||||||
node = self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-litemode","-txindex=0","-prune=1"], redirect_stderr=True, timewait=900)
|
node = self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-litemode","-txindex=0","-prune=1"], stderr=sys.stdout, timewait=900)
|
||||||
assert_equal(node.getblockcount(), 995)
|
assert_equal(node.getblockcount(), 995)
|
||||||
|
|
||||||
def height(index):
|
def height(index):
|
||||||
@ -298,7 +298,7 @@ class PruneTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# stop node, start back up with auto-prune at 550MB, make sure still runs
|
# stop node, start back up with auto-prune at 550MB, make sure still runs
|
||||||
self.stop_node(node_number)
|
self.stop_node(node_number)
|
||||||
self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-litemode","-txindex=0","-prune=550"], redirect_stderr=True, timewait=900)
|
self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-litemode","-txindex=0","-prune=550"], stderr=sys.stdout, timewait=900)
|
||||||
|
|
||||||
self.log.info("Success")
|
self.log.info("Success")
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ class PruneTest(BitcoinTestFramework):
|
|||||||
# check that the pruning node's wallet is still in good shape
|
# check that the pruning node's wallet is still in good shape
|
||||||
self.log.info("Stop and start pruning node to trigger wallet rescan")
|
self.log.info("Stop and start pruning node to trigger wallet rescan")
|
||||||
self.stop_node(2)
|
self.stop_node(2)
|
||||||
start_node(2, self.options.tmpdir, ["-litemode","-txindex=0","-prune=550"], redirect_stderr=True)
|
start_node(2, self.options.tmpdir, ["-litemode","-txindex=0","-prune=550"], stderr=sys.stdout)
|
||||||
self.log.info("Success")
|
self.log.info("Success")
|
||||||
|
|
||||||
# check that wallet loads loads successfully when restarting a pruned node after IBD.
|
# check that wallet loads loads successfully when restarting a pruned node after IBD.
|
||||||
@ -316,7 +316,7 @@ class PruneTest(BitcoinTestFramework):
|
|||||||
nds = [self.nodes[0], self.nodes[5]]
|
nds = [self.nodes[0], self.nodes[5]]
|
||||||
sync_blocks(nds, wait=5, timeout=300)
|
sync_blocks(nds, wait=5, timeout=300)
|
||||||
self.stop_node(5) #stop and start to trigger rescan
|
self.stop_node(5) #stop and start to trigger rescan
|
||||||
start_node(5, self.options.tmpdir, ["-litemode","-txindex=0","-prune=550"], redirect_stderr=True)
|
start_node(5, self.options.tmpdir, ["-litemode","-txindex=0","-prune=550"], stderr=sys.stdout)
|
||||||
self.log.info("Success")
|
self.log.info("Success")
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
|
@ -103,11 +103,11 @@ class BitcoinTestFramework(object):
|
|||||||
connect_nodes_bi(self.nodes, i, i + 1)
|
connect_nodes_bi(self.nodes, i, i + 1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
def setup_nodes(self):
|
def setup_nodes(self, stderr=None):
|
||||||
extra_args = None
|
extra_args = None
|
||||||
if hasattr(self, "extra_args"):
|
if hasattr(self, "extra_args"):
|
||||||
extra_args = self.extra_args
|
extra_args = self.extra_args
|
||||||
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, extra_args)
|
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, extra_args, stderr=stderr)
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
@ -219,8 +219,8 @@ class BitcoinTestFramework(object):
|
|||||||
def start_node(self, i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, stderr=None):
|
def start_node(self, i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, stderr=None):
|
||||||
return start_node(i, dirname, extra_args, rpchost, timewait, binary, stderr)
|
return start_node(i, dirname, extra_args, rpchost, timewait, binary, stderr)
|
||||||
|
|
||||||
def start_nodes(self, num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None):
|
def start_nodes(self, num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, stderr=None):
|
||||||
return start_nodes(num_nodes, dirname, extra_args, rpchost, timewait, binary)
|
return start_nodes(num_nodes, dirname, extra_args, rpchost, timewait, binary, stderr)
|
||||||
|
|
||||||
def stop_node(self, num_node):
|
def stop_node(self, num_node):
|
||||||
stop_node(self.nodes[num_node], num_node)
|
stop_node(self.nodes[num_node], num_node)
|
||||||
@ -281,7 +281,7 @@ class BitcoinTestFramework(object):
|
|||||||
rpc_handler.setLevel(logging.DEBUG)
|
rpc_handler.setLevel(logging.DEBUG)
|
||||||
rpc_logger.addHandler(rpc_handler)
|
rpc_logger.addHandler(rpc_handler)
|
||||||
|
|
||||||
def _initialize_chain(self, test_dir, num_nodes, cachedir):
|
def _initialize_chain(self, test_dir, num_nodes, cachedir, extra_args=None, stderr=None):
|
||||||
"""Initialize a pre-mined blockchain for use by the test.
|
"""Initialize a pre-mined blockchain for use by the test.
|
||||||
|
|
||||||
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
|
||||||
@ -309,7 +309,9 @@ class BitcoinTestFramework(object):
|
|||||||
args = [os.getenv("DASHD", "dashd"), "-server", "-keypool=1", "-datadir=" + datadir, "-discover=0", "-mocktime="+str(GENESISTIME)]
|
args = [os.getenv("DASHD", "dashd"), "-server", "-keypool=1", "-datadir=" + datadir, "-discover=0", "-mocktime="+str(GENESISTIME)]
|
||||||
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)
|
if extra_args is not None:
|
||||||
|
args.extend(extra_args)
|
||||||
|
bitcoind_processes[i] = subprocess.Popen(args, stderr=stderr)
|
||||||
self.log.debug("initialize_chain: dashd started, waiting for RPC to come up")
|
self.log.debug("initialize_chain: dashd started, waiting for RPC to come up")
|
||||||
wait_for_bitcoind_start(bitcoind_processes[i], rpc_url(i), i)
|
wait_for_bitcoind_start(bitcoind_processes[i], rpc_url(i), i)
|
||||||
self.log.debug("initialize_chain: RPC successfully started")
|
self.log.debug("initialize_chain: RPC successfully started")
|
||||||
|
@ -251,7 +251,7 @@ def wait_for_bitcoind_start(process, url, i):
|
|||||||
time.sleep(0.25)
|
time.sleep(0.25)
|
||||||
|
|
||||||
|
|
||||||
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, redirect_stderr=False, stderr=None):
|
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, stderr=None):
|
||||||
"""
|
"""
|
||||||
Start a dashd and return RPC connection to it
|
Start a dashd and return RPC connection to it
|
||||||
"""
|
"""
|
||||||
@ -264,11 +264,6 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
|
|||||||
args += [ "-createwalletbackups=0" ]
|
args += [ "-createwalletbackups=0" ]
|
||||||
if extra_args is not None: args.extend(extra_args)
|
if extra_args is not None: args.extend(extra_args)
|
||||||
|
|
||||||
# Allow to redirect stderr to stdout in case we expect some non-critical warnings/errors printed to stderr
|
|
||||||
# Otherwise the whole test would be considered to be failed in such cases
|
|
||||||
if redirect_stderr:
|
|
||||||
stderr = sys.stdout
|
|
||||||
|
|
||||||
bitcoind_processes[i] = subprocess.Popen(args, stderr=stderr)
|
bitcoind_processes[i] = subprocess.Popen(args, stderr=stderr)
|
||||||
logger.debug("initialize_chain: dashd started, waiting for RPC to come up")
|
logger.debug("initialize_chain: dashd started, waiting for RPC to come up")
|
||||||
url = rpc_url(i, rpchost)
|
url = rpc_url(i, rpchost)
|
||||||
@ -300,7 +295,7 @@ def assert_start_raises_init_error(i, dirname, extra_args=None, expected_msg=Non
|
|||||||
assert_msg = "dashd should have exited with expected error " + expected_msg
|
assert_msg = "dashd should have exited with expected error " + expected_msg
|
||||||
raise AssertionError(assert_msg)
|
raise AssertionError(assert_msg)
|
||||||
|
|
||||||
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, redirect_stderr=False):
|
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, stderr=None):
|
||||||
"""
|
"""
|
||||||
Start multiple dashds, return RPC connections to them
|
Start multiple dashds, return RPC connections to them
|
||||||
"""
|
"""
|
||||||
@ -311,7 +306,7 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, timewait=None
|
|||||||
rpcs = []
|
rpcs = []
|
||||||
try:
|
try:
|
||||||
for i in range(num_nodes):
|
for i in range(num_nodes):
|
||||||
rpcs.append(start_node(i, dirname, extra_args[i], rpchost, timewait=timewait, binary=binary[i], redirect_stderr=redirect_stderr))
|
rpcs.append(start_node(i, dirname, extra_args[i], rpchost, timewait=timewait, binary=binary[i], stderr=stderr))
|
||||||
except: # If one node failed to start, stop the others
|
except: # If one node failed to start, stop the others
|
||||||
stop_nodes(rpcs)
|
stop_nodes(rpcs)
|
||||||
raise
|
raise
|
||||||
|
@ -64,7 +64,7 @@ class WalletDumpTest(BitcoinTestFramework):
|
|||||||
def setup_chain(self):
|
def setup_chain(self):
|
||||||
# TODO remove this when usehd=1 becomes the default
|
# TODO remove this when usehd=1 becomes the default
|
||||||
# use our own cache and -usehd=1 as extra arg as the default cache is run with -usehd=0
|
# use our own cache and -usehd=1 as extra arg as the default cache is run with -usehd=0
|
||||||
initialize_chain(self.options.tmpdir, self.num_nodes, self.options.cachedir + "/hd", ["-usehd=1"], redirect_stderr=True)
|
self._initialize_chain(os.path.join(self.options.tmpdir, "hd"), self.num_nodes, os.path.join(self.options.cachedir, "hd"), extra_args=self.extra_args[0], stderr=sys.stdout)
|
||||||
set_cache_mocktime()
|
set_cache_mocktime()
|
||||||
|
|
||||||
def setup_network(self, split=False):
|
def setup_network(self, split=False):
|
||||||
@ -72,7 +72,7 @@ class WalletDumpTest(BitcoinTestFramework):
|
|||||||
# longer than the default 30 seconds due to an expensive
|
# longer than the default 30 seconds due to an expensive
|
||||||
# CWallet::TopUpKeyPool call, and the encryptwallet RPC made later in
|
# CWallet::TopUpKeyPool call, and the encryptwallet RPC made later in
|
||||||
# the test often takes even longer.
|
# the test often takes even longer.
|
||||||
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, self.extra_args, timewait=60, redirect_stderr=True)
|
self.nodes = start_nodes(self.num_nodes, os.path.join(self.options.tmpdir, "hd"), self.extra_args, timewait=60, stderr=sys.stdout)
|
||||||
|
|
||||||
def run_test (self):
|
def run_test (self):
|
||||||
tmpdir = self.options.tmpdir
|
tmpdir = self.options.tmpdir
|
||||||
|
@ -15,13 +15,16 @@ class WalletHDTest(BitcoinTestFramework):
|
|||||||
self.num_nodes = 2
|
self.num_nodes = 2
|
||||||
self.extra_args = [['-usehd=0'], ['-usehd=1', '-keypool=0']]
|
self.extra_args = [['-usehd=0'], ['-usehd=1', '-keypool=0']]
|
||||||
|
|
||||||
|
def setup_network(self):
|
||||||
|
self.setup_nodes(stderr=sys.stdout)
|
||||||
|
|
||||||
def run_test (self):
|
def run_test (self):
|
||||||
tmpdir = self.options.tmpdir
|
tmpdir = self.options.tmpdir
|
||||||
|
|
||||||
# Make sure can't switch off usehd after wallet creation
|
# Make sure can't switch off usehd after wallet creation
|
||||||
self.stop_node(1)
|
self.stop_node(1)
|
||||||
assert_start_raises_init_error(1, self.options.tmpdir, ['-usehd=0'], 'already existing HD wallet')
|
assert_start_raises_init_error(1, self.options.tmpdir, ['-usehd=0'], 'already existing HD wallet')
|
||||||
self.nodes[1] = start_node(1, self.options.tmpdir, self.extra_args[1], redirect_stderr=True)
|
self.nodes[1] = start_node(1, self.options.tmpdir, self.extra_args[1], stderr=sys.stdout)
|
||||||
connect_nodes_bi(self.nodes, 0, 1)
|
connect_nodes_bi(self.nodes, 0, 1)
|
||||||
|
|
||||||
# Make sure we use hd, keep chainid
|
# Make sure we use hd, keep chainid
|
||||||
@ -68,7 +71,7 @@ class WalletHDTest(BitcoinTestFramework):
|
|||||||
stop_node(self.nodes[1],1)
|
stop_node(self.nodes[1],1)
|
||||||
os.remove(self.options.tmpdir + "/node1/regtest/wallet.dat")
|
os.remove(self.options.tmpdir + "/node1/regtest/wallet.dat")
|
||||||
shutil.copyfile(tmpdir + "/hd.bak", tmpdir + "/node1/regtest/wallet.dat")
|
shutil.copyfile(tmpdir + "/hd.bak", tmpdir + "/node1/regtest/wallet.dat")
|
||||||
self.nodes[1] = start_node(1, self.options.tmpdir, self.extra_args[1], redirect_stderr=True)
|
self.nodes[1] = start_node(1, self.options.tmpdir, self.extra_args[1], stderr=sys.stdout)
|
||||||
#connect_nodes_bi(self.nodes, 0, 1)
|
#connect_nodes_bi(self.nodes, 0, 1)
|
||||||
|
|
||||||
# Assert that derivation is deterministic
|
# Assert that derivation is deterministic
|
||||||
@ -82,7 +85,7 @@ class WalletHDTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Needs rescan
|
# Needs rescan
|
||||||
self.stop_node(1)
|
self.stop_node(1)
|
||||||
self.nodes[1] = start_node(1, self.options.tmpdir, self.extra_args[1] + ['-rescan'], redirect_stderr=True)
|
self.nodes[1] = start_node(1, self.options.tmpdir, self.extra_args[1] + ['-rescan'], stderr=sys.stdout)
|
||||||
#connect_nodes_bi(self.nodes, 0, 1)
|
#connect_nodes_bi(self.nodes, 0, 1)
|
||||||
assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1)
|
assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class WalletTest(BitcoinTestFramework):
|
|||||||
self.extra_args = [['-usehd={:d}'.format(i%2==0)] for i in range(4)]
|
self.extra_args = [['-usehd={:d}'.format(i%2==0)] for i in range(4)]
|
||||||
|
|
||||||
def setup_network(self):
|
def setup_network(self):
|
||||||
self.nodes = start_nodes(3, self.options.tmpdir, self.extra_args[:3], redirect_stderr=True)
|
self.nodes = start_nodes(3, self.options.tmpdir, self.extra_args[:3], stderr=sys.stdout)
|
||||||
connect_nodes_bi(self.nodes,0,1)
|
connect_nodes_bi(self.nodes,0,1)
|
||||||
connect_nodes_bi(self.nodes,1,2)
|
connect_nodes_bi(self.nodes,1,2)
|
||||||
connect_nodes_bi(self.nodes,0,2)
|
connect_nodes_bi(self.nodes,0,2)
|
||||||
@ -178,7 +178,7 @@ class WalletTest(BitcoinTestFramework):
|
|||||||
txid2 = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
txid2 = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
||||||
sync_mempools(self.nodes)
|
sync_mempools(self.nodes)
|
||||||
|
|
||||||
self.nodes.append(start_node(3, self.options.tmpdir, self.extra_args[3], redirect_stderr=True))
|
self.nodes.append(start_node(3, self.options.tmpdir, self.extra_args[3], stderr=sys.stdout))
|
||||||
connect_nodes_bi(self.nodes, 0, 3)
|
connect_nodes_bi(self.nodes, 0, 3)
|
||||||
sync_blocks(self.nodes)
|
sync_blocks(self.nodes)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user