Skip to content

test: add dedicated case for pow round-trip second-leg revert #209

@thedavidmeister

Description

@thedavidmeister

Context: `test/src/lib/LibDecimalFloat.pow.t.sol::testRoundTripFuzzPow` originally only wrapped the first `powExternal(a, b)` in try/catch; the round-trip leg `powExternal(c, inv)` was bare. CI surfaced a counterexample where the second leg reverts with `WithTargetExponentOverflow(2696051936649033486196409040598252262955326698850935392994226984449, 363177628, 0)` — a tiny coefficient combined with a large inverted exponent produces an unrepresentable rescale target during the round-trip.

PR #208 wraps the round-trip in try/catch (treating revert as "can't round-trip this input", same as the first leg). The fuzz test now passes 5000 runs.

But silently catching is loose: we should pin the second-leg-revert path with a dedicated concrete test that:

  1. Constructs the exact counterexample input `(a = bytes32(1), b = bytes32(0xea5a58dfdcc79c60ac38b8284569e4519fda5eaaffec2a3d22027a4af1969e13))`.
  2. Asserts `a.pow(b)` succeeds (the first leg).
  3. Asserts `c.pow(b.inv())` reverts with `WithTargetExponentOverflow(...)` and the exact selector.

This pins the failure mode so a regression that changes which inputs revert vs which round-trip cleanly will surface in a named test instead of being absorbed by the fuzz catch.

Add to `test/src/lib/LibDecimalFloat.pow.t.sol` next to `testRoundTripFuzzPow`.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions