Skip to content

test(cbor): Populate golden cases for all structs the encoder handles - #4049

Open
RafaelGranza wants to merge 1 commit into
refactor/encoder-to-utils-cborfrom
test/cbor-golden-populated
Open

test(cbor): Populate golden cases for all structs the encoder handles#4049
RafaelGranza wants to merge 1 commit into
refactor/encoder-to-utils-cborfrom
test/cbor-golden-populated

Conversation

@RafaelGranza

@RafaelGranza RafaelGranza commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

User description

Adds cases for every struct CBOR encodes in production, and its populated version.

The golden test also asserts the decoded value equals the expected struct, so the Go side is covered too.

No need to do the check bucket by bucket.


PR Type

Tests


Description

  • Add populated golden cases for encoder structs

  • Add transaction, state, journal, and metadata coverage

  • Add expected CBOR bytes for new golden cases


File Walkthrough

Relevant files
Tests
golden_test.go
Expand populated CBOR golden test cases                                   

utils/cbor/v1/golden_test.go

  • Import migration package for SchemaMetadata golden case
  • Add populated golden cases for core, pathdb, and migration structs
  • Add helper builders for transactions, classes, state, and journals
  • Extend golden tests for encoder/decoder round-trip coverage
+150/-0 
on_disk_bytes.json
Add expected CBOR bytes for new cases                                       

utils/cbor/v1/testdata/on_disk_bytes.json

  • Add expected serialized CBOR bytes for new golden cases
  • Include transaction, StateUpdate, journal, and SchemaMetadata bytes
  • Extend test data for populated struct assertions
+13/-0   

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Reviewing PR #4049

  • Gather context (diff, files, repo conventions)
  • Review golden_test.go for correctness/coverage
  • Review testdata/on_disk_bytes.json changes
  • Post findings

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 90
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.17%. Comparing base (2b5452a) to head (8a32e4f).

Additional details and impacted files
@@                        Coverage Diff                         @@
##           refactor/encoder-to-utils-cbor    #4049      +/-   ##
==================================================================
- Coverage                           79.30%   79.17%   -0.13%     
==================================================================
  Files                                 465      465              
  Lines                               35786    35795       +9     
==================================================================
- Hits                                28381    28342      -39     
- Misses                               7396     7444      +48     
  Partials                                9        9              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@RafaelGranza
RafaelGranza force-pushed the test/cbor-golden-populated branch from ed2c758 to 8a32e4f Compare September 8, 2026 04:17
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Claude finished @RafaelGranza's task in 4m 55s —— View job


Reviewing PR #4049

  • Gather context (diff, files, repo conventions)
  • Review golden_test.go for correctness/coverage
  • Review testdata/on_disk_bytes.json changes
  • Post findings

Summary

Clean, no issues found.

This PR adds populated golden cases for the CBOR encoder/decoder covering DeclareTransaction, DeployTransaction, L1HandlerTransaction, DeployAccountTransaction, DeprecatedCairoClass, StateUpdate, and the pathdb journal types, alongside a handful of zero-value structs (L1Head, BlockCommitments, BlockTransactionsIndexes, migration.SchemaMetadata) that weren't previously covered at all.

Checked:

  • Every populated struct literal (populatedDeclareTransaction, populatedDeployAccountTransaction, populatedStateUpdate, etc.) matches its type's actual field set in core/transaction.go, core/state_update.go, and core/trie2/triedb/pathdb/journal.go — no stale/renamed fields.
  • The new migration import is actually used (migration.SchemaMetadata), not a stray import.
  • TestGoldenBytes already asserts len(goldenCases()) == len(golden), so the new cases and the new on_disk_bytes.json entries stay in lock-step — no orphaned vectors possible.
  • Round-trip coverage: the test doesn't just diff hex, it decodes each golden vector back via reflection and compares against the original struct (golden_test.go:346-348), so this also catches decode-side regressions, not just encode-side ones.
  • CI's ubuntu-arm64-4-core "Run Tests" job has already completed successfully, confirming the golden vectors and round-trip assertions actually pass (not just eyeballed correct).

No correctness, concurrency, or resource-safety concerns — this is additive test-only content with no production code changes.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Standalone PR Review

PR-Agent could not safely update the persistent review. This standalone result will not replace the canonical review.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 95
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant