-
Notifications
You must be signed in to change notification settings - Fork 496
Feature/fet 1977 alternative migrate tests to foundry #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mdtanrikulu
wants to merge
31
commits into
staging
Choose a base branch
from
feature/fet-1977-alternative-migrate-tests-to-foundry
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
5f80cf4
migrate deploy config to hh3 and rocketh
mdtanrikulu ca3ce81
lint
mdtanrikulu 6e269b0
migrate rest of the deploy scripts
mdtanrikulu f1ce1eb
fmt
mdtanrikulu 633a928
feat: add foundry testing infrastructure
mdtanrikulu ad4a2bf
migrate: move ts test files into testLegacy folder
mdtanrikulu adfcc88
create BaseTest foundation and test utilities
mdtanrikulu dda7eb9
migrate core registry tests to foundry
mdtanrikulu f66d5a5
migrate ETH registrar tests to foundry
mdtanrikulu 71298fe
migrate ReverseRegistrar tests to foundry
mdtanrikulu 3efd9a1
migrate resolver tests
mdtanrikulu d2e7e05
create BaseWrapperTest test foundation, migrate basic wrapper tests
mdtanrikulu 64fe4b5
migrate NameWrapper behavior tests
mdtanrikulu 37135df
migrate NameWrapper functionality tests
mdtanrikulu 94af610
migrate DNSSEC Oracle tests
mdtanrikulu ada94f0
migrate DNSRegistrar tests
mdtanrikulu 095aa56
migrate CCIPRead tests and scripts
mdtanrikulu 5bdc6ed
migrate UniversalResolver tests
mdtanrikulu 9431125
update CI
mdtanrikulu faffffa
Merge branch 'staging' into 'feature/fet-1977-alternative-migrate-tes…
mdtanrikulu 96d98bc
fmt
mdtanrikulu b5dfdf7
update/fix ccipRead tests using MockBatcher
mdtanrikulu 85bf362
add tests for uncovered reverse registrar contracts
mdtanrikulu 37756b1
add tests for uncovered reverse resolver contracts
mdtanrikulu 712a54d
update foundry config
mdtanrikulu 1d6067e
add tests for util contracts
mdtanrikulu 56d0085
update RegisterAndWrapETH2LD
mdtanrikulu c707484
remove legacy test files
mdtanrikulu b293239
migrate build scripts fully and fix local deployment test
mdtanrikulu fd7d4cb
revert and keep fixtures under test folder for deploy scripts
mdtanrikulu 9c5b01e
temp CI update lockfile
mdtanrikulu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [submodule "lib/forge-std"] | ||
| path = lib/forge-std | ||
| url = https://github.com/foundry-rs/forge-std |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,25 @@ | ||
| { | ||
| "typescript.tsdk": "node_modules/typescript/lib" | ||
| "typescript.tsdk": "node_modules/typescript/lib", | ||
| "solidity.remappings": [ | ||
| "@ensdomains/buffer/=node_modules/@ensdomains/buffer/", | ||
| "@ensdomains/solsha1/=node_modules/@ensdomains/solsha1/", | ||
| "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/", | ||
| "@openzeppelin/contracts-v5/=node_modules/@openzeppelin/contracts-v5/", | ||
| "forge-std/=lib/forge-std/src/", | ||
| "test/=test/" | ||
| ], | ||
| "solidity.packageDefaultDependenciesContractsDirectory": "contracts", | ||
| "solidity.packageDefaultDependenciesDirectory": "lib", | ||
| "search.exclude": { | ||
| "**/test/foundry-artifacts": true, | ||
| "**/test/foundry-cache": true, | ||
| "**/node_modules": true, | ||
| "**/cache": true, | ||
| "**/artifacts": true, | ||
| "**/build": true | ||
| }, | ||
| "files.exclude": { | ||
| "**/test/foundry-artifacts": true, | ||
| "**/test/foundry-cache": true | ||
| } | ||
| } |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,25 @@ | ||
| import type { DeployFunction } from 'hardhat-deploy/types.js' | ||
| import { execute, artifacts } from '@rocketh' | ||
|
|
||
| const func: DeployFunction = async function (hre) { | ||
| const { viem } = hre | ||
| export default execute( | ||
| async ({ deploy, get, namedAccounts }) => { | ||
| const { deployer } = namedAccounts | ||
|
|
||
| const registry = await viem.getContract('ENSRegistry') | ||
| const dnssec = await viem.getContract('DNSSECImpl') | ||
| const registry = await get('ENSRegistry') | ||
| const dnssec = await get('DNSSECImpl') | ||
|
|
||
| await viem.deploy('OffchainDNSResolver', [ | ||
| registry.address, | ||
| dnssec.address, | ||
| 'https://dnssec-oracle.ens.domains/', | ||
| ]) | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| func.id = 'OffchainDNSResolver v1.0.0' | ||
| func.tags = ['category:dnsregistrar', 'OffchainDNSResolver'] | ||
| func.dependencies = ['ENSRegistry', 'DNSSECImpl'] | ||
|
|
||
| export default func | ||
| await deploy('OffchainDNSResolver', { | ||
| account: deployer, | ||
| artifact: artifacts.OffchainDNSResolver, | ||
| args: [ | ||
| registry.address, | ||
| dnssec.address, | ||
| 'https://dnssec-oracle.ens.domains/', | ||
| ], | ||
| }) | ||
| }, | ||
| { | ||
| id: 'OffchainDNSResolver v1.0.0', | ||
| tags: ['category:dnsregistrar', 'OffchainDNSResolver'], | ||
| dependencies: ['ENSRegistry', 'DNSSECImpl'], | ||
| }, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,86 @@ | ||
| import type { DeployFunction } from 'hardhat-deploy/types.js' | ||
| import { execute, artifacts } from '@rocketh' | ||
| import type { Hash } from 'viem' | ||
| import { dnsEncodeName } from '../../test/fixtures/dnsEncodeName.js' | ||
|
|
||
| const func: DeployFunction = async function (hre) { | ||
| const { viem } = hre | ||
| export default execute( | ||
| async ({ deploy, execute, namedAccounts }) => { | ||
| const { deployer, owner } = namedAccounts | ||
|
|
||
| const { deployer, owner } = await viem.getNamedClients() | ||
| const psl = await deploy('SimplePublicSuffixList', { | ||
| account: deployer, | ||
| artifact: artifacts.SimplePublicSuffixList, | ||
| args: [], | ||
| }) | ||
|
|
||
| await viem.deploy('SimplePublicSuffixList', []) | ||
| if (!psl.newlyDeployed) { | ||
| return | ||
| } | ||
|
|
||
| const psl = await viem.getContract('SimplePublicSuffixList') | ||
| const listOwner = await psl.read.owner() | ||
| console.log('SimplePublicSuffixList deployed successfully') | ||
|
|
||
| if ( | ||
| owner !== undefined && | ||
| owner.address !== deployer.address && | ||
| listOwner !== owner.address | ||
| ) { | ||
| console.log('Transferring ownership to owner account') | ||
| const hash = await psl.write.transferOwnership([owner.address]) | ||
| console.log(`Transfer ownership (tx: ${hash})...`) | ||
| await viem.waitForTransactionSuccess(hash) | ||
| } | ||
| // Transfer ownership to owner if different from deployer | ||
| if (owner !== deployer) { | ||
| await execute(psl, { | ||
| functionName: 'transferOwnership', | ||
| args: [owner], | ||
| account: deployer, | ||
| }) | ||
| console.log('Transferred ownership to owner account') | ||
| } | ||
|
|
||
| const suffixList = await ( | ||
| await fetch('https://publicsuffix.org/list/public_suffix_list.dat', { | ||
| headers: { | ||
| Connection: 'close', | ||
| }, | ||
| }) | ||
| ).text() | ||
| let suffixes = suffixList | ||
| .split('\n') | ||
| .filter((suffix) => !suffix.startsWith('//') && suffix.trim() != '') | ||
| // Right now we're only going to support top-level, non-idna suffixes | ||
| suffixes = suffixes.filter((suffix) => suffix.match(/^[a-z0-9]+$/)) | ||
| // Fetch and set public suffix list | ||
| const suffixList = await ( | ||
| await fetch('https://publicsuffix.org/list/public_suffix_list.dat', { | ||
| headers: { | ||
| Connection: 'close', | ||
| }, | ||
| }) | ||
| ).text() | ||
|
|
||
| const transactionHashes: Hash[] = [] | ||
| console.log('Starting suffix transactions') | ||
| let suffixes = suffixList | ||
| .split('\n') | ||
| .filter((suffix) => !suffix.startsWith('//') && suffix.trim() != '') | ||
| // Right now we're only going to support top-level, non-idna suffixes | ||
| suffixes = suffixes.filter((suffix) => suffix.match(/^[a-z0-9]+$/)) | ||
|
|
||
| for (let i = 0; i < suffixes.length; i += 100) { | ||
| const batch = suffixes | ||
| .slice(i, i + 100) | ||
| .map((suffix) => dnsEncodeName(suffix)) | ||
| const hash = await psl.write.addPublicSuffixes([batch], { | ||
| account: owner.account, | ||
| }) | ||
| console.log(`Setting suffixes (tx: ${hash})...`) | ||
| transactionHashes.push(hash) | ||
| } | ||
| console.log( | ||
| `Waiting on ${transactionHashes.length} suffix-setting transactions to complete...`, | ||
| ) | ||
| await Promise.all( | ||
| transactionHashes.map((hash) => viem.waitForTransactionSuccess(hash)), | ||
| ) | ||
| console.log(`Starting suffix transactions for ${suffixes.length} suffixes`) | ||
| const totalBatches = Math.ceil(suffixes.length / 100) | ||
| let successfulBatches = 0 | ||
| let failedBatches = 0 | ||
|
|
||
| // Send transactions sequentially to avoid nonce conflicts | ||
| for (let i = 0; i < suffixes.length; i += 100) { | ||
| const batch = suffixes | ||
| .slice(i, i + 100) | ||
| .map((suffix) => dnsEncodeName(suffix)) | ||
|
|
||
| return true | ||
| } | ||
| const batchIndex = Math.floor(i / 100) + 1 | ||
| console.log( | ||
| `Sending suffixes batch ${batchIndex}/${totalBatches} (${batch.length} suffixes)`, | ||
| ) | ||
|
|
||
| func.id = 'SimplePublicSuffixList v1.0.0' | ||
| func.tags = ['category:dnsregistrar', 'SimplePublicSuffixList'] | ||
| func.dependencies = [] | ||
| try { | ||
| await execute(psl, { | ||
| functionName: 'addPublicSuffixes', | ||
| args: [batch], | ||
| account: owner, | ||
| }) | ||
| successfulBatches++ | ||
| console.log(`Batch ${batchIndex} completed successfully`) | ||
| } catch (error) { | ||
| failedBatches++ | ||
| console.error(`Batch ${batchIndex} failed:`, error.message || error) | ||
| // Continue with next batch | ||
| } | ||
| } | ||
|
|
||
| export default func | ||
| console.log( | ||
| `Public suffix list configuration completed: ${successfulBatches} successful, ${failedBatches} failed`, | ||
| ) | ||
| }, | ||
| { | ||
| id: 'SimplePublicSuffixList v1.0.0', | ||
| tags: ['category:dnsregistrar', 'SimplePublicSuffixList'], | ||
| dependencies: [], | ||
| }, | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frozen lockfiles ensure no random transititves get pulled and that the build is reproducible. I suggest to put it back and regenerate the lockfile and commit it to ensure it matches the same one in CI