aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2014-08-19 10:28:58 -0400
committerJeff Garzik <jgarzik@bitpay.com>2014-08-19 10:28:58 -0400
commitd789386371699fee14bb5e444507a6067293ff67 (patch)
treee852391fb16a530c5ad40757b1f77b94c0c46273 /src/test
parentdd2819701a1a4481ae06b24924b75d55b9feb115 (diff)
downloadbitcoin-d789386371699fee14bb5e444507a6067293ff67.tar.xz
Add "it works" test for bitcoin-tx
Diffstat (limited to 'src/test')
-rw-r--r--src/test/bctest.py35
-rwxr-xr-xsrc/test/bitcoin-util-test.py12
-rw-r--r--src/test/data/bitcoin-util-test.json5
-rw-r--r--src/test/data/blanktx.hex1
4 files changed, 53 insertions, 0 deletions
diff --git a/src/test/bctest.py b/src/test/bctest.py
new file mode 100644
index 0000000000..3b17acb75e
--- /dev/null
+++ b/src/test/bctest.py
@@ -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)
+
diff --git a/src/test/bitcoin-util-test.py b/src/test/bitcoin-util-test.py
new file mode 100755
index 0000000000..40690c2fed
--- /dev/null
+++ b/src/test/bitcoin-util-test.py
@@ -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")
+
diff --git a/src/test/data/bitcoin-util-test.json b/src/test/data/bitcoin-util-test.json
new file mode 100644
index 0000000000..af29fd75a5
--- /dev/null
+++ b/src/test/data/bitcoin-util-test.json
@@ -0,0 +1,5 @@
+[
+ { "exec": ["./bitcoin-tx", "-create"],
+ "output_cmp": "blanktx.hex"
+ }
+]
diff --git a/src/test/data/blanktx.hex b/src/test/data/blanktx.hex
new file mode 100644
index 0000000000..36b6f00fb6
--- /dev/null
+++ b/src/test/data/blanktx.hex
@@ -0,0 +1 @@
+01000000000000000000