Skip to content

Strict raw JSON check in RPC snapshot tests#7335

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

Strict raw JSON check in RPC snapshot tests#7335
sudo-shashank wants to merge 7 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

  • Tests
    • Improved RPC snapshot comparisons by automatically excluding known non-deterministic JSON fields, making regression checks more consistent and less prone to spurious differences.
    • Refreshed the affected Filecoin snapshot reference to the latest recorded variant.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The RPC snapshot test runner recursively removes selected fields from successful actual and expected JSON values before comparison. The snapshot manifest references a newer chain-message snapshot file.

Changes

RPC snapshot normalization

Layer / File(s) Summary
Normalize RPC snapshot comparisons
src/tool/subcommands/api_cmd/test_snapshot.rs, src/tool/subcommands/api_cmd/test_snapshots.txt
The test harness filters configured fields from nested JSON values before equality assertions and updates the referenced chain-message snapshot filename.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: RPC, Snapshot

Suggested reviewers: akaladarshi, hanabi1224, lesnyrumcajs

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: stricter raw JSON comparisons in RPC snapshot tests.
Linked Issues check ✅ Passed The PR switches snapshot tests to raw JSON comparison and updates a snapshot file, satisfying #7313.
Out of Scope Changes check ✅ Passed The changes are limited to the requested snapshot-test logic and the regenerated snapshot listing.
✨ 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 96.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 64.65%. Comparing base (17c49db) to head (334fa70).
✅ All tests successful. No failed tests found.

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

... and 10 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 17c49db...334fa70. 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.

Comment thread src/tool/subcommands/api_cmd/test_snapshot.rs Outdated

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/tool/subcommands/api_cmd/test_snapshot.rs`:
- Around line 94-110: The recursive filter_out_fields function removes Duration,
tt, and accessList from every nested object, masking regressions in transaction
and trace payloads. Replace the unrestricted recursive filtering with path-aware
exclusions limited to the intended response shapes, or preserve nested
occurrences for separate comparisons; keep unrelated fields unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 06666847-b38d-46f2-b887-0884f2ad9f0c

📥 Commits

Reviewing files that changed from the base of the PR and between 6f80798 and 4ef7627.

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

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

  • filecoin-project/lotus (manual)

Comment thread src/tool/subcommands/api_cmd/test_snapshot.rs
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