IntersectMBO / cardano-ledger

The ledger implementation and specifications of the Cardano blockchain.
Apache License 2.0
256 stars 158 forks source link

Test Conway CDDL using Cuddle #4437

Closed nc6 closed 2 months ago

nc6 commented 3 months ago

Description

This PR introduces cuddle, a Haskell library for declaring and validating CDDL documents.

This is then used to reflect the Conway CDDL specification (in eras/conway/impl/src/Cardano/Ledger/Conway/CDDL.hs) using a DSL known as Huddle.

libs/cardano-ledger-binary/testlib/Test/Cardano/Ledger/Binary/Cuddle.hs introduces utilities to run CDDL conformance tests using cuddle. These are currently based on a Huddle declaration, but it would be equally possible to use a native CDDL specification combined with cuddle's CBOR generators.

eras/conway/impl/test/Test/Cardano/Ledger/Conway/Binary/CddlSpec.hs then introduces a new set of tests based in the Huddle conway specification. The existing test suite is left untouched for now.

Checklist

nc6 commented 3 months ago

Note that I have #4461 addressed, but planned to include that in a subsequent PR to avoid inflating this one.