Skip to content

cleanup: remove TestBed and duplicate SimpleTest mock plumbing#246

Open
alexshchur wants to merge 30 commits intomasterfrom
tests/cleanup
Open

cleanup: remove TestBed and duplicate SimpleTest mock plumbing#246
alexshchur wants to merge 30 commits intomasterfrom
tests/cleanup

Conversation

@alexshchur
Copy link
Copy Markdown
Contributor

@alexshchur alexshchur commented May 4, 2026

Remove the remaining legacy TestBed surface and clean up duplicated SimpleTest plumbing across the mock stack.

The main change is that the Hardhat integrations now only auto-deploy the core mock contracts. TestBed / SimpleTest is no longer treated as a special runtime mock and should be deployed explicitly by tests that need it.

What changed

  • removed TestBed from @cofhe/mock-contracts
  • removed getTestBed() / TestBed mock access from the Hardhat plugins
  • removed deployTestBed / auto-deployment of SimpleTest from the Hardhat mock deployment flow
  • removed TEST_BED_ADDRESS from @cofhe/sdk
  • removed the duplicate SimpleTest wrapper/export from @cofhe/mock-contracts
  • updated docs and tests to deploy SimpleTest explicitly from the shared fixture/artifact where needed

Breaking changes

  • hre.cofhe.mocks.getTestBed() is gone
  • Hardhat 3 no longer exposes cofhe.mocks.TestBed
  • Hardhat mock deployment no longer accepts deployTestBed
  • SimpleTest is no longer auto-deployed as part of the mock environment
  • TEST_BED_ADDRESS is no longer exported from @cofhe/sdk
  • @cofhe/mock-contracts no longer ships the duplicate SimpleTest wrapper/artifact surface

Note

Medium Risk
Medium risk because it removes exported constants/types and changes Hardhat plugin APIs/behavior (no TestBed descriptor, no deployTestBed option), which can break existing tests and integrations expecting auto-deployed helper contracts.

Overview
Removes the legacy TestBed helper contract surface across the mock stack and makes Hardhat integrations auto-deploy only the core mock contracts.

Hardhat v2 and v3 plugins drop TestBed deployment/injection (deployTestBed option, cofhe.mocks.TestBed, and hre.cofhe.mocks.getTestBed()), and docs/tests are updated to deploy SimpleTest explicitly from @cofhe/test-setup artifacts when needed.

@cofhe/mock-contracts stops shipping/exporting TestBed artifacts/types (and related generated files), @cofhe/sdk removes TEST_BED_ADDRESS, and Foundry + integration test setups add @cofhe/test-setup remappings/dependencies to use the shared SimpleTest fixture.

Reviewed by Cursor Bugbot for commit 67c7be3. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cofhesdk-docs-gh-action Ready Ready Preview, Comment May 8, 2026 7:00am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
cofhesdk-docs Ignored Ignored May 8, 2026 7:00am

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

🦋 Changeset detected

Latest commit: 67c7be3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@cofhe/sdk Minor
@cofhe/mock-contracts Minor
@cofhe/hardhat-plugin Minor
@cofhe/hardhat-3-plugin Minor
@cofhe/abi Minor
@cofhe/react Minor
@cofhe/site Minor
@cofhe/example-react Minor
@cofhe/foundry-plugin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@alexshchur alexshchur changed the title chore: cleanup duplicated SimpleTest cleanup: remove TestBed and duplicate SimpleTest mock plumbing May 5, 2026
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.

Once credits are available, reopen this pull request to trigger a review.

Copy link
Copy Markdown
Collaborator

@architect-dev architect-dev left a comment

Choose a reason for hiding this comment

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

In the hardhat-plugin-test package we're using the SimpleTest by fetching the artifact from the test-setup, but I think we should be able to import the contract directly and deploy it with the standard hardhat deployment pipeline. I think how its set up in this PR means that it will always be type any since we no longer have the typechain coming from mock-contracts. Is this a real issue or is it already handled?

Most everything looks great, a few small changes I've noted though.

Comment thread packages/foundry-plugin/foundry.toml Outdated
"@fhenixprotocol/cofhe-contracts/=node_modules/@fhenixprotocol/cofhe-contracts/",
"@cofhe/mock-contracts/=node_modules/@cofhe/mock-contracts/"
"@cofhe/mock-contracts/=node_modules/@cofhe/mock-contracts/",
"@cofhe/test-setup/=../../test/setup/"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe better to import the @cofhe/test-setup package and pull the contract from node_modules? This feels somewhat brittle to me

Comment on lines 5 to 19
const fixedContracts = {
MockTaskManager: TASK_MANAGER_ADDRESS,
MockZkVerifier: MOCKS_ZK_VERIFIER_ADDRESS,
MockThresholdNetwork: MOCKS_THRESHOLD_NETWORK_ADDRESS,
TestBed: TEST_BED_ADDRESS,
MockTaskManager: {
fixedAddress: TASK_MANAGER_ADDRESS,
inspectTarget: 'MockTaskManager',
},
MockZkVerifier: {
fixedAddress: MOCKS_ZK_VERIFIER_ADDRESS,
inspectTarget: 'MockZkVerifier',
},
MockThresholdNetwork: {
fixedAddress: MOCKS_THRESHOLD_NETWORK_ADDRESS,
inspectTarget: 'MockThresholdNetwork',
},
};

const nonFixedContracts = {
MockACL: true,
MockACL: {
inspectTarget: 'MockACL',
},
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If we're switching to use the inspectTarget (which I like by the way), then this should be cleaned up. Instead of a keyed object lets just use an array Array<{ fixedAddress?: Hex, inspectTarget: string }>. If fixed address is populated then we do a fixed address deployment, if its undefined we'll do a variable address deployment.

Comment on lines 40 to 56
@@ -52,8 +57,8 @@ export const ${name}Artifact = ${JSON.stringify(artifact, null, 2)} as const sat
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lets extract this out into a fn writeFixedAddressArtifact, and below lines 63-77 extract out writeVariableAddressArtifact.


for (const [name, fixedAddress] of Object.entries(fixedContracts)) {
const abi = inspect(name, 'abi');
for (const [name, { fixedAddress, inspectTarget }] of Object.entries(fixedContracts)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

With a single array of contracts to deploy we don't need to do Object.entries anymore

import { describe, it, beforeEach } from 'node:test';
import assert from 'node:assert/strict';
import { network } from 'hardhat';
import SimpleTestArtifact from '../../setup/out/SimpleTest.sol/SimpleTest.json';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should be able to import from @cofhe/test-setup right?

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 75502f1. Configure here.

Comment thread test/hardhat-3-plugin-test/test/deploy-mocks.test.ts Outdated
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