Browse Source

Check stderr when testing bitcoin-tx

0.15
John Newbery 8 years ago
parent
commit
21704f6334
  1. 12
      test/util/bctest.py
  2. 4
      test/util/data/bitcoin-util-test.json

12
test/util/bctest.py

@ -102,6 +102,18 @@ def bctest(testDir, testObj, buildenv):
logging.error("Return code mismatch for " + outputFn) logging.error("Return code mismatch for " + outputFn)
raise Exception raise Exception
if "error_txt" in testObj:
want_error = testObj["error_txt"]
# Compare error text
# TODO: ideally, we'd compare the strings exactly and also assert
# That stderr is empty if no errors are expected. However, bitcoin-tx
# emits DISPLAY errors when running as a windows application on
# linux through wine. Just assert that the expected error text appears
# somewhere in stderr.
if want_error not in outs[1]:
logging.error("Error mismatch:\n" + "Expected: " + want_error + "\nReceived: " + outs[1].rstrip())
raise Exception
def bctester(testDir, input_basename, buildenv): def bctester(testDir, input_basename, buildenv):
""" Loads and parses the input file, runs all tests and reports results""" """ Loads and parses the input file, runs all tests and reports results"""
input_filename = testDir + "/" + input_basename input_filename = testDir + "/" + input_basename

4
test/util/data/bitcoin-util-test.json

@ -42,6 +42,7 @@
"args": ["-", "delin=31"], "args": ["-", "delin=31"],
"input": "tx394b54bb.hex", "input": "tx394b54bb.hex",
"return_code": 1, "return_code": 1,
"error_txt": "error: Invalid TX input index '31'",
"description": "Attempts to delete an input with a bad index from a transaction. Expected to fail." "description": "Attempts to delete an input with a bad index from a transaction. Expected to fail."
}, },
{ "exec": "./bitcoin-tx", { "exec": "./bitcoin-tx",
@ -60,6 +61,7 @@
"args": ["-", "delout=2"], "args": ["-", "delout=2"],
"input": "tx394b54bb.hex", "input": "tx394b54bb.hex",
"return_code": 1, "return_code": 1,
"error_txt": "error: Invalid TX output index '2'",
"description": "Attempts to delete an output with a bad index from a transaction. Expected to fail." "description": "Attempts to delete an output with a bad index from a transaction. Expected to fail."
}, },
{ "exec": "./bitcoin-tx", { "exec": "./bitcoin-tx",
@ -233,6 +235,7 @@
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0", "in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
"outdata=4:badhexdata"], "outdata=4:badhexdata"],
"return_code": 1, "return_code": 1,
"error_txt": "error: invalid TX output data",
"description": "Attempts to create a new transaction with one input and an output with malformed hex data. Expected to fail" "description": "Attempts to create a new transaction with one input and an output with malformed hex data. Expected to fail"
}, },
{ "exec": "./bitcoin-tx", { "exec": "./bitcoin-tx",
@ -241,6 +244,7 @@
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0", "in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
"outdata=badhexdata"], "outdata=badhexdata"],
"return_code": 1, "return_code": 1,
"error_txt": "error: invalid TX output data",
"description": "Attempts to create a new transaction with one input and an output with no value and malformed hex data. Expected to fail" "description": "Attempts to create a new transaction with one input and an output with no value and malformed hex data. Expected to fail"
}, },
{ "exec": "./bitcoin-tx", { "exec": "./bitcoin-tx",

Loading…
Cancel
Save