diff options
| author | Jeff Garzik <[email protected]> | 2014-08-18 23:14:29 -0400 |
|---|---|---|
| committer | Jeff Garzik <[email protected]> | 2014-08-19 10:29:10 -0400 |
| commit | fb14452c6cadb8d977c405dddb0a94115250d7c4 (patch) | |
| tree | 15bee02d3211d2043b2f5b390ee19745b79bbc6a /src/test | |
| parent | Add "it works" test for bitcoin-tx (diff) | |
| download | discoin-fb14452c6cadb8d977c405dddb0a94115250d7c4.tar.xz discoin-fb14452c6cadb8d977c405dddb0a94115250d7c4.zip | |
bitcoin-tx: Accept input via stdin. Add input handling to tests.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/bctest.py | 12 | ||||
| -rw-r--r-- | src/test/data/bitcoin-util-test.json | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/test/bctest.py b/src/test/bctest.py index 3b17acb75..b12647908 100644 --- a/src/test/bctest.py +++ b/src/test/bctest.py @@ -9,12 +9,20 @@ import sys def bctest(testDir, testObj): execargs = testObj['exec'] + + stdinCfg = None + inputData = None + if "input" in testObj: + filename = testDir + "/" + testObj['input'] + inputData = open(filename).read() + stdinCfg = subprocess.PIPE + outputFn = testObj['output_cmp'] outputData = open(testDir + "/" + outputFn).read() - proc = subprocess.Popen(execargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + proc = subprocess.Popen(execargs, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE) try: - outs = proc.communicate() + outs = proc.communicate(input=inputData) except OSError: print("OSError, Failed to execute " + execargs[0]) sys.exit(1) diff --git a/src/test/data/bitcoin-util-test.json b/src/test/data/bitcoin-util-test.json index af29fd75a..16bcb4489 100644 --- a/src/test/data/bitcoin-util-test.json +++ b/src/test/data/bitcoin-util-test.json @@ -1,5 +1,9 @@ [ { "exec": ["./bitcoin-tx", "-create"], "output_cmp": "blanktx.hex" + }, + { "exec": ["./bitcoin-tx", "-"], + "input": "blanktx.hex", + "output_cmp": "blanktx.hex" } ] |