Add "it works" test for bitcoin-tx
This commit is contained in:
parent
dd2819701a
commit
d789386371
6 changed files with 62 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -43,6 +43,7 @@ src/qt/test/moc*.cpp
|
|||
*.bak
|
||||
*.rej
|
||||
*.orig
|
||||
*.pyc
|
||||
*.o
|
||||
*.o-*
|
||||
*.patch
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
TESTS += test/test_bitcoin
|
||||
TESTS += test/test_bitcoin test/bitcoin-util-test.py
|
||||
bin_PROGRAMS += test/test_bitcoin
|
||||
TEST_SRCDIR = test
|
||||
TEST_BINARY=test/test_bitcoin$(EXEEXT)
|
||||
|
||||
|
||||
EXTRA_DIST += \
|
||||
test/bctest.py \
|
||||
test/bitcoin-util-test.py \
|
||||
test/data/bitcoin-util-test.json \
|
||||
test/data/blanktx.hex
|
||||
|
||||
JSON_TEST_FILES = \
|
||||
test/data/script_valid.json \
|
||||
test/data/base58_keys_valid.json \
|
||||
|
|
35
src/test/bctest.py
Normal file
35
src/test/bctest.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Copyright 2014 BitPay, Inc.
|
||||
# Distributed under the MIT/X11 software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
|
||||
def bctest(testDir, testObj):
|
||||
execargs = testObj['exec']
|
||||
outputFn = testObj['output_cmp']
|
||||
outputData = open(testDir + "/" + outputFn).read()
|
||||
|
||||
proc = subprocess.Popen(execargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
try:
|
||||
outs = proc.communicate()
|
||||
except OSError:
|
||||
print("OSError, Failed to execute " + execargs[0])
|
||||
sys.exit(1)
|
||||
|
||||
if outs[0] != outputData:
|
||||
print("Output data mismatch for " + outputFn)
|
||||
sys.exit(1)
|
||||
|
||||
def bctester(testDir, input_basename):
|
||||
input_filename = testDir + "/" + input_basename
|
||||
raw_data = open(input_filename).read()
|
||||
input_data = json.loads(raw_data)
|
||||
|
||||
for testObj in input_data:
|
||||
bctest(testDir, testObj)
|
||||
|
||||
sys.exit(0)
|
||||
|
12
src/test/bitcoin-util-test.py
Executable file
12
src/test/bitcoin-util-test.py
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/python
|
||||
# Copyright 2014 BitPay, Inc.
|
||||
# Distributed under the MIT/X11 software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
import os
|
||||
import bctest
|
||||
|
||||
if __name__ == '__main__':
|
||||
bctest.bctester(os.environ["srcdir"] + "/test/data",
|
||||
"bitcoin-util-test.json")
|
||||
|
5
src/test/data/bitcoin-util-test.json
Normal file
5
src/test/data/bitcoin-util-test.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
[
|
||||
{ "exec": ["./bitcoin-tx", "-create"],
|
||||
"output_cmp": "blanktx.hex"
|
||||
}
|
||||
]
|
1
src/test/data/blanktx.hex
Normal file
1
src/test/data/blanktx.hex
Normal file
|
@ -0,0 +1 @@
|
|||
01000000000000000000
|
Loading…
Reference in a new issue