mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Add "it works" test for bitcoin-tx
This commit is contained in:
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)
|
||||
|
||||
Reference in New Issue
Block a user