Skip to content

Commit e66cc1d

Browse files
author
MarcoFalke
committed
Merge #8881: Add some verbose logging to bitcoin-util-test.py
621441a add verbose mode to bitcoin-util-test.py (jnewbery)
2 parents f137753 + 621441a commit e66cc1d

File tree

3 files changed

+65
-30
lines changed

3 files changed

+65
-30
lines changed

src/test/bctest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,17 @@ def bctest(testDir, testObj, exeext):
4545
print("Return code mismatch for " + outputFn)
4646
sys.exit(1)
4747

48-
def bctester(testDir, input_basename, buildenv):
48+
def bctester(testDir, input_basename, buildenv, verbose = False):
4949
input_filename = testDir + "/" + input_basename
5050
raw_data = open(input_filename).read()
5151
input_data = json.loads(raw_data)
5252

5353
for testObj in input_data:
54+
if verbose and "description" in testObj:
55+
print ("Testing: " + testObj["description"])
5456
bctest(testDir, testObj, buildenv.exeext)
57+
if verbose and "description" in testObj:
58+
print ("PASS")
5559

5660
sys.exit(0)
5761

src/test/bitcoin-util-test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919

2020

2121
if __name__ == '__main__':
22+
verbose = False
2223
try:
2324
srcdir = os.environ["srcdir"]
2425
except:
2526
parser = argparse.ArgumentParser(description=help_text)
2627
parser.add_argument('-s', '--srcdir')
28+
parser.add_argument('-v', '--verbose', action='store_true')
2729
args = parser.parse_args()
2830
srcdir = args.srcdir
29-
bctest.bctester(srcdir + "/test/data", "bitcoin-util-test.json", buildenv)
31+
verbose = args.verbose
32+
bctest.bctester(srcdir + "/test/data", "bitcoin-util-test.json", buildenv, verbose = verbose)

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

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,73 @@
11
[
22
{ "exec": "./bitcoin-tx",
33
"args": ["-create"],
4-
"output_cmp": "blanktx.hex"
4+
"output_cmp": "blanktx.hex",
5+
"description": "Creates a blank transaction"
56
},
67
{ "exec": "./bitcoin-tx",
78
"args": ["-json","-create"],
8-
"output_cmp": "blanktx.json"
9+
"output_cmp": "blanktx.json",
10+
"description": "Creates a blank transaction (output in json)"
911
},
1012
{ "exec": "./bitcoin-tx",
1113
"args": ["-"],
1214
"input": "blanktx.hex",
13-
"output_cmp": "blanktx.hex"
15+
"output_cmp": "blanktx.hex",
16+
"description": "Creates a blank transaction when nothing is piped into bitcoin-tx"
1417
},
1518
{ "exec": "./bitcoin-tx",
1619
"args": ["-json","-"],
1720
"input": "blanktx.hex",
18-
"output_cmp": "blanktx.json"
21+
"output_cmp": "blanktx.json",
22+
"description": "Creates a blank transaction when nothing is piped into bitcoin-tx (output in json)"
1923
},
2024
{ "exec": "./bitcoin-tx",
2125
"args": ["-", "delin=1"],
2226
"input": "tx394b54bb.hex",
23-
"output_cmp": "tt-delin1-out.hex"
27+
"output_cmp": "tt-delin1-out.hex",
28+
"description": "Deletes a single input from a transaction"
2429
},
2530
{ "exec": "./bitcoin-tx",
2631
"args": ["-json", "-", "delin=1"],
2732
"input": "tx394b54bb.hex",
28-
"output_cmp": "tt-delin1-out.json"
33+
"output_cmp": "tt-delin1-out.json",
34+
"description": "Deletes a single input from a transaction (output in json)"
2935
},
3036
{ "exec": "./bitcoin-tx",
3137
"args": ["-", "delin=31"],
3238
"input": "tx394b54bb.hex",
33-
"return_code": 1
39+
"return_code": 1,
40+
"description": "Attempts to delete an input with a bad index from a transaction. Expected to fail."
3441
},
3542
{ "exec": "./bitcoin-tx",
3643
"args": ["-", "delout=1"],
3744
"input": "tx394b54bb.hex",
38-
"output_cmp": "tt-delout1-out.hex"
45+
"output_cmp": "tt-delout1-out.hex",
46+
"description": "Deletes a single output from a transaction"
3947
},
4048
{ "exec": "./bitcoin-tx",
4149
"args": ["-json", "-", "delout=1"],
4250
"input": "tx394b54bb.hex",
43-
"output_cmp": "tt-delout1-out.json"
51+
"output_cmp": "tt-delout1-out.json",
52+
"description": "Deletes a single output from a transaction (output in json)"
4453
},
4554
{ "exec": "./bitcoin-tx",
4655
"args": ["-", "delout=2"],
4756
"input": "tx394b54bb.hex",
48-
"return_code": 1
57+
"return_code": 1,
58+
"description": "Attempts to delete an output with a bad index from a transaction. Expected to fail."
4959
},
5060
{ "exec": "./bitcoin-tx",
5161
"args": ["-", "locktime=317000"],
5262
"input": "tx394b54bb.hex",
53-
"output_cmp": "tt-locktime317000-out.hex"
63+
"output_cmp": "tt-locktime317000-out.hex",
64+
"description": "Adds an nlocktime to a transaction"
5465
},
5566
{ "exec": "./bitcoin-tx",
5667
"args": ["-json", "-", "locktime=317000"],
5768
"input": "tx394b54bb.hex",
58-
"output_cmp": "tt-locktime317000-out.json"
69+
"output_cmp": "tt-locktime317000-out.json",
70+
"description": "Adds an nlocktime to a transaction (output in json)"
5971
},
6072
{ "exec": "./bitcoin-tx",
6173
"args":
@@ -65,7 +77,8 @@
6577
"in=22a6f904655d53ae2ff70e701a0bbd90aa3975c0f40bfc6cc996a9049e31cdfc:1",
6678
"outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o",
6779
"outaddr=4:1P8yWvZW8jVihP1bzHeqfE4aoXNX8AVa46"],
68-
"output_cmp": "txcreate1.hex"
80+
"output_cmp": "txcreate1.hex",
81+
"description": "Creates a new transaction with three inputs and two outputs"
6982
},
7083
{ "exec": "./bitcoin-tx",
7184
"args":
@@ -76,15 +89,18 @@
7689
"in=22a6f904655d53ae2ff70e701a0bbd90aa3975c0f40bfc6cc996a9049e31cdfc:1",
7790
"outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o",
7891
"outaddr=4:1P8yWvZW8jVihP1bzHeqfE4aoXNX8AVa46"],
79-
"output_cmp": "txcreate1.json"
92+
"output_cmp": "txcreate1.json",
93+
"description": "Creates a new transaction with three inputs and two outputs (output in json)"
8094
},
8195
{ "exec": "./bitcoin-tx",
8296
"args": ["-create", "outscript=0:"],
83-
"output_cmp": "txcreate2.hex"
97+
"output_cmp": "txcreate2.hex",
98+
"description": "Creates a new transaction with a single empty output script"
8499
},
85100
{ "exec": "./bitcoin-tx",
86101
"args": ["-json", "-create", "outscript=0:"],
87-
"output_cmp": "txcreate2.json"
102+
"output_cmp": "txcreate2.json",
103+
"description": "Creates a new transaction with a single empty output script (output in json)"
88104
},
89105
{ "exec": "./bitcoin-tx",
90106
"args":
@@ -94,7 +110,8 @@
94110
"set=prevtxs:[{\"txid\":\"4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485\",\"vout\":0,\"scriptPubKey\":\"76a91491b24bf9f5288532960ac687abb035127b1d28a588ac\"}]",
95111
"sign=ALL",
96112
"outaddr=0.001:193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7"],
97-
"output_cmp": "txcreatesign.hex"
113+
"output_cmp": "txcreatesign.hex",
114+
"description": "Creates a new transaction with a single input and a single output, and then signs the transaction"
98115
},
99116
{ "exec": "./bitcoin-tx",
100117
"args":
@@ -105,29 +122,33 @@
105122
"set=prevtxs:[{\"txid\":\"4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485\",\"vout\":0,\"scriptPubKey\":\"76a91491b24bf9f5288532960ac687abb035127b1d28a588ac\"}]",
106123
"sign=ALL",
107124
"outaddr=0.001:193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7"],
108-
"output_cmp": "txcreatesign.json"
125+
"output_cmp": "txcreatesign.json",
126+
"description": "Creates a new transaction with a single input and a single output, and then signs the transaction (output in json)"
109127
},
110128
{ "exec": "./bitcoin-tx",
111129
"args":
112130
["-create",
113131
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
114132
"outdata=4:badhexdata"],
115-
"return_code": 1
133+
"return_code": 1,
134+
"description": "Attempts to create a new transaction with one input and an output with malformed hex data. Expected to fail"
116135
},
117136
{ "exec": "./bitcoin-tx",
118137
"args":
119138
["-create",
120139
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
121140
"outdata=badhexdata"],
122-
"return_code": 1
141+
"return_code": 1,
142+
"description": "Attempts to create a new transaction with one input and an output with no value and malformed hex data. Expected to fail"
123143
},
124144
{ "exec": "./bitcoin-tx",
125145
"args":
126146
["-create",
127147
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
128148
"outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o",
129149
"outdata=4:54686973204f505f52455455524e207472616e73616374696f6e206f7574707574207761732063726561746564206279206d6f646966696564206372656174657261777472616e73616374696f6e2e"],
130-
"output_cmp": "txcreatedata1.hex"
150+
"output_cmp": "txcreatedata1.hex",
151+
"description": "Creates a new transaction with one input, one address output and one data output"
131152
},
132153
{ "exec": "./bitcoin-tx",
133154
"args":
@@ -136,15 +157,17 @@
136157
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
137158
"outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o",
138159
"outdata=4:54686973204f505f52455455524e207472616e73616374696f6e206f7574707574207761732063726561746564206279206d6f646966696564206372656174657261777472616e73616374696f6e2e"],
139-
"output_cmp": "txcreatedata1.json"
160+
"output_cmp": "txcreatedata1.json",
161+
"description": "Creates a new transaction with one input, one address output and one data output (output in json)"
140162
},
141163
{ "exec": "./bitcoin-tx",
142164
"args":
143165
["-create",
144166
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
145167
"outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o",
146168
"outdata=54686973204f505f52455455524e207472616e73616374696f6e206f7574707574207761732063726561746564206279206d6f646966696564206372656174657261777472616e73616374696f6e2e"],
147-
"output_cmp": "txcreatedata2.hex"
169+
"output_cmp": "txcreatedata2.hex",
170+
"description": "Creates a new transaction with one input, one address output and one data (zero value) output"
148171
},
149172
{ "exec": "./bitcoin-tx",
150173
"args":
@@ -153,34 +176,39 @@
153176
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
154177
"outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o",
155178
"outdata=54686973204f505f52455455524e207472616e73616374696f6e206f7574707574207761732063726561746564206279206d6f646966696564206372656174657261777472616e73616374696f6e2e"],
156-
"output_cmp": "txcreatedata2.json"
179+
"output_cmp": "txcreatedata2.json",
180+
"description": "Creates a new transaction with one input, one address output and one data (zero value) output (output in json)"
157181
},
158182
{ "exec": "./bitcoin-tx",
159183
"args":
160184
["-create",
161185
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0:4294967293",
162186
"outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o"],
163-
"output_cmp": "txcreatedata_seq0.hex"
187+
"output_cmp": "txcreatedata_seq0.hex",
188+
"description": "Creates a new transaction with one input with sequence number and one address output"
164189
},
165190
{ "exec": "./bitcoin-tx",
166191
"args":
167192
["-json",
168193
"-create",
169194
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0:4294967293",
170195
"outaddr=0.18:13tuJJDR2RgArmgfv6JScSdreahzgc4T6o"],
171-
"output_cmp": "txcreatedata_seq0.json"
196+
"output_cmp": "txcreatedata_seq0.json",
197+
"description": "Creates a new transaction with one input with sequence number and one address output (output in json)"
172198
},
173199
{ "exec": "./bitcoin-tx",
174200
"args":
175201
["01000000011f5c38dfcf6f1a5f5a87c416076d392c87e6d41970d5ad5e477a02d66bde97580000000000fdffffff0180a81201000000001976a9141fc11f39be1729bf973a7ab6a615ca4729d6457488ac00000000",
176202
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0:1"],
177-
"output_cmp": "txcreatedata_seq1.hex"
203+
"output_cmp": "txcreatedata_seq1.hex",
204+
"description": "Adds a new input with sequence number to a transaction"
178205
},
179206
{ "exec": "./bitcoin-tx",
180207
"args":
181208
["-json",
182209
"01000000011f5c38dfcf6f1a5f5a87c416076d392c87e6d41970d5ad5e477a02d66bde97580000000000fdffffff0180a81201000000001976a9141fc11f39be1729bf973a7ab6a615ca4729d6457488ac00000000",
183210
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0:1"],
184-
"output_cmp": "txcreatedata_seq1.json"
211+
"output_cmp": "txcreatedata_seq1.json",
212+
"description": "Adds a new input with sequence number to a transaction (output in json)"
185213
}
186214
]

0 commit comments

Comments
 (0)