fix(dpp): add missing #[test] attribute to should_set_empty_schema_defs#3101
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughBoth v0 and v1 schema modules add a test verifying behavior when Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
3fa4706 to
2935852
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/rs-dpp/src/data_contract/v1/methods/schema.rs (1)
179-213: Consider asserting document_types are still populated after clearing defs.The test verifies that
schema_defsbecomesNone, but does not confirm thatdocument_typesremains intact — which is the other observable side-effect ofset_schema_defs. Adding this assertion would close a small coverage gap and guard against future regressions in theset_document_schemascall insideset_schema_defs.💡 Suggested additional assertion
data_contract .set_schema_defs(None, true, &mut vec![], platform_version) .expect("should set defs"); assert_eq!(None, data_contract.schema_defs()) + assert_eq!(1, data_contract.document_types().len(), "document_types should be preserved after clearing schema_defs"); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/rs-dpp/src/data_contract/v1/methods/schema.rs` around lines 179 - 213, The test currently only asserts that schema_defs() becomes None after calling DataContractV1::set_schema_defs, but doesn't assert that document_schemas remain populated; update the test to also assert the document_schemas (or document_types) are still present on the data_contract after set_schema_defs returns (e.g., call data_contract.document_schemas() or the appropriate getter on the DataContractV1 instance and assert it contains the previously inserted "document_type_name" schema), so set_schema_defs/DataContractV1::set_document_schemas behavior is covered.packages/rs-dpp/src/data_contract/v0/methods/schema.rs (1)
208-213: Consider asserting document type integrity after clearing defs.The current assertion only verifies the
schema_defspostcondition. Adding a check thatdocument_types/document_schemas()are still intact after theset_schema_defs(None, …)call would make the test more comprehensive and guard against an accidental wipe of document types.➕ Proposed additional assertion
data_contract .set_schema_defs(None, true, &mut vec![], platform_version) .expect("should set defs"); + assert_eq!(1, data_contract.document_types().len(), "document types should be preserved after clearing schema defs"); assert_eq!(None, data_contract.schema_defs()) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/rs-dpp/src/data_contract/v0/methods/schema.rs` around lines 208 - 213, The test currently only checks that schema_defs() is None after calling data_contract.set_schema_defs(None, true, &mut vec![], platform_version); add an assertion to also verify that document type schemas remain intact — e.g., capture the pre-call document_schemas()/document_types() state, call set_schema_defs(...), then assert equality with data_contract.document_schemas() (or data_contract.document_types()) so clearing defs does not accidentally wipe document schemas; reference the methods set_schema_defs, schema_defs(), and document_schemas()/document_types() to locate where to add this assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/rs-dpp/src/data_contract/v0/methods/schema.rs`:
- Around line 208-213: The test currently only checks that schema_defs() is None
after calling data_contract.set_schema_defs(None, true, &mut vec![],
platform_version); add an assertion to also verify that document type schemas
remain intact — e.g., capture the pre-call document_schemas()/document_types()
state, call set_schema_defs(...), then assert equality with
data_contract.document_schemas() (or data_contract.document_types()) so clearing
defs does not accidentally wipe document schemas; reference the methods
set_schema_defs, schema_defs(), and document_schemas()/document_types() to
locate where to add this assertion.
In `@packages/rs-dpp/src/data_contract/v1/methods/schema.rs`:
- Around line 179-213: The test currently only asserts that schema_defs()
becomes None after calling DataContractV1::set_schema_defs, but doesn't assert
that document_schemas remain populated; update the test to also assert the
document_schemas (or document_types) are still present on the data_contract
after set_schema_defs returns (e.g., call data_contract.document_schemas() or
the appropriate getter on the DataContractV1 instance and assert it contains the
previously inserted "document_type_name" schema), so
set_schema_defs/DataContractV1::set_document_schemas behavior is covered.
397720f to
b4ee514
Compare
The #[test] attribute fix and schema_defs test improvements for should_set_empty_schema_defs are already covered by PR dashpay#3101. Removing duplicates to keep PRs independent.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Both v0 and v1 DataContract schema test modules had should_set_empty_schema_defs() defined inside #[cfg(test)] but missing the #[test] attribute. The test runner silently skipped them.
Address CodeRabbit nitpick: add assertions that document_types remain intact after set_schema_defs(None, ...) in both v0 and v1 tests.
b4ee514 to
3762dc7
Compare
The #[test] attribute fix and schema_defs test improvements for should_set_empty_schema_defs are already covered by PR dashpay#3101. Removing duplicates to keep PRs independent.
The #[test] attribute fix and schema_defs test improvements for should_set_empty_schema_defs are already covered by PR dashpay#3101. Removing duplicates to keep PRs independent.
The #[test] attribute fix and schema_defs test improvements for should_set_empty_schema_defs are already covered by PR dashpay#3101. Removing duplicates to keep PRs independent.
The #[test] attribute fix and schema_defs test improvements for should_set_empty_schema_defs are already covered by PR dashpay#3101. Removing duplicates to keep PRs independent.
Problem
should_set_empty_schema_defs()exists in both v0 and v1 DataContract schema test modules inside#[cfg(test)] mod tests, but was shipped without the#[test]attribute. The test runner silently skips these functions — they compile but never execute.Introduced in #3077 (
d6f4eb9, @shumkov) — the function was added to the test module but the#[test]attribute was never included. The test was DOA from day one. 🍝Additionally, the test body used
document_schemas: Default::default()(emptyBTreeMap), which now fails validation withDocumentTypesAreMissingError. Fixed by adding a minimal document schema matching the pattern from the adjacentshould_set_a_new_schema_defstest.Fix
#[test]attribute to both v0 and v1 versionscargo test -p dpp --lib -- should_set_empty_schema_defsFiles changed
2 files —
packages/rs-dpp/src/data_contract/{v0,v1}/methods/schema.rsFound during SDK test quality audit (tracker thepastaclaw/tracker#12).
Summary by CodeRabbit