Skip to content

fix: honor skipCompare in hexEqual matcher - #400

Open
Kewe63 wants to merge 1 commit into
circlefin:mainfrom
Kewe63:fix/hex-equal-skip-compare
Open

Kewe63 wants to merge 1 commit into
circlefin:mainfrom
Kewe63:fix/hex-equal-skip-compare

Conversation

@Kewe63

@Kewe63 Kewe63 commented Sep 13, 2026

Copy link
Copy Markdown

Summary

  • honor the declared SkipCompare contract in the custom hexEqual matcher
  • skip hexadecimal validation when the expected value is the sentinel
  • add regression coverage through the registered Chai plugin

Fixes #399

Root cause

types.d.ts allows SkipCompare as the hexEqual argument, but supportHexEqual() validated the sentinel object with isHex() before applying any skip behavior. The generic skippable plugin only wraps built-in comparison methods, so it could not intercept the custom matcher.

Changes

  • detect SkipCompare before validating hexadecimal operands
  • exercise hexEqual(skipCompare) in the existing matcher test suite

Testing

  • RED, before the implementation change:
    • npx hardhat test ./tests/helpers/matchers/index.test.ts --no-compile
    • result: 14 passing, 1 failing
    • failure: skipCompare was rejected as an invalid hex string
  • GREEN, after the implementation change:
    • npx hardhat test ./tests/helpers/matchers/index.test.ts --no-compile
    • result: 15 passing
  • make test-unit-hardhat
    • result: 37 passing
  • npx eslint tests/helpers/matchers/Hex.ts tests/helpers/matchers/index.test.ts
    • passed
  • npx prettier --check tests/helpers/matchers/Hex.ts tests/helpers/matchers/index.test.ts
    • passed

Risk

Low. The early return applies only to the existing SkipCompare sentinel. Normal equality, inequality, case-insensitive comparison, and invalid-hex validation retain their existing paths and coverage.

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

Labels

None yet

1 participant