Browse Source

Merge #762: Abort tests early and output error if first bitcoin-cli call fails

192c07a Abort early and output error if first bitcoin-cli call fails (Kristaps Kaupe)
master
Adam Gibson 5 years ago
parent
commit
86af73d417
No known key found for this signature in database
GPG Key ID: 141001A1AF77F20B
  1. 12
      conftest.py

12
conftest.py

@ -42,7 +42,8 @@ def local_command(command, bg=False, redirect=''):
else:
#in case of foreground execution, we can use the output; if not
#it doesn't matter
return subprocess.check_output(command)
return subprocess.run(command, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
def root_path():
# returns the directory in which this file is contained
@ -120,7 +121,12 @@ def setup(request):
"-rpcuser=" + bitcoin_rpcusername,
"-rpcpassword=" + bitcoin_rpcpassword]
for i in range(2):
destn_addr = local_command(root_cmd + ["getnewaddress"])[:-1].decode('utf-8')
local_command(root_cmd + ["generatetoaddress", "301", destn_addr])
cpe = local_command(root_cmd + ["getnewaddress"])
if cpe.returncode == 0:
destn_addr = cpe.stdout[:-1].decode('utf-8')
local_command(root_cmd + ["generatetoaddress", "301", destn_addr])
else:
pytest.exit("Cannot setup tests, bitcoin-cli failing.\n" +
str(cpe.stdout))
time.sleep(1)

Loading…
Cancel
Save