Canonical JSON stringify/parse
I tried to hold to the contract of the JSON global as well as the canonical JSON spec. If you have good ideas on how to test this feel free to suggest / add. Right now I'm not testing it against the RFC but I think we can just test it's working right when we implement hashing.
Message type definitions
This one is pretty big, but I tried to leverage JSON.parse() in conjunction with runtypes to make the checking smooth and as low overhead as possible.
There is one annoying thing about runtypes though, it doesn't support exact shape matching, so I had to get that extension from an issue I've linked to in the relevant part of the codebase. Hopefully the LV Leitung will understand this shameless copy paste :)
Test runner
I just wrote my own in the end, it was quick work, done it before and avoided this mess 🥴
You can see how I intended tests to be written from the example test and fixture files.
Closes #3
This one is big, go commit by commit in review.
Features
Canonical JSON stringify/parse I tried to hold to the contract of the
JSON
global as well as the canonical JSON spec. If you have good ideas on how to test this feel free to suggest / add. Right now I'm not testing it against the RFC but I think we can just test it's working right when we implement hashing.Message type definitions This one is pretty big, but I tried to leverage
JSON.parse()
in conjunction with runtypes to make the checking smooth and as low overhead as possible.There is one annoying thing about runtypes though, it doesn't support exact shape matching, so I had to get that extension from an issue I've linked to in the relevant part of the codebase. Hopefully the LV Leitung will understand this shameless copy paste :)
Test runner I just wrote my own in the end, it was quick work, done it before and avoided this mess 🥴 You can see how I intended tests to be written from the example test and fixture files.