Skip to content

test: mutation-harden log unit coverage#447

Open
thedavidmeister wants to merge 1 commit into
masterfrom
2026-06-15-solver-core-coverage
Open

test: mutation-harden log unit coverage#447
thedavidmeister wants to merge 1 commit into
masterfrom
2026-06-15-solver-core-coverage

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Summary

Mutation-hardens the unit tests for src/core/process/log.ts (transaction-receipt income / clear-amount accounting helpers), the weakest qualifying module found in a scoped adversarial-mutation pass over the core solve/processing logic (src/core/**).

The existing tests asserted only weak properties — a "_18" suffix for getActualPrice, and typeof === "bigint" / > 0n for getTotalIncome — so arithmetic and argument mutations on the actual money math passed undetected. This PR pins the exact computed values and adds the missing branch.

Tests-only. No source changes (git diff src/ is empty apart from the test file).

Mutation matrix (log.ts)

Function · behavior Mutation Before After
getActualPrice · * ONE18 scaling * ONE18/ ONE18 SURVIVED KILLED
getActualPrice · scaleTo18(value, tokenDecimals) decimals arg → 0 SURVIVED KILLED
getTotalIncome · input price/income pairing input branch uses outputTokenPrice SURVIVED KILLED
getTotalIncome · input / ONE18 divisor / ONE18* ONE18 SURVIVED KILLED
getActualClearAmount · AfterClearV2 normalize-fail n/a (new branch coverage) uncovered covered

Already-covered behaviors confirmed by mutation (existing tests killed the mutant): getIncome token-address filter, value compare, and to === signer filter; getActualClearAmount branch selector, Transfer from === ob filter, AfterClear event selection, and AfterClearV2 decimals arg; getActualPrice to === arb / from !== orderbook filters; getTotalIncome both-undefined guard and the sign of the final sum.

What was added / strengthened

  • getActualPrice — strengthened the existing "formatted price" test to pin the exact price; added a non-18 (6) decimals test so the scaleTo18 decimals argument and the ONE18 scaling are both exercised.
  • getTotalIncome — pinned exact per-branch and summed values (4n / 9n / 13n); added a distinct-price/distinct-income case (19n vs swapped 25n) so each income is verified to pair with its own token price and the ONE18 divisor is verified.
  • getActualClearAmount — added a test for the AfterClearV2 normalize-failure branch returning undefined (unparsable aliceOutput).

Exact expected values are deterministic from the test file's existing formatUnits / parseUnits mocks combined with the real scaleTo18, so the assertions discriminate correct vs. mutated output.

Gaps checklist

  • getActualPrice price arithmetic pinned (scaling + divisor + decimals)
  • getTotalIncome exact value, price↔income pairing, and divisor pinned
  • getActualClearAmount AfterClearV2 normalize-failure branch covered
  • No surviving fillable mutants remain in log.ts after this pass
  • Note: removing the if (outputResult.isErr()) guard is an equivalent mutant (an Err result's .value is also undefined), so it is not separately killable; the negated-guard variant is killed by the existing valid-float test.

Verification

  • log.test.ts: 15 → 18 tests, all green on baseline.
  • src/core unit suite: 224 tests green (was 221).
  • tsc -p tsconfig.check.json: clean. eslint: clean.
  • Full vitest unit suite green (the src/logger test requires the project's --disableConsoleIntercept invocation, which is a pre-existing harness quirk, in an out-of-scope module, and passes under its own npm script).
  • e2e / hardhat fork tests are a pre-existing environmental red (RPC/secrets) and are out of scope.

🤖 Generated with Claude Code

Strengthen and extend the unit tests for src/core/process/log.ts so they
kill previously-surviving mutants in the income/clear-amount accounting
helpers. The existing tests asserted only weak properties (a "_18" suffix
for getActualPrice, and typeof/positivity for getTotalIncome), which let
arithmetic and argument mutations pass undetected.

- getActualPrice: pin the exact computed price and add a non-18 decimals
  case so the scaleTo18 decimals argument and the ONE18 scaling are checked.
- getTotalIncome: pin exact per-branch and summed values, and add a case
  with distinct prices and incomes so each income is verified to pair with
  its own token price (not swapped) and the ONE18 divisor is verified.
- getActualClearAmount: cover the AfterClearV2 normalize-failure branch
  returning undefined.

Tests-only; no source changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@thedavidmeister, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 22 minutes and 52 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 586ee743-c82d-4701-9c7d-b28aa5e1e733

📥 Commits

Reviewing files that changed from the base of the PR and between 4928590 and 30c2e0e.

📒 Files selected for processing (1)
  • src/core/process/log.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-06-15-solver-core-coverage

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.

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.

1 participant