Skip to content

test(integrity): slot-distinctness guard and per-word integrity count assertions#211

Open
thedavidmeister wants to merge 3 commits into
mainfrom
2026-06-20-issue-210-integrity-pointer-tests
Open

test(integrity): slot-distinctness guard and per-word integrity count assertions#211
thedavidmeister wants to merge 3 commits into
mainfrom
2026-06-20-issue-210-integrity-pointer-tests

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Closes #210

Adds three tests to ERC4626Words.extern.pointers.t.sol:

  1. testIntegritySlotsAreDistinctlyAssigned — iterates every 2-byte slot in the freshly-built integrity table and asserts it is non-zero. Catches the case where an opcode is silently omitted from the dispatch table (zero = uninitialized pointer).

  2. testIntegrityConvertToAssetsReturns2Inputs1Output — calls LibOpERC4626ConvertToAssets.integrity(OperandV2.wrap(0), 0, 0) and asserts (inputs, outputs) == (2, 1).

  3. testIntegrityConvertToSharesReturns2Inputs1Output — identical structure for LibOpERC4626ConvertToShares.

The UnexpectedInputs error-selector path (part b of issue #210) requires the bounds-check guard from PR #205, which is not yet merged; that path is deferred to avoid conflict.

Summary by CodeRabbit

  • Tests
    • Improved test coverage for ERC4626 token conversion operations with enhanced integrity verification checks.

… assertions (#210)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Jun 20, 2026
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 20 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 30bae952-3ca0-42dd-a733-d1eba7e10015

📥 Commits

Reviewing files that changed from the base of the PR and between fcd1bd3 and 2426420.

📒 Files selected for processing (2)
  • test/src/concrete/ERC4626Words.extern.pointers.t.sol
  • test/src/concrete/ERC4626Words.parse.t.sol

Walkthrough

Three new test functions are added to ERC4626Words.extern.pointers.t.sol along with supporting imports for extern opcode constants, the pointer table length constant, two integrity libraries, and the OperandV2 type. The tests verify integrity slot distinctness, array length, and that both convertToAssets and convertToShares integrity functions report 2 inputs and 1 output.

Changes

ERC4626 integrity pointer tests

Layer / File(s) Summary
Imports and integrity test functions
test/src/concrete/ERC4626Words.extern.pointers.t.sol
Imports for extern opcode constants, OPCODE_FUNCTION_POINTERS_LENGTH, LibOpERC4626ConvertToAssets, LibOpERC4626ConvertToShares, and OperandV2 are added. Three test functions added: testIntegritySlotsAreDistinctlyAssigned (checks each 2-byte slot is non-zero and array length equals OPCODE_FUNCTION_POINTERS_LENGTH * 2), testIntegrityConvertToAssetsReturns2Inputs1Output, and testIntegrityConvertToSharesReturns2Inputs1Output (each asserts (inputs=2, outputs=1) from the respective integrity function).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main additions: slot-distinctness guard tests and per-word integrity count assertions, matching the primary changes in the PR.
Linked Issues check ✅ Passed The PR implements the slot-distinctness guard test and integrity input/output count assertions for both ERC4626 words, directly addressing objectives 1 and 2(a) from issue #210.
Out of Scope Changes check ✅ Passed All changes are scoped to test additions for ERC4626 integrity validation; no unrelated code modifications or feature implementations are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-06-20-issue-210-integrity-pointer-tests

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.

@thedavidmeister

Copy link
Copy Markdown
Contributor Author

Rework note (human reject, 2026-07-04): testIntegritySlotsAreDistinctlyAssigned asserts slot != 0, which is NON-ZERO, not DISTINCT — two opcodes colliding on one integrity slot (the exact self-consistent-but-wrong case #210 names) passes. Implement pairwise inequality across the table (or argue on the issue if deliberately shared integrity fns should be legitimate). #210's second ask — the END-TO-END integrity path: bad-arity source through the real parse/deploy path asserting the EXACT integrity error selector — is absent entirely; the direct-call 2-in/1-out units are fine as bonus but do not cover it. Re-attempt with both asks genuinely met, then Closes #210.

…gnment naming

Rework per the trusted rework note on #211:

- End-to-end integrity leg: three parse2 tests drive bad-arity sources
  (too-few and too-many inputs for erc4626-convert-to-assets, too-few for
  erc4626-convert-to-shares) through the real subparser + deploy path and
  pin the EXACT ExternIntegrityInputsMismatch(bytecodeInputs, 2) revert
  data. Mutation-validated: with integrity mutated to return (1,1) all
  three fail (revert data no longer matches); green on baseline (116/116).

- Pairwise-distinctness leg: renamed testIntegritySlotsAreDistinctlyAssigned
  to testIntegritySlotsAreAssigned (it asserts non-zero, not distinctness)
  and documented why distinctness is not asserted — both words' integrity
  functions are extensionally identical ((2,1)) so solc deduplicates them to
  one pointer (committed table hex"0c830c83"); a pairwise-inequality
  assertion reds on correct code. The distinctness design question is
  raised on #210 for a ruling.

Co-Authored-By: Claude <noreply@anthropic.com>
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

🤖 ai:producer
Producer note: reworked per the rework note at head 2426420. (1) E2E integrity leg added — three parse2 bad-arity tests pin the exact ExternIntegrityInputsMismatch revert data through the real subparser+deploy path; mutation-validated (integrity mutated to (1,1) → all three fail on revert-data mismatch; 116/116 green on baseline). (2) Pairwise distinctness is unimplementable-as-green on this repo: the committed table is hex"0c830c83" — both words share ONE integrity pointer because their integrity functions are extensionally identical and solc deduplicates them; the test is renamed to the honest testIntegritySlotsAreAssigned (non-zero) and the distinctness question is raised on #210 as a design ruling (per the note's 'or argue on the issue' branch).

@thedavidmeister thedavidmeister added ai:ready AI vetter: passes review, ready for human decision and removed human:reject Human reviewer: needs rework labels Jul 19, 2026
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

🤖 ai:vetter
Reviewed 2426420: ready — closes #210 — E2E bad-arity parse2 tests pin exact ExternIntegrityInputsMismatch revert data per human rework note; distinctness resolved via the note's argue-on-issue branch (solc dedupes identical integrity fns, test renamed honestly); mutations killed
cost 300 — integrity table + E2E arity tests

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

Labels

ai:ready AI vetter: passes review, ready for human decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add deferred integrity-pointer tests from #29: slot-distinctness guard + end-to-end integrity-path (input counts + error selector)

1 participant