mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Merge #9832: [qa] assert_start_raises_init_error
025dec0
[qa] assert_start_raises_init_error (NicolasDorier)
Tree-SHA512: 0fe3ecbd47625b181aed92f15445ac26993e1a8b9843bbc1088c4adcea774e503b870912a18e13dca3f255c22a9964c1c0ca92c758907538143f316c5272ea4a
This commit is contained in:
parent
4615da99fb
commit
56890f98f2
@ -16,6 +16,7 @@ import http.client
|
||||
import random
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import re
|
||||
import errno
|
||||
@ -352,7 +353,7 @@ def _rpchost_to_args(rpchost):
|
||||
rv += ['-rpcport=' + rpcport]
|
||||
return rv
|
||||
|
||||
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, redirect_stderr=False):
|
||||
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, redirect_stderr=False, stderr=None):
|
||||
"""
|
||||
Start a dashd and return RPC connection to it
|
||||
"""
|
||||
@ -385,6 +386,25 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
|
||||
|
||||
return proxy
|
||||
|
||||
def assert_start_raises_init_error(i, dirname, extra_args=None, expected_msg=None):
|
||||
with tempfile.SpooledTemporaryFile(max_size=2**16) as log_stderr:
|
||||
try:
|
||||
node = start_node(i, dirname, extra_args, stderr=log_stderr)
|
||||
stop_node(node, i)
|
||||
except Exception as e:
|
||||
assert 'bitcoind exited' in str(e) #node must have shutdown
|
||||
if expected_msg is not None:
|
||||
log_stderr.seek(0)
|
||||
stderr = log_stderr.read().decode('utf-8')
|
||||
if expected_msg not in stderr:
|
||||
raise AssertionError("Expected error \"" + expected_msg + "\" not found in:\n" + stderr)
|
||||
else:
|
||||
if expected_msg is None:
|
||||
assert_msg = "bitcoind should have exited with an error"
|
||||
else:
|
||||
assert_msg = "bitcoind should have exited with expected error " + expected_msg
|
||||
raise AssertionError(assert_msg)
|
||||
|
||||
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, timewait=None, binary=None, redirect_stderr=False):
|
||||
"""
|
||||
Start multiple dashds, return RPC connections to them
|
||||
|
12
qa/rpc-tests/wallet-hd.py
Executable file → Normal file
12
qa/rpc-tests/wallet-hd.py
Executable file → Normal file
@ -25,15 +25,9 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
tmpdir = self.options.tmpdir
|
||||
|
||||
# Make sure can't switch off usehd after wallet creation
|
||||
stop_node(self.nodes[1],1)
|
||||
try:
|
||||
start_node(1, self.options.tmpdir, ['-usehd=0'], redirect_stderr=True)
|
||||
raise AssertionError("Must not allow to turn off HD on an already existing HD wallet")
|
||||
except Exception as e:
|
||||
assert("dashd exited with status 1 during initialization" in str(e))
|
||||
# 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.node_args[1])
|
||||
self.nodes[1] = start_node(1, self.options.tmpdir, ['-usehd=1', '-keypool=0'], redirect_stderr=True)
|
||||
self.stop_node(1)
|
||||
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.node_args[1])
|
||||
connect_nodes_bi(self.nodes, 0, 1)
|
||||
|
||||
# Make sure we use hd, keep chainid
|
||||
|
Loading…
Reference in New Issue
Block a user