Skip to content

Commit aebb33a

Browse files
authored
Merge pull request #13 from mkoura/kwxm/e2e/batch6/dropList
End-to-end tests for `dropList`
2 parents b44b2d1 + 6aa806d commit aebb33a

File tree

10 files changed

+546
-10
lines changed

10 files changed

+546
-10
lines changed

CLAUDE.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ Scripts support multiple Plutus Ledger versions (V1, V2, V3) and Plutus Core lan
7777
**Module Naming Pattern:** `V{LedgerVersion}_{CoreCompact}.hs`
7878

7979
Where `CoreCompact` is Plutus Core version with digits compacted (no separators):
80+
8081
- 1.0.0 → 100
8182
- 1.1.0 → 110
8283

8384
**Examples:**
85+
8486
- `V1_100.hs` = PlutusV1 + Plutus Core 1.0.0
8587
- `V2_110.hs` = PlutusV2 + Plutus Core 1.1.0
8688
- `V3_100.hs` = PlutusV3 + Plutus Core 1.0.0
@@ -112,11 +114,13 @@ import PlutusScripts.Batch6.DropList.V3_110 qualified as DropList_V3_110
112114
**Rationale:**
113115

114116
This convention provides clear separation of concerns:
117+
115118
- **Underscore** separates distinct version concepts (Plutus Ledger vs Core)
116119
- **No separator** within Core version digits (compacted for clarity)
117120
- Removes ambiguity about which separator indicates what
118121

119122
**Benefits:**
123+
120124
- Visual clarity: `V3_110` vs verbose `V3_1_1_0`
121125
- Less verbose: 6 characters vs 8 characters
122126
- Clear hierarchy: version concepts (separated) vs version digits (compact)
@@ -174,6 +178,7 @@ mapM_ writeScriptGroup Bitwise_V3_110.failingBitwiseScriptGroups_V3_110
174178
```
175179

176180
This pattern:
181+
177182
- ✅ Encapsulates parameter iteration in the library
178183
- ✅ Keeps executable unaware of Params types
179184
- ✅ Generates numbered script files automatically
@@ -292,6 +297,7 @@ cabal run envelopes
292297
Output: Multiple `.plutus` files in `serialised-plutus-scripts/` (git-ignored)
293298

294299
**Generated Scripts**:
300+
295301
- PlutusV2 scripts (bytestring/integer conversions)
296302
- Basic PlutusV3 scripts (always succeed/fail, token names, time ranges, redeemers)
297303
- SECP256k1 scripts (Schnorr and ECDSA signature verification)
@@ -317,12 +323,14 @@ To add a simple script:
317323
For parameterized tests (e.g., failing tests with multiple edge cases):
318324

319325
1. Define test parameters in the `Common` module:
326+
320327
```haskell
321328
data Params = Params { input :: ByteString, expected :: Bool }
322329
testParams :: [Params]
323330
```
324331

325332
2. Create a `ScriptGroup` in the versioned module:
333+
326334
```haskell
327335
myScriptGroup :: [ScriptGroup DefaultUni DefaultFun (BuiltinData -> BuiltinUnit)]
328336
myScriptGroup = [ScriptGroup
@@ -332,7 +340,7 @@ For parameterized tests (e.g., failing tests with multiple edge cases):
332340
```
333341

334342
3. Use `mapM_ writeScriptGroup` in `app/Main.hs`
335-
4. Run `cabal run envelopes` - generates numbered files (myTestScript_1.plutus, _2.plutus, ...)
343+
4. Run `cabal run envelopes` - generates numbered files (myTestScript_1.plutus, \_2.plutus, ...)
336344

337345
## Nix Binary Cache
338346

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Originally based on the [Antaeus repository](https://github.com/IntersectMBO/ant
99
This repository provides serialized Plutus scripts compiled for **Plutus Core 1.0.0 and 1.1.0** targeting **PlutusV2** and **PlutusV3** ledger APIs. The scripts are generated as `.plutus` envelope files consumed by the [cardano-node-tests](https://github.com/IntersectMBO/cardano-node-tests) E2E test suite.
1010

1111
**Key Features:**
12+
1213
- Comprehensive script library covering basic validators, bitwise operations, cryptography, and governance
1314
- Plutus Core 1.0.0 and 1.1.0 support with PlutusV2 and PlutusV3 targeting
1415
- Modular architecture with Common/Versioned module pattern
@@ -40,6 +41,7 @@ cabal run envelopes
4041
The generated `.plutus` files are JSON envelopes containing the serialized Plutus scripts, ready for use in cardano-node-tests.
4142

4243
**Generated Scripts**:
44+
4345
- PlutusV2 scripts (bytestring/integer conversions)
4446
- Basic PlutusV3 scripts (always succeed/fail, token names, time ranges, redeemers)
4547
- SECP256k1 scripts (Schnorr and ECDSA signature verification)
@@ -87,12 +89,14 @@ Core testing scripts for fundamental blockchain operations:
8789
Scripts demonstrating Plutus bitwise primitives (Plutus Core 1.1.0+):
8890

8991
**Succeeding Tests**:
92+
9093
- Logical operations: `andByteString`, `orByteString`, `xorByteString`, `complementByteString`
9194
- Shifts and rotates: `shiftByteString`, `rotateByteString`
9295
- Bit manipulation: `readBit`, `writeBits`, `countSetBits`, `findFirstSetBit`
9396
- Byte operations: `replicateByte`, conversions between integers and bytestrings
9497

9598
**Failing Tests**:
99+
96100
- ReadBit edge cases: empty bytestring, negative indices, out of bounds, Int64 limits
97101
- WriteBits edge cases: empty bytestring, negative indices, out of bounds
98102
- ReplicateByte edge cases: negative count, invalid byte values, size limits
@@ -145,17 +149,20 @@ alwaysSucceedPolicyCompiled = $$(PlutusTx.compile [||mkAlwaysSucceedPolicyV3||])
145149
Scripts are compiled for both **Plutus Core 1.0.0** (PlutusV2) and **Plutus Core 1.1.0** (PlutusV3):
146150

147151
**Plutus Core 1.0.0 scripts:**
152+
148153
```haskell
149154
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.0.0 #-}
150155
```
151156

152157
**Plutus Core 1.1.0 scripts:**
158+
153159
```haskell
154160
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:conservative-optimisation #-}
155161
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.1.0 #-}
156162
```
157163

158164
PlutusV3 (1.1.0) validators receive enhanced `ScriptContext` with governance support:
165+
159166
- Committee actions and voting
160167
- Proposal transactions
161168
- Constitutional committee hot key operations
@@ -292,6 +299,7 @@ Example envelope structure:
292299
5. **Validation**: Cardano node validates scripts during E2E tests
293300

294301
The scripts enable comprehensive testing of:
302+
295303
- Plutus V2 and V3 features (including governance)
296304
- Bitwise operations introduced in Plutus Core 1.1.0
297305
- Cryptographic primitives (BLS, SECP256k1)
@@ -302,18 +310,21 @@ The scripts enable comprehensive testing of:
302310
### Adding New Scripts
303311

304312
1. **Create validator logic** in `PlutusScripts/<Category>/Common.hs`:
313+
305314
```haskell
306315
{-# INLINEABLE myValidator #-}
307316
myValidator :: BuiltinData -> BuiltinData -> BuiltinData -> ()
308317
```
309318

310319
2. **Add versioned module** `PlutusScripts/<Category>/V_1_1.hs`:
320+
311321
```haskell
312322
myValidatorCompiled :: CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> ())
313323
myValidatorCompiled = $$(PlutusTx.compile [||myValidator||])
314324
```
315325

316326
3. **Update envelopes executable** in `app/Main.hs`:
327+
317328
```haskell
318329
writeEnvelopeV3 "myValidatorScript" MyCategory.myValidatorCompiled
319330
```

plutus-scripts/Helpers/ScriptUtils.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ The executable can iterate over 'sgScripts' and generate files named
3838
-}
3939
data ScriptGroup uni fun a = ScriptGroup
4040
{ sgBaseName :: String
41-
-- ^ Base name for the script group (e.g., "failingReadBitPolicyScriptV3")
41+
-- ^ Base name for the script group (e.g., "failingReadBitPolicyScriptV3")
4242
, sgScripts :: [CompiledCodeIn uni fun a]
43-
-- ^ List of compiled scripts, will be numbered from 1
43+
-- ^ List of compiled scripts, will be numbered from 1
4444
}
4545

4646
{-# INLINEABLE tracedUnsafeFrom #-}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module PlutusScripts.Batch6.DropList (
2+
allDropListScripts,
3+
allDropListScriptGroups,
4+
)
5+
where
6+
7+
import Helpers.Envelopes (
8+
VersionedScript (VersionedScript),
9+
VersionedScriptGroup (VersionedScriptGroup),
10+
plc110,
11+
)
12+
import PlutusLedgerApi.Common.Versions (PlutusLedgerLanguage (PlutusV3))
13+
import PlutusScripts.Batch6.DropList.V3_110 qualified as V3_110
14+
import PlutusTx.Prelude qualified as P
15+
16+
allDropListScripts :: [VersionedScript (P.BuiltinData -> P.BuiltinUnit)]
17+
allDropListScripts =
18+
[ VersionedScript
19+
PlutusV3
20+
plc110
21+
"succeedingDropListPolicyScript"
22+
V3_110.succeedingDropListPolicy
23+
]
24+
25+
allDropListScriptGroups :: [VersionedScriptGroup (P.BuiltinData -> P.BuiltinUnit)]
26+
allDropListScriptGroups =
27+
[ VersionedScriptGroup
28+
PlutusV3
29+
plc110
30+
"expensiveDropListPolicyScript"
31+
V3_110.expensiveDropListScriptGroup
32+
]

0 commit comments

Comments
 (0)