E2E Testing
The E2E test suite validates compiled withdrawal scripts against a real Cardano devnet.
How it works
Each test case:
- Starts a local Cardano node with devnet genesis
- Connects via Node-to-Client mini-protocols (local state query + local tx submission)
- Registers a script-based staking credential
- Submits a withdrawal transaction with CBOR data in the redeemer
- Asserts acceptance or rejection
sequenceDiagram
participant Test
participant Node as Cardano Node
Test->>Node: Start devnet
Test->>Node: Register staking credential
Note over Node: Wait for block
Test->>Node: Submit withdrawal (key_cbor, value_cbor)
Node-->>Test: Accepted / Rejected
Test cases
Valid CBOR acceptance
Submits a withdrawal with CBOR matching the schema:
- Key:
{"owner": <28 zero bytes>}— valid map with 28-byte bstr - Value:
{"amount": 1, "payload": <4 bytes>}— valid map in canonical order
Expected: transaction accepted.
Invalid CBOR rejection
Submits a withdrawal with invalid CBOR:
- Key:
0x05— a bare uint, not a map - Value:
0x05— same
Expected: transaction rejected (script execution fails).
Running locally
The nix shell provides cardano-node and sets E2E_GENESIS_DIR via the shell hook. Tests take ~18 seconds (mostly devnet startup).
Transaction construction
The test builds withdrawal transactions manually using cardano-ledger types:
- Witnesses are constructed via the
AlonzoTxWitspattern constructor (not lens setters) to ensure correct CBOR serialization - Redeemer:
List [B key_cbor, B value_cbor]with conservative ExUnits - Script integrity hash: computed from language views + redeemers
- Registration: uses
ConwayRegCertwith implicit deposit (SNothing) to avoid requiring a script witness during credential registration
CI
E2E tests run in GitHub Actions on NixOS runners as part of the standard CI pipeline.