Week 11 of my Google Summer of Code journey with CircuitVerse (August 3rd to August 9th) was all about one thing: testing the canonical pipeline against real circuits.
This week, Aboo suggested verifying canonical import/export against all the projects in CircuitVerse Editor's Picks.
๐งช Testing the Editor's Picks
I created a new editorPicks.spec.ts test file for this.
My first approach was to fetch each project's circuit_data through the CircuitVerse API while the test was running.
After discussing it with my mentors, we changed the approach. Depending on the network/API would make the tests slower and could make them fail for reasons completely unrelated to the canonical pipeline.
So instead, I downloaded the Editor's Picks circuit data and kept all 12 projects as local fixtures inside the test suite.
That made the tests repeatable and gave us a fixed set of real-world circuits to keep checking in the future.
๐ The Round-Trip Test
The test flow was as follows:
1๏ธโฃ Load the original legacy
circuit_datausing CircuitVerse's legacy loader.
2๏ธโฃ Export the loaded project throughcanonicaliseProject().
3๏ธโฃ Import that canonical JSON again throughimportCanonical().
4๏ธโฃ Re-export the reconstructed project.
5๏ธโฃ Compare the hashes and canonical project data.
Basically, if the canonical pipeline is really preserving the project, legacy โ canonical โ import โ canonical should come back to the same result.
That was the theory at least ๐
๐ And... A Lot of Projects Failed
Once I ran the tests across the Editor's Picks, many of the real circuits started failing the round trip.
This was actually useful because the tests immediately exposed things my original pipeline wasn't preserving properly:
- ๐ Complete wire topology: dangling wires, standalone wires and some multi-port/fan-out nets could lose information.
- ๐ Routing and layout details: intermediate routing, port positions and some canvas/subcircuit visual data were incomplete.
- ๐๏ธ Project-level state: things like the project name, clock settings, focused circuit, tab order and annotations were not fully round-tripping.
My earlier tests were mostly hitting the happy path. The Editor's Picks were much bigger and messier, which is exactly why they were such a good test set.
๐ง Back to Research
I spent the rest of the week going through the failed projects one by one and trying to understand what information was being lost and where it should live in the canonical structure.
There were a few design decisions to think through, especially around representing complete wire/routing topology without making the canonical format unnecessarily complicated.
So I did not rush a PR this week.
๐ฎ What's Next
The tests did exactly what good tests are supposed to do โ they broke my assumptions before users did. ๐
Hopefully next week I can start fixing these round-trip gaps and raise a PR with the Editor's Picks verification passing.
Looking forward to next week! ๐
Top comments (0)