Skip to content

Strict raw JSON check in RPC snapshot tests#7335

Open
sudo-shashank wants to merge 3 commits into
mainfrom
shashank/strict-json-check
Open

Strict raw JSON check in RPC snapshot tests#7335
sudo-shashank wants to merge 3 commits into
mainfrom
shashank/strict-json-check

Conversation

@sudo-shashank

@sudo-shashank sudo-shashank commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary of changes

Changes introduced in this pull request:

  • Implement strict raw-JSON check in RPC snapshot tests, skipping non-deterministic (tt, Duration) and known-divergent (accessList, lotus#12214) fields before comparing.

Reference issue to close (if applicable)

Closes #7313

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • Bug Fixes

    • Improved RPC snapshot comparisons by ignoring known non-deterministic fields, producing more reliable regression results.
    • Applied consistent filtering to nested JSON objects and arrays during comparisons.
  • Tests

    • Updated the affected Filecoin RPC snapshot reference to the latest expected result.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR switches RPC regression tests to raw JSON comparison and updates snapshots, matching issue #7313.
Out of Scope Changes check ✅ Passed The changes stay focused on RPC snapshot comparison and snapshot regeneration, with no clear unrelated additions.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: stricter raw JSON comparisons in RPC snapshot tests.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shashank/strict-json-check
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch shashank/strict-json-check

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/tool/subcommands/api_cmd/test_snapshot.rs (1)

84-101: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add focused tests for recursive field stripping.

Cover nested objects, arrays, exact key matching, and preservation of similarly named fields. This helper globally removes fields from every RPC response, so regression coverage is valuable for preventing over- or under-stripping.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tool/subcommands/api_cmd/test_snapshot.rs` around lines 84 - 101, Add
focused unit tests for strip_skipped_fields covering skipped fields in nested
objects and array elements, exact key matching, and preservation of similarly
named non-skipped fields. Use representative serde_json::Value inputs and assert
the transformed values retain all unrelated data while removing only keys listed
in SKIPPED_COMPARISON_FIELDS.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/tool/subcommands/api_cmd/test_snapshot.rs`:
- Around line 84-101: Add focused unit tests for strip_skipped_fields covering
skipped fields in nested objects and array elements, exact key matching, and
preservation of similarly named non-skipped fields. Use representative
serde_json::Value inputs and assert the transformed values retain all unrelated
data while removing only keys listed in SKIPPED_COMPARISON_FIELDS.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a0eee4b3-7e2a-4c75-971a-2766b2a67736

📥 Commits

Reviewing files that changed from the base of the PR and between 4928229 and 547955b.

📒 Files selected for processing (2)
  • src/tool/subcommands/api_cmd/test_snapshot.rs
  • src/tool/subcommands/api_cmd/test_snapshots.txt
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)

@sudo-shashank sudo-shashank marked this pull request as ready for review July 10, 2026 06:24
@sudo-shashank sudo-shashank requested a review from a team as a code owner July 10, 2026 06:24
@sudo-shashank sudo-shashank requested review from LesnyRumcajs and akaladarshi and removed request for a team July 10, 2026 06:24
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 64.44%. Comparing base (4928229) to head (547955b).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/tool/subcommands/api_cmd/test_snapshot.rs 93.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/tool/subcommands/api_cmd/test_snapshot.rs 84.00% <93.75%> (+1.11%) ⬆️

... and 13 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4928229...547955b. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


/// JSON fields removed from both actual and expected responses before the
/// strict raw-JSON snapshot comparison. See each group below for why.
const SKIPPED_COMPARISON_FIELDS: &[&str] = &[

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not great to globally ignore fields with a given name. The ignores should be scoped to given methods.

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.

Strict raw JSON check in RPC snapshot tests

2 participants