From abd3c7220dd59a9d96c58b7092d85d0a42119f78 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 16 Oct 2024 02:06:05 -0400 Subject: [PATCH] fix: test --- src/tests/Uns.test.ts | 12 +++++-- src/tests/UnsInternal.test.ts | 9 ++--- src/tests/testData/mockData.json | 61 +++++++++++++++++++++----------- 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/src/tests/Uns.test.ts b/src/tests/Uns.test.ts index 693426dd..01c95a00 100644 --- a/src/tests/Uns.test.ts +++ b/src/tests/Uns.test.ts @@ -1,3 +1,4 @@ +import nock from 'nock'; import Resolution from '../index'; import ResolutionError, {ResolutionErrorCode} from '../errors/resolutionError'; import {NullAddress} from '../types'; @@ -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({ @@ -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, ); }); @@ -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, ); }); diff --git a/src/tests/UnsInternal.test.ts b/src/tests/UnsInternal.test.ts index 01b3749a..1c61a200 100644 --- a/src/tests/UnsInternal.test.ts +++ b/src/tests/UnsInternal.test.ts @@ -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; @@ -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( @@ -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( @@ -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( @@ -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( diff --git a/src/tests/testData/mockData.json b/src/tests/testData/mockData.json index d185179d..f121362e 100644 --- a/src/tests/testData/mockData.json +++ b/src/tests/testData/mockData.json @@ -81,7 +81,7 @@ "params": [ { "data": "0x4f558e7940920d1d24c83454d9d64e6666927f3abb97b3fd67c7e1bf43de5c2f4297f3b8", - "to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2" + "to": "0x109e7315189e476ab21166955a0fb9be9b531bec" }, "latest" ] @@ -101,7 +101,7 @@ "params": [ { "data": "0x4f558e791e3f482b3363eb4710dae2cb2183128e272eafbe137f686851c1caea32502230", - "to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2" + "to": "0x109e7315189e476ab21166955a0fb9be9b531bec" }, "latest" ] @@ -142,7 +142,7 @@ "params": [ { "data": "0x4f558e79644d751c0e0112006e6d5d5d9234c9d3fae5a4646ff88a754d7fa1ed09794e94", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -164,7 +164,7 @@ "params": [ { "data": "0x4f558e794118ebbd893ecbb9f5d7a817c7d8039c1bd991b56ea243e2ae84d0a1b2c950a7", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -184,7 +184,7 @@ "params": [ { "data": "0x4f558e790f4a10a4f46c288cea365fcf45cccf0e9d901b945b9829ccdb54c10dc3cb7a6f", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -204,7 +204,7 @@ "params": [ { "data": "0x4f558e795c828ec285c0bf152a30a325b3963661a80cb87641d60920344caf04d4a0f31e", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -224,7 +224,7 @@ "params": [ { "data": "0x4f558e791e3f482b3363eb4710dae2cb2183128e272eafbe137f686851c1caea32502230", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -246,7 +246,7 @@ "params": [ { "data": "0x4f558e790f4a10a4f46c288cea365fcf45cccf0e9d901b945b9829ccdb54c10dc3cb7a6f", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -265,7 +265,8 @@ "method": "eth_call", "params": [ { - "data": "0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000e4933c051d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000377b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f977b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f9756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e500000000000000000000000000000000000000000000000000000000" + "data": "0x4f558e79ed0afd72b0ca62d74b891a3c8a70d90f88b8c386f188fd455bc53f58f0079334", + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -273,7 +274,7 @@ "RESPONSE": { "jsonrpc": "2.0", "id": 1, - "result": "0x0000000000000000000000000000000000000000000000000000000000000001" + "result": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, { @@ -323,7 +324,7 @@ "params": [ { "data": "0x4f558e79ed0afd72b0ca62d74b891a3c8a70d90f88b8c386f188fd455bc53f58f0079334", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -364,7 +365,7 @@ "params": [ { "data": "0xa81ce6f970702ccf2d95c2c8ff666f5e4dde0ed0e83d7d7407fff6f593d4e277aac0a40c", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -372,7 +373,7 @@ "RESPONSE": { "jsonrpc": "2.0", "id": 1, - "result": "0x000000000000000000000000801452cFAC27e79a11c6b185986fdE09e8637589" + "result": "0x000000000000000000000000Ab005176D74900A9c25fDA144e2f9f329A409166" } }, { @@ -384,7 +385,7 @@ "params": [ { "data": "0xa81ce6f98e3f4a48d9806259e049ea529c5be0c6433ff147ad781caf8014d196c388e1df", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -392,7 +393,7 @@ "RESPONSE": { "jsonrpc": "2.0", "id": 1, - "result": "0x000000000000000000000000070e83FCed225184E67c86302493ffFCDB953f71" + "result": "0x000000000000000000000000DD907B4d80B4a979fd77eE502580c55F2700292c" } }, { @@ -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" } }, { @@ -423,7 +444,7 @@ "params": [ { "data": "0xa81ce6f99319b0a972ee595115c81afa667fc78253ff07a82fc635b39d528c759c979ebc", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -445,7 +466,7 @@ "params": [ { "data": "0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000e4933c051d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000377b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f977b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f9756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e500000000000000000000000000000000000000000000000000000000", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -467,7 +488,7 @@ "params": [ { "data": "0xac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000c4933c051d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240920d1d24c83454d9d64e6666927f3abb97b3fd67c7e1bf43de5c2f4297f3b82ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f940920d1d24c83454d9d64e6666927f3abb97b3fd67c7e1bf43de5c2f4297f3b8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e500000000000000000000000000000000000000000000000000000000", - "to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2" + "to": "0x109e7315189e476ab21166955a0fb9be9b531bec" }, "latest" ] @@ -489,7 +510,7 @@ "params": [ { "data": "0xac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000a4933c051d0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001610f26481d76ff830345933bfa36b33bc6b18b795a5f2c6cffbe77d2ab047314000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f9610f26481d76ff830345933bfa36b33bc6b18b795a5f2c6cffbe77d2ab04731400000000000000000000000000000000000000000000000000000000", - "to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2" + "to": "0x109e7315189e476ab21166955a0fb9be9b531bec" }, "latest" ]