Skip to content
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

temporary fix of ccip tests #182

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 26 additions & 72 deletions packages/ensjs/src/functions/public/ccip.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { createPublicClient, http } from 'viem'
import { goerli, mainnet } from 'viem/chains'
import { mainnet } from 'viem/chains'
import { describe, expect, it, vi } from 'vitest'
import { addEnsContracts } from '../../contracts/addEnsContracts.js'
import { ccipRequest } from '../../utils/ccipRequest.js'
import batch from './batch.js'
import getAddressRecord from './getAddressRecord.js'
import getRecords from './getRecords.js'
import getText from './getTextRecord.js'
// import getText from './getTextRecord.js'

vi.setConfig({
testTimeout: 30000,
})

const goerliPublicClient = createPublicClient({
chain: addEnsContracts(goerli),
transport: http('https://goerli.gateway.tenderly.co/4imxc4hQfRjxrVB2kWKvTo'),
})

const mainnetPublicClient = createPublicClient({
chain: addEnsContracts(mainnet),
transport: http('https://mainnet.gateway.tenderly.co/4imxc4hQfRjxrVB2kWKvTo'),
Expand All @@ -25,90 +20,50 @@ const mainnetPublicClient = createPublicClient({
describe('CCIP', () => {
describe('getRecords', () => {
it('should return records from a ccip-read name', async () => {
const result = await getRecords(goerliPublicClient, {
name: '1.offchainexample.eth',
texts: ['email', 'description'],
contentHash: true,
coins: ['ltc', '60'],
const result = await getRecords(mainnetPublicClient, {
name: 'sg.offchaindemo.eth',
// texts: ['email', 'description'],
// contentHash: true,
coins: ['60'],
})
expect(result).toMatchInlineSnapshot(`
{
"coins": [
{
"id": 2,
"name": "ltc",
"value": "MQMcJhpWHYVeQArcZR3sBgyPZxxRtnH441",
},
{
"id": 60,
"name": "eth",
"value": "0x41563129cDbbD0c5D3e1c86cf9563926b243834d",
},
],
"contentHash": {
"decoded": "bafybeico3uuyj3vphxpvbowchdwjlrlrh62awxscrnii7w7flu5z6fk77y",
"protocolType": "ipfs",
},
"resolverAddress": "0xEE28bdfBB91dE63bfBDA454082Bb1850f7804B09",
"texts": [
{
"key": "email",
"value": "[email protected]",
},
{
"key": "description",
"value": "hello offchainresolver wildcard record",
"value": "0x80c5657CEE59A5a193EfDCfDf3D3913Fad977B61",
},
],
"resolverAddress": "0xDB34Da70Cfd694190742E94B7f17769Bc3d84D27",
}
`)
})
it('should return records from a ccip-read name with custom ccipRequest', async () => {
const goerliWithEns = addEnsContracts(goerli)
const goerliWithEns = addEnsContracts(mainnet)
const goerliPublicClientWithCustomCcipRequest = createPublicClient({
chain: goerliWithEns,
transport: http(
'https://goerli.gateway.tenderly.co/4imxc4hQfRjxrVB2kWKvTo',
'https://mainnet.gateway.tenderly.co/4imxc4hQfRjxrVB2kWKvTo',
),
ccipRead: {
request: ccipRequest(goerliWithEns),
},
})
const result = await getRecords(goerliPublicClientWithCustomCcipRequest, {
name: '1.offchainexample.eth',
texts: ['email', 'description'],
contentHash: true,
coins: ['ltc', '60'],
name: 'sg.offchaindemo.eth',
coins: ['60'],
})
expect(result).toMatchInlineSnapshot(`
{
"coins": [
{
"id": 2,
"name": "ltc",
"value": "MQMcJhpWHYVeQArcZR3sBgyPZxxRtnH441",
},
{
"id": 60,
"name": "eth",
"value": "0x41563129cDbbD0c5D3e1c86cf9563926b243834d",
},
],
"contentHash": {
"decoded": "bafybeico3uuyj3vphxpvbowchdwjlrlrh62awxscrnii7w7flu5z6fk77y",
"protocolType": "ipfs",
},
"resolverAddress": "0xEE28bdfBB91dE63bfBDA454082Bb1850f7804B09",
"texts": [
{
"key": "email",
"value": "[email protected]",
},
{
"key": "description",
"value": "hello offchainresolver wildcard record",
"value": "0x80c5657CEE59A5a193EfDCfDf3D3913Fad977B61",
},
],
"resolverAddress": "0xDB34Da70Cfd694190742E94B7f17769Bc3d84D27",
}
`)
})
Expand Down Expand Up @@ -138,39 +93,38 @@ describe('CCIP', () => {
describe('batch', () => {
it('allows batch ccip', async () => {
const result = await batch(
goerliPublicClient,
getAddressRecord.batch({ name: '1.offchainexample.eth' }),
getAddressRecord.batch({ name: '1.offchainexample.eth', coin: 'ltc' }),
getText.batch({ name: '1.offchainexample.eth', key: 'email' }),
mainnetPublicClient,
getAddressRecord.batch({ name: 'sg.offchaindemo.eth' }),
getAddressRecord.batch({ name: 'sg.offchaindemo.eth', coin: '60' }),
// getText.batch({ name: '1.offchainexample.eth', key: 'email' }),
)
expect(result).toMatchInlineSnapshot(`
[
{
"id": 60,
"name": "eth",
"value": "0x41563129cDbbD0c5D3e1c86cf9563926b243834d",
"value": "0x80c5657CEE59A5a193EfDCfDf3D3913Fad977B61",
},
{
"id": 2,
"name": "ltc",
"value": "MQMcJhpWHYVeQArcZR3sBgyPZxxRtnH441",
"id": 60,
"name": "eth",
"value": "0x80c5657CEE59A5a193EfDCfDf3D3913Fad977B61",
},
"[email protected]",
]
`)
})
it('allows nested batch ccip', async () => {
const result = await batch(
goerliPublicClient,
batch.batch(getAddressRecord.batch({ name: '1.offchainexample.eth' })),
mainnetPublicClient,
batch.batch(getAddressRecord.batch({ name: 'sg.offchaindemo.eth' })),
)
expect(result).toMatchInlineSnapshot(`
[
[
{
"id": 60,
"name": "eth",
"value": "0x41563129cDbbD0c5D3e1c86cf9563926b243834d",
"value": "0x80c5657CEE59A5a193EfDCfDf3D3913Fad977B61",
},
],
]
Expand Down
Loading