Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
sammyluo committed Oct 16, 2024
1 parent d8665a4 commit abd3c72
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 26 deletions.
12 changes: 10 additions & 2 deletions src/tests/Uns.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import nock from 'nock';
import Resolution from '../index';
import ResolutionError, {ResolutionErrorCode} from '../errors/resolutionError';
import {NullAddress} from '../types';
Expand Down Expand Up @@ -35,6 +36,11 @@ import Zns from '../Zns';
import {EthereumNetworks} from '../utils';

describe('UNS', () => {
beforeEach(() => {
nock.cleanAll();
jest.restoreAllMocks();
});

describe('constructor', () => {
it('should define the default uns contract', () => {
const uns = new Uns({
Expand Down Expand Up @@ -1215,7 +1221,8 @@ describe('UNS', () => {
'udtestdev-265f8f.crypto',
);
expect(registryAddress).toBe(
UnsConfig.networks[5].contracts.CNSRegistry.address,
UnsConfig.networks[EthereumNetworks[ETH_L1_TESTNET_NAME]].contracts
.CNSRegistry.address,
);
});

Expand All @@ -1231,7 +1238,8 @@ describe('UNS', () => {
);
const registryAddress = await uns.registryAddress('some-domain.888');
expect(registryAddress).toBe(
UnsConfig.networks[5].contracts.UNSRegistry.address,
UnsConfig.networks[EthereumNetworks[ETH_L1_TESTNET_NAME]].contracts
.UNSRegistry.address,
);
});

Expand Down
9 changes: 5 additions & 4 deletions src/tests/UnsInternal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import {ResolutionError, ResolutionErrorCode} from '../errors/resolutionError';
import {eip137Namehash, fromHexStringToDecimals} from '../utils/namehash';
import Networking from '../utils/Networking';
import {EthereumNetworks} from '../utils';

let unsInternalL1: UnsInternal;
let unsInternalL2: UnsInternal;
Expand Down Expand Up @@ -364,7 +365,7 @@ describe('UnsInternal', () => {
expect(location['udtestdev-check.wallet']).toEqual({
registryAddress: '0x070e83FCed225184E67c86302493ffFCDB953f71',
resolverAddress: '0x070e83FCed225184E67c86302493ffFCDB953f71',
networkId: 5,
networkId: EthereumNetworks[ETH_L1_TESTNET_NAME],
blockchain: BlockchainType.ETH,
ownerAddress: '0x0e43F36e4B986dfbE1a75cacfA60cA2bD44Ae962',
blockchainProviderUrl: getProtocolLinkFromEnv(
Expand All @@ -375,7 +376,7 @@ describe('UnsInternal', () => {
expect(location['brad.crypto']).toEqual({
registryAddress: '0x801452cFAC27e79a11c6b185986fdE09e8637589',
resolverAddress: '0x95AE1515367aa64C462c71e87157771165B1287A',
networkId: 5,
networkId: EthereumNetworks[ETH_L1_TESTNET_NAME],
blockchain: BlockchainType.ETH,
ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7',
blockchainProviderUrl: getProtocolLinkFromEnv(
Expand All @@ -400,7 +401,7 @@ describe('UnsInternal', () => {
expect(location['udtestdev-test-l2-domain-784391.wallet']).toEqual({
registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93',
resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93',
networkId: 80001,
networkId: EthereumNetworks[POL_L2_TESTNET_NAME],
blockchain: BlockchainType.POL,
ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7',
blockchainProviderUrl: getProtocolLinkFromEnv(
Expand All @@ -424,7 +425,7 @@ describe('UnsInternal', () => {
expect(location['0xtestdomain-dev-test.wallet']).toEqual({
registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93',
resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93',
networkId: 80001,
networkId: EthereumNetworks[POL_L2_TESTNET_NAME],
blockchain: BlockchainType.POL,
ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7',
blockchainProviderUrl: getProtocolLinkFromEnv(
Expand Down
61 changes: 41 additions & 20 deletions src/tests/testData/mockData.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"params": [
{
"data": "0x4f558e7940920d1d24c83454d9d64e6666927f3abb97b3fd67c7e1bf43de5c2f4297f3b8",
"to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2"
"to": "0x109e7315189e476ab21166955a0fb9be9b531bec"
},
"latest"
]
Expand All @@ -101,7 +101,7 @@
"params": [
{
"data": "0x4f558e791e3f482b3363eb4710dae2cb2183128e272eafbe137f686851c1caea32502230",
"to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2"
"to": "0x109e7315189e476ab21166955a0fb9be9b531bec"
},
"latest"
]
Expand Down Expand Up @@ -142,7 +142,7 @@
"params": [
{
"data": "0x4f558e79644d751c0e0112006e6d5d5d9234c9d3fae5a4646ff88a754d7fa1ed09794e94",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
Expand All @@ -164,7 +164,7 @@
"params": [
{
"data": "0x4f558e794118ebbd893ecbb9f5d7a817c7d8039c1bd991b56ea243e2ae84d0a1b2c950a7",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
Expand All @@ -184,7 +184,7 @@
"params": [
{
"data": "0x4f558e790f4a10a4f46c288cea365fcf45cccf0e9d901b945b9829ccdb54c10dc3cb7a6f",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
Expand All @@ -204,7 +204,7 @@
"params": [
{
"data": "0x4f558e795c828ec285c0bf152a30a325b3963661a80cb87641d60920344caf04d4a0f31e",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
Expand All @@ -224,7 +224,7 @@
"params": [
{
"data": "0x4f558e791e3f482b3363eb4710dae2cb2183128e272eafbe137f686851c1caea32502230",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
Expand All @@ -246,7 +246,7 @@
"params": [
{
"data": "0x4f558e790f4a10a4f46c288cea365fcf45cccf0e9d901b945b9829ccdb54c10dc3cb7a6f",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
Expand All @@ -265,15 +265,16 @@
"method": "eth_call",
"params": [
{
"data": "0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000e4933c051d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000377b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f977b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f9756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e500000000000000000000000000000000000000000000000000000000"
"data": "0x4f558e79ed0afd72b0ca62d74b891a3c8a70d90f88b8c386f188fd455bc53f58f0079334",
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
},
"RESPONSE": {
"jsonrpc": "2.0",
"id": 1,
"result": "0x0000000000000000000000000000000000000000000000000000000000000001"
"result": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
Expand Down Expand Up @@ -323,7 +324,7 @@
"params": [
{
"data": "0x4f558e79ed0afd72b0ca62d74b891a3c8a70d90f88b8c386f188fd455bc53f58f0079334",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
Expand Down Expand Up @@ -364,15 +365,15 @@
"params": [
{
"data": "0xa81ce6f970702ccf2d95c2c8ff666f5e4dde0ed0e83d7d7407fff6f593d4e277aac0a40c",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
},
"RESPONSE": {
"jsonrpc": "2.0",
"id": 1,
"result": "0x000000000000000000000000801452cFAC27e79a11c6b185986fdE09e8637589"
"result": "0x000000000000000000000000Ab005176D74900A9c25fDA144e2f9f329A409166"
}
},
{
Expand All @@ -384,15 +385,15 @@
"params": [
{
"data": "0xa81ce6f98e3f4a48d9806259e049ea529c5be0c6433ff147ad781caf8014d196c388e1df",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
},
"RESPONSE": {
"jsonrpc": "2.0",
"id": 1,
"result": "0x000000000000000000000000070e83FCed225184E67c86302493ffFCDB953f71"
"result": "0x000000000000000000000000DD907B4d80B4a979fd77eE502580c55F2700292c"
}
},
{
Expand All @@ -411,7 +412,27 @@
"RESPONSE": {
"jsonrpc": "2.0",
"id": 1,
"result": "0x000000000000000000000000070e83FCed225184E67c86302493ffFCDB953f71"
"result": "0x000000000000000000000000DD907B4d80B4a979fd77eE502580c55F2700292c"
}
},
{
"METHOD": "POST",
"REQUEST": {
"jsonrpc": "2.0",
"id": "1",
"method": "eth_call",
"params": [
{
"data": "0xa81ce6f98e3f4a48d9806259e049ea529c5be0c6433ff147ad781caf8014d196c388e1df",
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
},
"RESPONSE": {
"jsonrpc": "2.0",
"id": 1,
"result": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
{
Expand All @@ -423,7 +444,7 @@
"params": [
{
"data": "0xa81ce6f99319b0a972ee595115c81afa667fc78253ff07a82fc635b39d528c759c979ebc",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
Expand All @@ -445,7 +466,7 @@
"params": [
{
"data": "0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000e4933c051d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000377b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f977b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f9756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e500000000000000000000000000000000000000000000000000000000",
"to": "0x76007c52c73972a441afa1a0e1016b140ffde689"
"to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9"
},
"latest"
]
Expand All @@ -467,7 +488,7 @@
"params": [
{
"data": "0xac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000c4933c051d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240920d1d24c83454d9d64e6666927f3abb97b3fd67c7e1bf43de5c2f4297f3b82ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f940920d1d24c83454d9d64e6666927f3abb97b3fd67c7e1bf43de5c2f4297f3b8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e500000000000000000000000000000000000000000000000000000000",
"to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2"
"to": "0x109e7315189e476ab21166955a0fb9be9b531bec"
},
"latest"
]
Expand All @@ -489,7 +510,7 @@
"params": [
{
"data": "0xac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000a4933c051d0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001610f26481d76ff830345933bfa36b33bc6b18b795a5f2c6cffbe77d2ab047314000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f9610f26481d76ff830345933bfa36b33bc6b18b795a5f2c6cffbe77d2ab04731400000000000000000000000000000000000000000000000000000000",
"to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2"
"to": "0x109e7315189e476ab21166955a0fb9be9b531bec"
},
"latest"
]
Expand Down

0 comments on commit abd3c72

Please sign in to comment.