Skip to content

Add wire codec roundtrip fuzz test generator#87

Open
dillonkearns wants to merge 1 commit intolamdera:lamdera-nextfrom
dillonkearns:add/wire-roundtrip-fuzz-tests
Open

Add wire codec roundtrip fuzz test generator#87
dillonkearns wants to merge 1 commit intolamdera:lamdera-nextfrom
dillonkearns:add/wire-roundtrip-fuzz-tests

Conversation

@dillonkearns
Copy link
Copy Markdown
Collaborator

Hey @supermario, I thought I'd add a random generator to try to surface any problematic permutations in types for the wire codecs. I was able to find one case that has errors, which I'll share in a separate issue or PR shortly.

For now, this PR adds an elm-pages + elm-codegen based generator that randomly creates Elm type definitions (unions, records, extensible records, alias chains, cross-module references) weighted toward edge cases, then generates elm-test fuzz tests running the wire codecs in a roundtrip test.

Run with: cd test/scenario-alltypes && bash run-roundtrip-tests.sh

The generator produces 15 type scenarios including extensible record alias chains, cross-module references, overlapping fields, deep alias chains, many-variant unions, and two-level extensible chains. The two-level extensible chain scenario surfaces a known bug where the wire codec generator loses fields when an extensible record extends another extensible record.

Happy to discuss if you have any feedback, and if you don't want to add this to the codebase no worries, still useful for running separately if you don't want to pull it in to this project directly! Just thought I'd share.

Adds an elm-pages + elm-codegen based generator that randomly creates Elm
type definitions (unions, records, extensible records, alias chains, cross-module
references) weighted toward edge cases, then generates elm-test fuzz tests
proving the compiler-generated wire codecs are correct via roundtrip testing.

Run with: cd test/scenario-alltypes && bash run-roundtrip-tests.sh

The generator produces 15 type scenarios including extensible record alias
chains, cross-module references, overlapping fields, deep alias chains,
many-variant unions, and two-level extensible chains. The two-level extensible
chain scenario surfaces a known bug where the wire codec generator loses fields
when an extensible record extends another extensible record.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@miniBill
Copy link
Copy Markdown
Member

Thank you! This seems super useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants