Skip to content

Use import.sol instead of npmFilesToBuild for test dependencies - #324

Open
Amxx wants to merge 3 commits into
hardhat3from
hardhat3-import-mocks
Open

Amxx wants to merge 3 commits into
hardhat3from
hardhat3-import-mocks

Conversation

@Amxx

@Amxx Amxx commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Uses a single mechanism to get artifacts for the dependencies that the tests deploy, instead of three.

Replace npmFilesToBuild with import.sol

Hardhat 3 only emits artifacts for compilation roots, so importing a contract is not enough to get its artifact. However, with exposed.imports, the exposed plugin generates a $-prefixed version of every contract that contracts/mocks/import.sol imports by name, and those are roots. import.sol already provided $AccessManager, $ERC721, $Create2, etc. this way.

CallReceiverMock, UpgradeableBeacon, ERC7913P256Verifier and ERC7913RSAVerifier move from npmFilesToBuild to import.sol, and the tests now deploy their $ versions. Those are subclasses with extra $-prefixed functions; no test depends on the exact ABI or bytecode.

Replace the extra paths.sources entry with a mock

ECDSAOwnedDKIMRegistry was built by adding lib/email-tx-builder/packages/contracts/src/utils as a source directory. Its exposed version cannot be used: with exposed.initializers, its constructor runs the initializer, so initialize reverts (and dkimRegistry / signer are never set). Instead, ECDSAOwnedDKIMRegistryMock (an empty subclass declared in contracts/mocks) is a root and gets a plain artifact. This also stops compiling the unrelated contracts of that directory.

Upgradeable patch

The patch is updated for the new paths.sources. It also deletes ECDSAOwnedDKIMRegistryMock: the transpiler keeps it as-is (it already inherits Initializable), which would duplicate the copy that the tests get from lib/openzeppelin-community-contracts (HHE1001).

Testing

  • npx hardhat test mocha: 1460 passing, 2 pending
  • npm run lint:sol, forge build: pass
  • tests-upgradeable steps, run locally (copy, transpile, npm run test, test:inheritance, test:pragma): pass

Amxx added 2 commits November 17, 2026 16:05
Hardhat 3 does not emit artifacts for contracts that are only imported, but the
exposed plugin (with `exposed.imports`) generates a `$`-prefixed version of every
contract that import.sol imports by name, and those are compilation roots. Use
that single mechanism for every dependency the tests deploy.
…e directory

The exposed version of ECDSAOwnedDKIMRegistry cannot be used: with
`exposed.initializers`, its constructor runs the initializer, so `initialize`
reverts. A mock declared in the project sources is a compilation root, so it gets
a plain artifact. This also stops compiling the unrelated contracts of that
directory.
@Amxx
Amxx requested a review from a team as a code owner November 17, 2026 15:05
Copilot AI balanced review requested due to automatic review settings November 17, 2026 15:05
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4c136dbf-7c3d-4dbc-a4ff-e3088fd7d210

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified in the test dependency artifact-generation changes.

No open issues 🎉

What changed in this PR

Simplifies test dependency artifact generation by using local compilation roots and the existing exposed-contract mechanism instead of separate Hardhat build configuration.

Changes:

  • Moves four dependencies into import.sol and updates tests to deploy their $-prefixed versions.
  • Adds a plain ECDSAOwnedDKIMRegistryMock subclass to preserve explicit initialization in tests.
  • Removes npmFilesToBuild and the extra dependency source directory from Hardhat configuration.
File Description
test/​utils/​cryptography/​ZKEmailUtils.test.js Deploys the new DKIM registry mock.
test/​proxy/​HybridProxy.test.js Deploys $UpgradeableBeacon.
test/​account/​RoleAccountFactory.test.js Deploys $CallReceiverMock.
test/​account/​modules/​ERC7579SignatureValidator.test.js Deploys exposed P256 and RSA verifiers.
test/​account/​modules/​ERC7579SelectorExecutor.test.js Deploys $CallReceiverMock.
test/​account/​modules/​ERC7579MultisigWeighted.test.js Deploys $CallReceiverMock.
test/​account/​modules/​ERC7579MultisigStorage.test.js Deploys $CallReceiverMock.
test/​account/​modules/​ERC7579Multisig.test.js Deploys $CallReceiverMock.
test/​account/​modules/​ERC7579Executor.test.js Deploys $CallReceiverMock.
test/​account/​modules/​ERC7579DelayedExecutor.test.js Deploys $CallReceiverMock.
test/​account/​AccountZKEmail.test.js Uses the exposed call receiver and new registry mock.
test/​account/​AccountERC7913.test.js Uses the exposed call receiver and new registry mock.
hardhat.config.ts Removes explicit dependency build entries and the extra source directory.
contracts/​mocks/​utils/​cryptography/​ECDSAOwnedDKIMRegistryMock.sol Adds a compilation root for the plain registry artifact.
contracts/​mocks/​import.sol Adds four named imports and documents exposed artifact generation.

Review effort: Balanced

The transpiler keeps ECDSAOwnedDKIMRegistryMock as-is (it already inherits
Initializable), which would duplicate the copy that the tests get from
lib/openzeppelin-community-contracts. The patch deletes it.
Copilot AI balanced review requested due to automatic review settings November 17, 2026 15:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the test dependency artifact generation changes.

No open issues 🎉

Review effort: Balanced

@Amxx

Amxx commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Closed in favor of #325

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.

2 participants