Skip to content

Conversation

@wolf31o2
Copy link
Member

@wolf31o2 wolf31o2 commented Nov 18, 2025

Summary by CodeRabbit

  • Tests
    • Added automated coverage checks to ensure every certificate type constant is represented in tests.
    • Refactored tests to reduce duplication by reusing a centralized test dataset for certificate-type validations, preserving existing assertions with minor structural cleanup.

@wolf31o2 wolf31o2 requested a review from a team as a code owner November 18, 2025 14:41
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 18, 2025

📝 Walkthrough

Walkthrough

Adds a shared certificateTypeTests table and refactors TestCertificateTypeMethods in ledger/common/common_test.go to reuse that table. Introduces TestCertificateTypeCoverage(t *testing.T), which uses reflection to ensure every CertificateType constant is represented in the shared test table. Existing tests are retained but now reference the shared table; only minor composite-literal formatting changes were made.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify the reflection logic correctly identifies all CertificateType constants and that the underlying type assumption (uint) is valid.
  • Confirm TestCertificateTypeCoverage accurately collects tested types from certificateTypeTests and will fail only when a constant is genuinely missing.
  • Check certificateTypeTests includes the intended mapping for every CertificateType variant.
  • Review minor formatting changes in TestCertificateTypeMethods to ensure no behavioral change.

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test(ledger): verify all cert types' directly and clearly describes the main change: adding test coverage verification for all certificate types.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/all-cert-types

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 889d75d and baeff1d.

📒 Files selected for processing (1)
  • ledger/common/common_test.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ledger/common/common_test.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (go)

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.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 910b0da and 889d75d.

📒 Files selected for processing (1)
  • ledger/common/common_test.go (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
ledger/common/common_test.go (2)
ledger/common/certs.go (41)
  • PoolRetirementCertificate (617-623)
  • CertificateTypePoolRetirement (36-36)
  • RegistrationCertificate (787-793)
  • CertificateTypeRegistration (39-39)
  • DeregistrationCertificate (828-834)
  • CertificateTypeDeregistration (40-40)
  • VoteDelegationCertificate (869-875)
  • CertificateTypeVoteDelegation (41-41)
  • CertificateTypeStakeRegistration (32-32)
  • Certificate (127-132)
  • StakeRegistrationCertificate (220-225)
  • StakeDeregistrationCertificate (256-261)
  • CertificateTypeStakeDeregistration (33-33)
  • StakeDelegationCertificate (294-300)
  • CertificateTypeStakeDelegation (34-34)
  • PoolRegistrationCertificate (435-448)
  • CertificateTypePoolRegistration (35-35)
  • GenesisKeyDelegationCertificate (653-660)
  • CertificateTypeGenesisKeyDelegation (37-37)
  • MoveInstantaneousRewardsCertificate (733-738)
  • CertificateTypeMoveInstantaneousRewards (38-38)
  • StakeVoteDelegationCertificate (915-922)
  • CertificateTypeStakeVoteDelegation (42-42)
  • StakeRegistrationDelegationCertificate (964-971)
  • CertificateTypeStakeRegistrationDelegation (43-43)
  • VoteRegistrationDelegationCertificate (1007-1014)
  • CertificateTypeVoteRegistrationDelegation (44-44)
  • StakeVoteRegistrationDelegationCertificate (1055-1063)
  • CertificateTypeStakeVoteRegistrationDelegation (45-45)
  • AuthCommitteeHotCertificate (1116-1122)
  • CertificateTypeAuthCommitteeHot (46-46)
  • ResignCommitteeColdCertificate (1162-1168)
  • CertificateTypeResignCommitteeCold (47-47)
  • RegistrationDrepCertificate (1211-1218)
  • CertificateTypeRegistrationDrep (48-48)
  • DeregistrationDrepCertificate (1262-1268)
  • CertificateTypeDeregistrationDrep (49-49)
  • UpdateDrepCertificate (1303-1309)
  • CertificateTypeUpdateDrep (50-50)
  • LeiosEbCertificate (1352-1361)
  • CertificateTypeLeiosEb (51-51)
ledger/compat.go (4)
  • PoolRetirementCertificate (66-66)
  • Certificate (64-64)
  • StakeDelegationCertificate (68-68)
  • PoolRegistrationCertificate (67-67)
🔇 Additional comments (1)
ledger/common/common_test.go (1)

935-936: ****

The original review comment is based on a false premise. LeiosEb is tested in TestCertificateTypeCoverage (line 902), not TestCertificateTypeMethods (lines 747-899)—these are two separate test functions. LeiosEbCertificate.Type() is correctly implemented and returns uint(CertificateTypeLeiosEb). The absence of a CertType field is intentional; unlike other certificate types, LeiosEbCertificate implements Type() directly without storing the type as a field. No issues or test coverage gaps exist.

Likely an incorrect or invalid review comment.

Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
@wolf31o2 wolf31o2 force-pushed the test/all-cert-types branch from 889d75d to baeff1d Compare November 18, 2025 15:31
@wolf31o2 wolf31o2 merged commit cc7fa2d into main Nov 18, 2025
10 checks passed
@wolf31o2 wolf31o2 deleted the test/all-cert-types branch November 18, 2025 17:32
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.

3 participants