Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Nov 28, 2023
1 parent 10a0244 commit 35e58bc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/services/ens/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { logError } from '../exceptions'
const rpcProvider = {
resolveName: jest.fn(() => Promise.resolve('0x0000000000000000000000000000000000000000')),
lookupAddress: jest.fn(() => Promise.resolve('safe.eth')),
getNetwork: jest.fn(() => Promise.resolve({ chainId: 1 })),
} as unknown as JsonRpcProvider

const badRpcProvider = {
Expand All @@ -19,6 +20,10 @@ jest.mock('../exceptions', () => ({
logError: jest.fn(),
}))

jest.mock('./custom', () => ({
customResolveName: jest.fn(() => Promise.resolve('0x0000001111111111111111111111111111111111')),
}))

describe('domains', () => {
describe('isDomain', () => {
it('should check the domain format', async () => {
Expand All @@ -40,6 +45,15 @@ describe('domains', () => {
expect(address).toBe(undefined)
expect(logError).toHaveBeenCalledWith('101: Failed to resolve the address', 'bad resolveName')
})

it('should look up names on Sepolia', async () => {
// mock rpcProvider
const rpcProvider = {
getNetwork: jest.fn(() => Promise.resolve({ chainId: 11155111 })),
} as unknown as JsonRpcProvider

expect(await resolveName(rpcProvider, 'sepolia.eth')).toBe('0x0000001111111111111111111111111111111111')
})
})

describe('lookupAddress', () => {
Expand Down

0 comments on commit 35e58bc

Please sign in to comment.