Skip to content

fix(scripts): add missing error code variants across all contracts (Fixes #857) - #887

Closed
kleitonbernardino-lab wants to merge 1 commit into
MergeFi:mainfrom
kleitonbernardino-lab:fix/missing-error-codes-857
Closed

kleitonbernardino-lab wants to merge 1 commit into
MergeFi:mainfrom
kleitonbernardino-lab:fix/missing-error-codes-857

Conversation

@kleitonbernardino-lab

Copy link
Copy Markdown

Summary of Changes

This PR updates scripts/error-codes.mjs to synchronize its error mapping tables with the latest error variants in all three contracts (escrow, milestones, and maintenance-pool), addressing #857:

  1. Escrow Contract Errors (contracts/escrow/src/error.rs):
    • Added code 21: ArithmeticOverflow
    • Added code 22: InvalidVersion
    • Added code 24: TooManyRecipients
  2. Milestones Contract Errors (contracts/milestones/src/error.rs):
    • Added code 25: TooManyRecipients
  3. Maintenance Pool Contract Errors (contracts/maintenance-pool/src/error.rs):
    • Added code 20: TooManyRecipients
  4. Test Suite & Parity Invariant (scripts/error-codes.test.mjs):
    • Added unit test coverage asserting each missing variant is properly resolved by decodeErrorCode and formatted without falling back to "No known mapping for error code N".
    • Added automated enum parity tests that read contracts/*/src/error.rs and verify 100% of defined enum variants in Rust match the table in scripts/error-codes.mjs, preventing future drift.

Verification

All unit tests pass cleanly:

$ node --test scripts/error-codes.test.mjs
▶ errorMappings variant coverage (#857)
  ✔ escrow includes ArithmeticOverflow (21), InvalidVersion (22), TooManyRecipients (24)
  ✔ milestones includes TooManyRecipients (25)
  ✔ maintenancePool includes TooManyRecipients (20)
  ✔ decodeErrorCode returns proper meanings for the new error codes
  ✔ formatError does not output 'No known mapping' for the new codes
✔ errorMappings variant coverage (#857)
▶ contract error.rs and error-codes.mjs parity assertion (#857)
  ✔ escrow errorMappings strictly matches contracts/escrow/src/error.rs
  ✔ milestones errorMappings strictly matches contracts/milestones/src/error.rs
  ✔ maintenancePool errorMappings strictly matches contracts/maintenance-pool/src/error.rs
✔ contract error.rs and error-codes.mjs parity assertion (#857)
▶ extractErrorCode & formatError general unit tests
  ✔ returns null for non-error or empty inputs
  ✔ extracts error code from JSON and object structures
  ✔ extracts error code from string regex patterns
  ✔ formatError formats unmapped and unknown codes gracefully
✔ extractErrorCode & formatError general unit tests
ℹ tests 12
ℹ suites 3
ℹ pass 12
ℹ fail 0

Fixes #857.

…ixes MergeFi#857)

Signed-off-by: Kleiton Bernardino <kleiton.bernardino@gmail.com>
@vercel

vercel Bot commented Nov 11, 2026

Copy link
Copy Markdown

@kleitonbernardino-lab is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@chonilius chonilius closed this Nov 12, 2026
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.

scripts/error-codes.mjs is missing the newest error variant of all three contracts, so those failures print 'No known mapping'

2 participants