Commit 318c729
Add ScriptContext Builder testlib and refactor LinearVesting tests (#7643)
* Add ScriptContext Builder testlib and refactor LinearVesting tests
Introduce a ScriptContext builder module in plutus-ledger-api testlib
that provides composable combinators for constructing ScriptContext
values in tests. This replaces hand-crafted script contexts with a
declarative builder pattern using lenses.
Key changes:
- Add PlutusLedgerApi.Test.ScriptContextBuilder.Builder with combinators
for minting, spending, certifying, rewarding, and proposing contexts
- Add PlutusLedgerApi.Test.ScriptContextBuilder.Lenses with TH-generated
lenses for all V3 ledger types
- Refactor LinearVesting benchmark tests to use the new builder
- Fix AsData destructSum-manual test to use manual IsData instances
instead of asData, regenerating golden files
Based on work from PR #7562.
Co-authored-by: Philip DiSarro <philip-disarro@users.noreply.github.com>
* Replace redundant helpers with existing API functions
- Replace local isPubKeyAddress/isScriptAddress with
toPubKeyHash/toScriptHash from PlutusLedgerApi.V1.Address
- Replace negateValue with PlutusTx.negate (Value has AdditiveGroup)
- Export and relocate currencySymbolFromHex and singleCurrencySymbol
to a dedicated Helpers section at the bottom of Builder.hs
Co-authored-by: Philip DiSarro <philip-disarro@users.noreply.github.com>
* Regenerate golden files for LinearVesting and CallTrace tests
---------
Co-authored-by: Philip DiSarro <philip-disarro@users.noreply.github.com>1 parent 8337e0b commit 318c729
File tree
10 files changed
+943
-56
lines changed- plutus-benchmark
- linear-vesting
- src/LinearVesting
- test/9.6
- plutus-ledger-api
- changelog.d
- testlib/PlutusLedgerApi/Test/ScriptContextBuilder
- Lenses
10 files changed
+943
-56
lines changedLines changed: 38 additions & 48 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
16 | 25 | | |
17 | | - | |
18 | | - | |
| 26 | + | |
| 27 | + | |
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
22 | 31 | | |
23 | 32 | | |
24 | | - | |
| 33 | + | |
25 | 34 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
31 | 49 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
66 | 56 | | |
67 | 57 | | |
68 | 58 | | |
69 | 59 | | |
70 | | - | |
71 | | - | |
| 60 | + | |
| 61 | + | |
72 | 62 | | |
73 | 63 | | |
74 | 64 | | |
75 | 65 | | |
76 | 66 | | |
77 | 67 | | |
78 | 68 | | |
79 | | - | |
80 | | - | |
| 69 | + | |
| 70 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1478 | 1478 | | |
1479 | 1479 | | |
1480 | 1480 | | |
1481 | | - | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
1482 | 1499 | | |
1483 | 1500 | | |
1484 | 1501 | | |
| |||
1489 | 1506 | | |
1490 | 1507 | | |
1491 | 1508 | | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
1492 | 1515 | | |
1493 | | - | |
1494 | | - | |
| 1516 | + | |
1495 | 1517 | | |
1496 | 1518 | | |
1497 | 1519 | | |
| |||
Lines changed: 26 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1207 | 1207 | | |
1208 | 1208 | | |
1209 | 1209 | | |
1210 | | - | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
1211 | 1229 | | |
1212 | 1230 | | |
1213 | 1231 | | |
| |||
1218 | 1236 | | |
1219 | 1237 | | |
1220 | 1238 | | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
1221 | 1245 | | |
1222 | | - | |
1223 | | - | |
| 1246 | + | |
1224 | 1247 | | |
1225 | 1248 | | |
1226 | 1249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
781 | | - | |
| 781 | + | |
782 | 782 | | |
| 783 | + | |
783 | 784 | | |
784 | 785 | | |
785 | 786 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
164 | 167 | | |
165 | 168 | | |
166 | 169 | | |
| |||
180 | 183 | | |
181 | 184 | | |
182 | 185 | | |
| 186 | + | |
183 | 187 | | |
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
188 | 192 | | |
189 | 193 | | |
| 194 | + | |
190 | 195 | | |
191 | 196 | | |
192 | 197 | | |
| |||
0 commit comments