Browse Source

Add bitcoin-tx tests

Testing: delin, delout, locktime, and basic createrawtransaction-like
functionality.
0.10
Jeff Garzik 10 years ago
parent
commit
df4d61e681
  1. 7
      src/Makefile.test.include
  2. 16
      src/test/bctest.py
  3. 29
      src/test/data/bitcoin-util-test.json
  4. 1
      src/test/data/tt-delin1-out.hex
  5. 1
      src/test/data/tt-delout1-out.hex
  6. 1
      src/test/data/tt-locktime317000-out.hex
  7. 1
      src/test/data/tx394b54bb.hex
  8. 1
      src/test/data/txcreate1.hex

7
src/Makefile.test.include

@ -8,7 +8,12 @@ EXTRA_DIST += \
test/bctest.py \ test/bctest.py \
test/bitcoin-util-test.py \ test/bitcoin-util-test.py \
test/data/bitcoin-util-test.json \ test/data/bitcoin-util-test.json \
test/data/blanktx.hex test/data/blanktx.hex \
test/data/tt-delin1-out.hex \
test/data/tt-delout1-out.hex \
test/data/tt-locktime317000-out.hex \
test/data/tx394b54bb.hex \
test/data/txcreate1.hex
JSON_TEST_FILES = \ JSON_TEST_FILES = \
test/data/script_valid.json \ test/data/script_valid.json \

16
src/test/bctest.py

@ -17,8 +17,11 @@ def bctest(testDir, testObj):
inputData = open(filename).read() inputData = open(filename).read()
stdinCfg = subprocess.PIPE stdinCfg = subprocess.PIPE
outputFn = testObj['output_cmp'] outputFn = None
outputData = open(testDir + "/" + outputFn).read() outputData = None
if "output_cmp" in testObj:
outputFn = testObj['output_cmp']
outputData = open(testDir + "/" + outputFn).read()
proc = subprocess.Popen(execargs, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE) proc = subprocess.Popen(execargs, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try: try:
@ -27,10 +30,17 @@ def bctest(testDir, testObj):
print("OSError, Failed to execute " + execargs[0]) print("OSError, Failed to execute " + execargs[0])
sys.exit(1) sys.exit(1)
if outs[0] != outputData: if outputData and (outs[0] != outputData):
print("Output data mismatch for " + outputFn) print("Output data mismatch for " + outputFn)
sys.exit(1) sys.exit(1)
wantRC = 0
if "return_code" in testObj:
wantRC = testObj['return_code']
if proc.returncode != wantRC:
print("Return code mismatch for " + outputFn)
sys.exit(1)
def bctester(testDir, input_basename): def bctester(testDir, input_basename):
input_filename = testDir + "/" + input_basename input_filename = testDir + "/" + input_basename
raw_data = open(input_filename).read() raw_data = open(input_filename).read()

29
src/test/data/bitcoin-util-test.json

@ -5,5 +5,34 @@
{ "exec": ["./bitcoin-tx", "-"], { "exec": ["./bitcoin-tx", "-"],
"input": "blanktx.hex", "input": "blanktx.hex",
"output_cmp": "blanktx.hex" "output_cmp": "blanktx.hex"
},
{ "exec": ["./bitcoin-tx", "-", "delin=1"],
"input": "tx394b54bb.hex",
"output_cmp": "tt-delin1-out.hex"
},
{ "exec": ["./bitcoin-tx", "-", "delin=31"],
"input": "tx394b54bb.hex",
"return_code": 1
},
{ "exec": ["./bitcoin-tx", "-", "delout=1"],
"input": "tx394b54bb.hex",
"output_cmp": "tt-delout1-out.hex"
},
{ "exec": ["./bitcoin-tx", "-", "delout=2"],
"input": "tx394b54bb.hex",
"return_code": 1
},
{ "exec": ["./bitcoin-tx", "-", "locktime=317000"],
"input": "tx394b54bb.hex",
"output_cmp": "tt-locktime317000-out.hex"
},
{ "exec":
["./bitcoin-tx", "-create",
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
"in=bf829c6bcf84579331337659d31f89dfd138f7f7785802d5501c92333145ca7c:18",
"in=22a6f904655d53ae2ff70e701a0bbd90aa3975c0f40bfc6cc996a9049e31cdfc:1",
"outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o",
"outaddr=4:1P8yWvZW8jVihP1bzHeqfE4aoXNX8AVa46"],
"output_cmp": "txcreate1.hex"
} }
] ]

1
src/test/data/tt-delin1-out.hex

File diff suppressed because one or more lines are too long

1
src/test/data/tt-delout1-out.hex

File diff suppressed because one or more lines are too long

1
src/test/data/tt-locktime317000-out.hex

File diff suppressed because one or more lines are too long

1
src/test/data/tx394b54bb.hex

File diff suppressed because one or more lines are too long

1
src/test/data/txcreate1.hex

@ -0,0 +1 @@
01000000031f5c38dfcf6f1a5f5a87c416076d392c87e6d41970d5ad5e477a02d66bde97580000000000ffffffff7cca453133921c50d5025878f7f738d1df891fd359763331935784cf6b9c82bf1200000000fffffffffccd319e04a996c96cfc0bf4c07539aa90bd0b1a700ef72fae535d6504f9a6220100000000ffffffff0280a81201000000001976a9141fc11f39be1729bf973a7ab6a615ca4729d6457488ac0084d717000000001976a914f2d4db28cad6502226ee484ae24505c2885cb12d88ac00000000
Loading…
Cancel
Save