Skip to content

test(extern): assert sub-parser honors overridden extern() address#230

Open
thedavidmeister wants to merge 4 commits into
mainfrom
2026-06-25-issue-42-extern-override-seam-test
Open

test(extern): assert sub-parser honors overridden extern() address#230
thedavidmeister wants to merge 4 commits into
mainfrom
2026-06-25-issue-42-extern-override-seam-test

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

`ERC4626SubParser.erc4626ConvertToAssetsSubParser` and its shares sibling call `extern()` — a virtual method — to obtain the extern contract address encoded into the emitted `ExternDispatchV2` constant. Any derived contract can override `extern()` to split the subparser and extern into separate deployments. Nothing tested that the sub-parser actually reads from the override rather than a hardcoded `address(this)`.

What

Adds `ERC4626SubParserSplitExternWrapper` — a test contract that overrides `extern()` to return `address(0xdead)` — and `testSubParserHonorsOverriddenExtern`, which:

  1. Calls both `convertToAssetsSubParserPublic` and `convertToSharesSubParserPublic` on the split wrapper.
  2. Asserts the emitted `ExternDispatchV2` constants encode `address(0xdead)`, not `address(splitWords)`.
  3. Asserts the result differs from what `address(this)` would produce.

Mutation-validated: replacing `extern()` with `address(this)` in `ERC4626SubParser` causes the assertion to fail with the correct mismatch message.

Closes #42

Co-Authored-By: Claude noreply@anthropic.com

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for sub-parser behavior when an external address is overridden, helping ensure results are generated from the correct source.
    • Added coverage for asset and share conversion paths to prevent regressions in encoded output handling.

Adds ERC4626SubParserSplitExternWrapper — a test contract that overrides
extern() to return an arbitrary address — and testSubParserHonorsOverriddenExtern
which calls both word-parser functions and asserts the emitted ExternDispatchV2
constant encodes the overridden address, not address(this).

Mutation-validated: replacing extern() with address(this) in
ERC4626SubParser causes the assertion to fail.

Closes #42

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

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: eb3ee565-d206-4e1e-b602-96f2e78d396d

📥 Commits

Reviewing files that changed from the base of the PR and between 14acd39 and f9b47a0.

📒 Files selected for processing (2)
  • test/src/abstract/ERC4626SubParser.wordParsers.t.sol
  • test/src/abstract/ERC4626SubParserSplitExtern.wrapper.sol

Walkthrough

Adds a test-only derived wrapper that injects a custom extern() address, then verifies the sub-parser encodes both assets and shares dispatch constants against that overridden address instead of the contract address.

Changes

ERC4626 subparser extern override coverage

Layer / File(s) Summary
Split extern wrapper and encoding test
test/src/abstract/ERC4626SubParserSplitExtern.wrapper.sol, test/src/abstract/ERC4626SubParser.wordParsers.t.sol
ERC4626SubParserSplitExternWrapper overrides extern() with an injected address, and the new test asserts the parsed assets and shares dispatch constants encode that overridden extern target.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 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 clearly and concisely describes the added test for honoring an overridden extern() address.
Linked Issues check ✅ Passed The changes add the requested coverage for a subclass overriding extern() and verify the emitted extern target matches the override.
Out of Scope Changes check ✅ Passed The PR appears scoped to the requested test coverage and wrapper needed to validate extern() override behavior.
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-25-issue-42-extern-override-seam-test

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 and others added 3 commits June 25, 2026 05:22
…apper

Collapse the two-line import to a single line (forge fmt canonical form)
so that the copy-artifacts diff-check sees no stale artifacts.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

extern() override seam in derived contracts untested

1 participant