test(lotus_json): assert LotusJson<Option<T>> is nullable in schema#7347
test(lotus_json): assert LotusJson<Option<T>> is nullable in schema#73470xDevNinja wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
WalkthroughChangesLotusJson schema nullability
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
LGTM, thanks! There is an outstanding lint issue to fix tho. |
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 62 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
sudo-shashank
left a comment
There was a problem hiding this comment.
lint:spellcheck failing
Add a regression test verifying that the JSON/OpenRPC schema generated for LotusJson<Option<T>> permits null (is optional), while the non-optional LotusJson<T> counterpart does not. Closes ChainSafe#4331
de41e74 to
375530d
Compare
|
Good catch, thanks. Fixed the spellcheck failure by rewording the doc comment to avoid the word that tripped the dictionary. Should be green now. |
Summary
Closes #4331.
LotusJson<Option<T>>delegates its schema toOption<T::LotusJson>, whichschemarsalready renders as nullable ("type": [..., "null"]/ anullbranch inanyOf). This adds a small regression test locking that behaviour in, as suggested in the issue — verifying that:LotusJson<Option<T>>produces a schema that permitsnull(i.e. is optional in the OpenRPC spec), andLotusJson<T>counterpart does not permitnull.The helper
schema_allows_nullaccepts both the"type"union form (used for primitives/arrays) and theanyOf/oneOfform (used for$refobject types), so the test stays robust across inner types.No production code changes — test only.
Reference tests
cargo test -p forest-filecoin --lib lotus_json::opt::— 3 passed (existing snapshot + quickcheck, plus the newoptional_is_nullable_in_schema).Other information and links
Issue originally raised by @ruseinov in #4330 (comment).
Summary by CodeRabbit
nullin generated JSON/OpenRPC schemas.nullin the corresponding schemas.