Commit 1473f69
committed
Merge bitcoin/bitcoin#32421: test: refactor: overhaul (w)txid determination for
4ef6253 test: avoid unneeded (w)txid hex -> integer conversions (Sebastian Falbesoner)
472f377 scripted-diff: test: rename CTransaction `.getwtxid()` -> `wtxid_hex` for consistency (Sebastian Falbesoner)
81af433 test: rename CTransaction `.sha256` -> `.txid_int` for consistency (Sebastian Falbesoner)
ce83924 test: rename CTransaction `.rehash()`/`.hash` -> `.txid_hex` for consistency (Sebastian Falbesoner)
e9cdaef test: introduce and use CTransaction `.wtxid_int` property (Sebastian Falbesoner)
9b3dce2 test: remove bare CTransaction `.rehash()`/`.calc_sha256()` calls (Sebastian Falbesoner)
a2724e3 test: remove txid caching in CTransaction class (Sebastian Falbesoner)
Pull request description:
In the functional test framework, determining a (w)txid for a `CTransaction` instance is currently rather confusing and footgunny due to inconsistent naming/interfaces (see table below) and statefulness involved. This PR aims to improve that by:
* removing the (w)txid caching mechanism, in order to avoid the need to call additional rehashing functions (`.rehash()`/`.calculate_sha256()`, see first two commits and bitcoin/bitcoin#32050 (comment)). This change in theory decreases the performance, as the involved serialization and hashing involved might be called more often than previously, but I couldn't find a functional test where this leads to a measurable run-time increase on my machine.
* introduce consistent naming that shows the type of the returned txid, i.e. hex string vs. test-framework-internal representation [currently integers] (see remaining commits)
Summary table showing (w)txid determaination before/after this PR:
| Task | master | PR |
|:-----------------------|:-----------------------|:-------------|
| get TXID (hex string) | `.rehash()` / `.hash`[1] | `.txid_hex` |
| get TXID (integer) | `.sha256`[1] | `.txid_int` |
| get WTXID (hex string) | `.getwtxid()` | `.wtxid_hex` |
| get WTXID (integer) | `.calc_sha256(True)` | `.wtxid_int` |
Unfortunately, most renames can't be done with a scripted-diff, as the property names (`.hash`, `.sha256`) are also used for blocks and other message types. The PR is rather invasive and touches a lot of files, but I think it's worth to do it, also to make life easier for new contributors. Future tasks like e.g. doing the same overhaul for block (header) objects or getting rid of the integer representation (see bitcoin/bitcoin#32050) become easier should become easier after this one.
[1] = returned value might be out-of-date, if rehashing function wasn't called after modification
ACKs for top commit:
maflcko:
re-ACK 4ef6253 🏈
achow101:
ACK 4ef6253
marcofleon:
code review ACK 4ef6253
Tree-SHA512: 4b472c31d169966b6f6878911a8404d25bf3e503b6e8ef30f36a7415d21ad4bc1265083af2d3ead6edfcd9fac9ccb0a8be57e1b0739ad431b836413070d7d583CTransaction objectsFile tree
45 files changed
+333
-499
lines changed- contrib/signet
- test/functional
- data
- test_framework
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
45 files changed
+333
-499
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
| 43 | + | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | | - | |
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
63 | | - | |
| 61 | + | |
64 | 62 | | |
65 | 63 | | |
66 | 64 | | |
| |||
88 | 86 | | |
89 | 87 | | |
90 | 88 | | |
91 | | - | |
92 | 89 | | |
93 | 90 | | |
94 | 91 | | |
| |||
111 | 108 | | |
112 | 109 | | |
113 | 110 | | |
114 | | - | |
115 | 111 | | |
116 | 112 | | |
117 | 113 | | |
| |||
130 | 126 | | |
131 | 127 | | |
132 | 128 | | |
133 | | - | |
134 | 129 | | |
135 | 130 | | |
136 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
| |||
113 | 112 | | |
114 | 113 | | |
115 | 114 | | |
116 | | - | |
117 | 115 | | |
118 | 116 | | |
119 | 117 | | |
| |||
130 | 128 | | |
131 | 129 | | |
132 | 130 | | |
133 | | - | |
134 | 131 | | |
135 | 132 | | |
136 | 133 | | |
| |||
147 | 144 | | |
148 | 145 | | |
149 | 146 | | |
150 | | - | |
| 147 | + | |
151 | 148 | | |
152 | | - | |
153 | 149 | | |
154 | 150 | | |
155 | 151 | | |
| |||
162 | 158 | | |
163 | 159 | | |
164 | 160 | | |
165 | | - | |
166 | 161 | | |
167 | 162 | | |
168 | 163 | | |
| |||
175 | 170 | | |
176 | 171 | | |
177 | 172 | | |
178 | | - | |
179 | 173 | | |
180 | 174 | | |
181 | 175 | | |
| |||
187 | 181 | | |
188 | 182 | | |
189 | 183 | | |
190 | | - | |
| 184 | + | |
191 | 185 | | |
192 | 186 | | |
193 | | - | |
194 | 187 | | |
195 | 188 | | |
196 | 189 | | |
| |||
226 | 219 | | |
227 | 220 | | |
228 | 221 | | |
229 | | - | |
230 | 222 | | |
231 | 223 | | |
232 | 224 | | |
| |||
274 | 266 | | |
275 | 267 | | |
276 | 268 | | |
277 | | - | |
278 | 269 | | |
279 | 270 | | |
280 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
605 | 605 | | |
606 | 606 | | |
607 | 607 | | |
608 | | - | |
| 608 | + | |
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | | - | |
123 | 122 | | |
124 | 123 | | |
125 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | 113 | | |
115 | 114 | | |
116 | 115 | | |
| |||
220 | 219 | | |
221 | 220 | | |
222 | 221 | | |
223 | | - | |
224 | 222 | | |
225 | 223 | | |
226 | 224 | | |
227 | 225 | | |
228 | 226 | | |
229 | | - | |
| 227 | + | |
230 | 228 | | |
231 | 229 | | |
232 | 230 | | |
233 | | - | |
234 | 231 | | |
235 | 232 | | |
236 | 233 | | |
| |||
244 | 241 | | |
245 | 242 | | |
246 | 243 | | |
247 | | - | |
| 244 | + | |
248 | 245 | | |
249 | 246 | | |
250 | 247 | | |
251 | | - | |
252 | 248 | | |
253 | | - | |
| 249 | + | |
254 | 250 | | |
255 | 251 | | |
256 | 252 | | |
| |||
264 | 260 | | |
265 | 261 | | |
266 | 262 | | |
267 | | - | |
| 263 | + | |
268 | 264 | | |
269 | 265 | | |
270 | 266 | | |
271 | 267 | | |
272 | 268 | | |
273 | 269 | | |
274 | | - | |
| 270 | + | |
275 | 271 | | |
276 | 272 | | |
277 | 273 | | |
278 | 274 | | |
279 | 275 | | |
280 | | - | |
| 276 | + | |
281 | 277 | | |
282 | 278 | | |
283 | 279 | | |
284 | 280 | | |
285 | 281 | | |
286 | 282 | | |
287 | | - | |
| 283 | + | |
288 | 284 | | |
289 | 285 | | |
290 | 286 | | |
291 | 287 | | |
292 | | - | |
| 288 | + | |
293 | 289 | | |
294 | 290 | | |
295 | | - | |
| 291 | + | |
296 | 292 | | |
297 | 293 | | |
298 | 294 | | |
299 | | - | |
| 295 | + | |
300 | 296 | | |
301 | 297 | | |
302 | 298 | | |
303 | | - | |
| 299 | + | |
304 | 300 | | |
305 | 301 | | |
306 | 302 | | |
| |||
319 | 315 | | |
320 | 316 | | |
321 | 317 | | |
322 | | - | |
323 | | - | |
| 318 | + | |
| 319 | + | |
324 | 320 | | |
325 | 321 | | |
326 | 322 | | |
| |||
337 | 333 | | |
338 | 334 | | |
339 | 335 | | |
340 | | - | |
341 | | - | |
| 336 | + | |
| 337 | + | |
342 | 338 | | |
343 | 339 | | |
344 | 340 | | |
| |||
353 | 349 | | |
354 | 350 | | |
355 | 351 | | |
356 | | - | |
357 | 352 | | |
358 | 353 | | |
359 | 354 | | |
360 | 355 | | |
361 | | - | |
| 356 | + | |
362 | 357 | | |
363 | 358 | | |
364 | 359 | | |
365 | 360 | | |
366 | 361 | | |
367 | 362 | | |
368 | | - | |
369 | 363 | | |
370 | 364 | | |
371 | 365 | | |
| |||
374 | 368 | | |
375 | 369 | | |
376 | 370 | | |
377 | | - | |
| 371 | + | |
378 | 372 | | |
379 | 373 | | |
380 | 374 | | |
381 | | - | |
382 | 375 | | |
383 | 376 | | |
384 | 377 | | |
| |||
0 commit comments