Skip to content

Commit

Permalink
Merge pull request #352 from ensdomains/tateb/test-improvements
Browse files Browse the repository at this point in the history
feat: test improvements
  • Loading branch information
talentlessguy authored Jul 5, 2024
2 parents 8e8cf71 + dffbfe4 commit 3c96089
Show file tree
Hide file tree
Showing 169 changed files with 24,005 additions and 29,258 deletions.
44 changes: 22 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,48 @@ jobs:
wiki_address_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js 16
uses: actions/setup-node@v3
- name: Use Bun 1.1.13
uses: oven-sh/setup-bun@v1
with:
node-version: 16
cache: 'yarn'
bun-version: 1.1.13

- run: yarn install --frozen-lockfile
- run: bun install --frozen-lockfile

- name: Run wikiCheck
run: yarn wikiCheck
run: bun run wikiCheck
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js 16
uses: actions/setup-node@v3
- name: Use Bun 1.1.13
uses: oven-sh/setup-bun@v1
with:
node-version: 16
cache: 'yarn'
bun-version: 1.1.13

- run: yarn install --frozen-lockfile
- run: bun install --frozen-lockfile

- name: Run test
run: yarn test
- name: Run tests
run: bun run test:parallel

deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js 16
uses: actions/setup-node@v3
- name: Use Bun 1.1.13
uses: oven-sh/setup-bun@v1
with:
node-version: 16
cache: 'yarn'
bun-version: 1.1.13

- run: yarn install --frozen-lockfile
- run: bun install --frozen-lockfile

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run deploy
run: yarn test:deploy
run: bun run test:deploy
env:
BATCH_GATEWAY_URLS: '["https://universal-offchain-unwrapper.ens-cf.workers.dev/"]'
Binary file added bun.lockb
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 10 additions & 19 deletions deploy/dnsregistrar/00_deploy_offchain_dns_resolver.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import type { DeployFunction } from 'hardhat-deploy/types.js'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments } = hre
const { deploy } = deployments
const { deployer } = await getNamedAccounts()
const func: DeployFunction = async function (hre) {
const { viem } = hre

const registry = await ethers.getContract('ENSRegistry')
const dnssec = await ethers.getContract('DNSSECImpl')
const registry = await viem.getContract('ENSRegistry')
const dnssec = await viem.getContract('DNSSECImpl')

const tx = await deploy('OffchainDNSResolver', {
from: deployer,
args: [
registry.address,
dnssec.address,
'https://dnssec-oracle.ens.domains/',
],
log: true,
})
console.log(`Deployed OffchainDNSResolver to ${tx.address}`)
await viem.deploy('OffchainDNSResolver', [
registry.address,
dnssec.address,
'https://dnssec-oracle.ens.domains/',
])
}

func.tags = ['OffchainDNSResolver']
Expand Down
68 changes: 35 additions & 33 deletions deploy/dnsregistrar/05_deploy_public_suffix_list.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
import { ethers } from 'hardhat'
import packet from 'dns-packet'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import type { DeployFunction } from 'hardhat-deploy/types.js'
import type { Hash } from 'viem'
import { dnsEncodeName } from '../../test/fixtures/dnsEncodeName.js'

function encodeName(name: string) {
return '0x' + packet.name.encode(name).toString('hex')
}
const func: DeployFunction = async function (hre) {
const { viem } = hre

const { deployer, owner } = await viem.getNamedClients()

await viem.deploy('SimplePublicSuffixList', [])

const psl = await viem.getContract('SimplePublicSuffixList')
const listOwner = await psl.read.owner()

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments } = hre
const { deploy } = deployments
const { deployer, owner } = await getNamedAccounts()

await deploy('SimplePublicSuffixList', {
from: deployer,
gasLimit: 10000000,
args: [],
log: true,
})
const psl = await ethers.getContract('SimplePublicSuffixList')
const listOwner = await psl.owner()

if (owner !== undefined && owner !== deployer && listOwner !== owner) {
if (
owner !== undefined &&
owner.address !== deployer.address &&
listOwner !== owner.address
) {
console.log('Transferring ownership to owner account')
const tx = await psl.transferOwnership(owner)
console.log(`Transfer ownership (tx: ${tx.hash})...`)
await tx.wait()
const hash = await psl.write.transferOwnership([owner.address])
console.log(`Transfer ownership (tx: ${hash})...`)
await viem.waitForTransactionSuccess(hash)
}
const publicSuffixList = psl.connect(await ethers.getSigner(owner))

const suffixList = await (
await fetch('https://publicsuffix.org/list/public_suffix_list.dat')
Expand All @@ -37,18 +31,26 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
.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]+$/))
const txes = []

const transactionHashes: Hash[] = []
console.log('Starting suffix transactions')

for (let i = 0; i < suffixes.length; i += 100) {
const batch = suffixes.slice(i, i + 100).map((suffix) => encodeName(suffix))
const tx = await publicSuffixList.addPublicSuffixes(batch)
console.log(`Setting suffixes (tx: ${tx.hash})...`)
txes.push(tx)
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 ${txes.length} suffix-setting transactions to complete...`,
`Waiting on ${transactionHashes.length} suffix-setting transactions to complete...`,
)
await Promise.all(
transactionHashes.map((hash) => viem.waitForTransactionSuccess(hash)),
)
await Promise.all(txes.map((tx) => tx.wait()))
}

func.tags = ['SimplePublicSuffixList']
Expand Down
73 changes: 33 additions & 40 deletions deploy/dnsregistrar/10_deploy_dnsregistrar.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,38 @@
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments } = hre
const { deploy } = deployments
const { deployer, owner } = await getNamedAccounts()

const registry = await hre.deployments.get('ENSRegistry')
const dnssec = await hre.deployments.get('DNSSECImpl')
const resolver = await hre.deployments.get('OffchainDNSResolver')
const oldregistrar = await hre.deployments.getOrNull('DNSRegistrar')
const root = await ethers.getContract('Root')

const publicSuffixList = await ethers.getContract('SimplePublicSuffixList')

const tx = await deploy('DNSRegistrar', {
from: deployer,
args: [
oldregistrar?.address || '0x0000000000000000000000000000000000000000',
resolver.address,
dnssec.address,
publicSuffixList.address,
registry.address,
],
log: true,
})
console.log(`Deployed DNSRegistrar to ${tx.address}`)

if (
owner !== undefined &&
(await root.owner()).toLowerCase() === owner.toLowerCase()
) {
const tx2 = await root
.connect(await ethers.getSigner(owner))
.setController(tx.address, true)
console.log(`Set DNSRegistrar as controller of Root (${tx2.hash})`)
await tx2.wait()
import type { DeployFunction } from 'hardhat-deploy/types.js'
import { zeroAddress } from 'viem'

const func: DeployFunction = async function (hre) {
const { viem } = hre

const { owner } = await viem.getNamedClients()

const registry = await viem.getContract('ENSRegistry')
const dnssec = await viem.getContract('DNSSECImpl')
const resolver = await viem.getContract('OffchainDNSResolver')
const oldregistrar = await viem.getContractOrNull('DNSRegistrar')
const root = await viem.getContract('Root')

const publicSuffixList = await viem.getContract('SimplePublicSuffixList')

const deployment = await viem.deploy('DNSRegistrar', [
oldregistrar?.address || zeroAddress,
resolver.address,
dnssec.address,
publicSuffixList.address,
registry.address,
])

const rootOwner = await root.read.owner()

if (owner !== undefined && rootOwner === owner.address) {
const hash = await root.write.setController([deployment.address, true], {
account: owner.account,
})
console.log(`Set DNSRegistrar as controller of Root (${hash})`)
await viem.waitForTransactionSuccess(hash)
} else {
console.log(
`${owner} is not the owner of the root; you will need to call setController('${tx.address}', true) manually`,
`${owner.address} is not the owner of the root; you will need to call setController('${deployment.address}', true) manually`,
)
}
}
Expand Down
Loading

0 comments on commit 3c96089

Please sign in to comment.