-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: test that deploy offchain in the layer 2. #53
Conversation
packages/client/README
Outdated
|
||
4. With the local Hardhat node running, execute the E2E tests: | ||
````cmd | ||
yarn client hardhat test ./test/l2_e2e.spec.ts --network localhost |
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.
this could be a script on the client's package.json as well.
perhaps even following this example
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.
I tryed to use a script, but it was not possible to run the node and the tests in parallel. Maybe we can work on this improviment later.
|
||
|
||
|
||
# Running Tests with Local Arbitrum Node |
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.
# Running Tests with Local Arbitrum Node | |
## Running Tests with Local Arbitrum Node |
packages/client/test/l2_e2e.spec.ts
Outdated
import { localhost } from 'viem/chains' | ||
import { createTestClient, http, publicActions } from 'viem' | ||
import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers' | ||
// import { expect } from 'chai' |
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.
// import { expect } from 'chai' |
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.
It will be used after the gatway_l2 implementation. That is why it was not removed.
packages/client/test/l2_e2e.spec.ts
Outdated
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.
maybe this file could be called arbitrum_e2e.spec.ts
since we might want to integrate other L2's in the near future
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.
Nice call.
packages/client/test/l2_e2e.spec.ts
Outdated
async function deployOffchainResolver(): Promise<void> { | ||
const walletForL2 = new Wallet(devAccountPrivateKey) | ||
const l2Signer = walletForL2.connect(l2Provider) | ||
|
||
const ResolverContract = await new eth.ContractFactory( | ||
abiOffchainResolver, | ||
bytecodeOffchainResolver, | ||
l2Signer, | ||
).deploy(gatewayUrl, signers) | ||
|
||
offchainResolver = await eth.getContractAt( | ||
abiOffchainResolver, | ||
await ResolverContract.getAddress(), | ||
) | ||
console.log('Offchain resolver: ', await ResolverContract.getAddress()) | ||
} | ||
|
||
// Function to deploy registry contract | ||
async function deployRegistry(): Promise<void> { | ||
const l1Signer = await l1Provider.getSigner(devAccountPublicKey) | ||
const RegistryContract = await new eth.ContractFactory( | ||
abiRegistry, | ||
bytecodeRegistry, | ||
l1Signer, | ||
).deploy() | ||
|
||
registry = await eth.getContractAt( | ||
abiRegistry, | ||
await RegistryContract.getAddress(), | ||
) | ||
console.log('Registry: ', await RegistryContract.getAddress()) | ||
|
||
await (registry.connect(l1Signer) as Contract).setSubnodeRecord( | ||
root, | ||
labelhash('eth'), | ||
l1Signer, | ||
await offchainResolver.getAddress(), | ||
10000000, | ||
) | ||
await (registry.connect(l1Signer) as Contract).setSubnodeRecord( | ||
namehash('eth'), | ||
labelhash('offchain'), | ||
l1Signer, | ||
await offchainResolver.getAddress(), | ||
10000000, | ||
) | ||
} |
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.
this could be shared with the other e2e
spec file
packages/client/test/l2_e2e.spec.ts
Outdated
// console.log('ok!') | ||
// try { | ||
// await client.getEnsAvatar({ | ||
// name: ensAddress, | ||
// universalResolverAddress: | ||
// (await UniversalResolverContract.getAddress()) as `0x${string}`, | ||
// }) | ||
// } catch (error) { | ||
// const customError = error as BaseError | ||
// console.log(customError.message) | ||
// // expect(customError.message).contain('HTTP request failed') | ||
// } |
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.
is this commented out on purpose?
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.
It will be used after the gatway_l2 implementation. That is why it was not removed.
the client's |
@@ -2,7 +2,7 @@ | |||
"name": "@blockful/client", | |||
"packageManager": "yarn@4.1.0", | |||
"scripts": { | |||
"test": "vitest run", | |||
"test": "yarn hardhat test ./test/arbitrum_e2e.spec.ts --network localhost", |
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.
"test": "yarn hardhat test ./test/arbitrum_e2e.spec.ts --network localhost", | |
"test:arb": "yarn hardhat test ./test/arbitrum_e2e.spec.ts --network localhost", |
@@ -2,7 +2,7 @@ | |||
"name": "@blockful/client", | |||
"packageManager": "yarn@4.1.0", | |||
"scripts": { | |||
"test": "vitest run", | |||
"test": "yarn hardhat test ./test/arbitrum_e2e.spec.ts --network localhost", | |||
"test:watch": "vitest", |
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.
remove this line
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.
rename this file to deploys.ts
import { normalize } from 'viem/ens' | ||
import { localhost } from 'viem/chains' | ||
import { createTestClient, http, publicActions } from 'viem' | ||
const gatewayUrl = 'http://127.0.0.1:3000' |
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.
const gatewayUrl = 'http://127.0.0.1:3000' | |
const gatewayUrl = 'http://127.0.0.1:3000/{sender}/{data}.json' |
before(async () => { | ||
const signers = await eth.getSigners() | ||
|
||
const walletForL2 = new Wallet(devAccountPrivateKey) |
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.
try using viem instead: https://viem.sh/docs/ethers-migration#viem-11
const gatewayUrl = 'http://127.0.0.1:3000' | ||
|
||
// Providers | ||
const l2Provider = new eth.JsonRpcProvider('http://127.0.0.1:8547') |
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.
try using viem instead: https://viem.sh/docs/ethers-migration#viem-1
const offchainResolverContract = await deployOffchainResolver( | ||
l2Signer, | ||
gatewayUrl, | ||
signers as unknown as string, |
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.
double-check this conversion
because the offchain part is not implemented yet. | ||
*/ | ||
it('Call ENS flow with viem.', async () => { | ||
// ENS address |
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.
// ENS address |
|
||
// Deploying the contracts | ||
const offchainResolverContract = await deployOffchainResolver( | ||
l2Signer, |
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.
I think this should be deployed on L1 and the PublicResolver on the L2
feat: test that deploys offchain in the layer 2
All Submissions:
Description
Pull request will add an other test file that deploys the contracts in the Arbitrum local node. This way it will be possibly to test the complete flow of interactions including l2 contracts.
Related Issue
#51
#47
Changes
Changes to Core Features: