diff --git a/tests/handlers/ApplicationCreated.test.ts b/tests/handlers/ApplicationCreated.test.ts index efa8210..0d6cb67 100644 --- a/tests/handlers/ApplicationCreated.test.ts +++ b/tests/handlers/ApplicationCreated.test.ts @@ -8,8 +8,8 @@ import { RollupVersion, } from '../../src/model'; import { generateIDFrom } from '../../src/utils'; +import { mockModelImplementation } from '../stubs/mocks'; import { block, ctx, logs } from '../stubs/params'; -import { mockModelImplementation } from '../stubs/utils'; vi.mock('../../src/model/', async (importOriginal) => { const actualMods = await importOriginal; diff --git a/tests/handlers/InputAdded.test.ts b/tests/handlers/InputAdded.test.ts index 1d14c7d..80e1508 100644 --- a/tests/handlers/InputAdded.test.ts +++ b/tests/handlers/InputAdded.test.ts @@ -16,6 +16,7 @@ import { NFT, Token, } from '../../src/model'; +import { mockModelImplementation } from '../stubs/mocks'; import { block, ctx, @@ -25,7 +26,6 @@ import { logErc721Transfer, logs, } from '../stubs/params'; -import { mockModelImplementation } from '../stubs/utils'; vi.mock('../../src/abi/ERC20'); diff --git a/tests/handlers/OwnershipTransferred.test.ts b/tests/handlers/OwnershipTransferred.test.ts index e6f2a70..e089de9 100644 --- a/tests/handlers/OwnershipTransferred.test.ts +++ b/tests/handlers/OwnershipTransferred.test.ts @@ -4,8 +4,8 @@ import { sepolia } from 'viem/chains'; import OwnerShipTransferred from '../../src/handlers/OwnershipTransferred'; import { Application, Chain, RollupVersion } from '../../src/model'; import { generateIDFrom } from '../../src/utils'; +import { mockModelImplementation } from '../stubs/mocks'; import { block, ctx, logs } from '../stubs/params'; -import { mockModelImplementation } from '../stubs/utils'; vi.mock('../../src/model/', async (importOriginal) => { const actualMods = await importOriginal; diff --git a/tests/handlers/v2/ApplicationCreated.test.ts b/tests/handlers/v2/ApplicationCreated.test.ts index 9635e6f..636733e 100644 --- a/tests/handlers/v2/ApplicationCreated.test.ts +++ b/tests/handlers/v2/ApplicationCreated.test.ts @@ -8,8 +8,8 @@ import { RollupVersion, } from '../../../src/model'; import { generateIDFrom } from '../../../src/utils'; +import { mockModelImplementation } from '../../stubs/mocks'; import { block, ctx, logApplicationCreatedV2, logs } from '../../stubs/params'; -import { mockModelImplementation } from '../../stubs/utils'; vi.mock('../../../src/model/', async (importOriginal) => { const actualMods = await importOriginal; diff --git a/tests/handlers/v2/InputAdded.test.ts b/tests/handlers/v2/InputAdded.test.ts index 0d91c59..892c690 100644 --- a/tests/handlers/v2/InputAdded.test.ts +++ b/tests/handlers/v2/InputAdded.test.ts @@ -16,6 +16,7 @@ import { NFT, Token, } from '../../../src/model'; +import { mockModelImplementation } from '../../stubs/mocks'; import { block, ctx, @@ -27,7 +28,6 @@ import { logInputAddedV2, logs, } from '../../stubs/params'; -import { mockModelImplementation } from '../../stubs/utils'; vi.mock('../../../src/abi/ERC20'); diff --git a/tests/stubs/mocks.ts b/tests/stubs/mocks.ts new file mode 100644 index 0000000..59d4386 --- /dev/null +++ b/tests/stubs/mocks.ts @@ -0,0 +1,8 @@ +import { MockedObject, vi } from 'vitest'; + +export const mockModelImplementation = (object: T) => { + const Mock = vi.mocked(object) as MockedObject; + // @ts-ignore + Mock.mockImplementation((args) => ({ ...args } as object)); + return Mock; +}; diff --git a/tests/stubs/utils.ts b/tests/stubs/utils.ts index 6b13654..67ba32b 100644 --- a/tests/stubs/utils.ts +++ b/tests/stubs/utils.ts @@ -7,16 +7,8 @@ import { Hex, parseAbiParameters, } from 'viem'; -import { MockedObject, vi } from 'vitest'; import { evmAdvanceAbi } from '../../src/decoders/evmAdvance'; -export const mockModelImplementation = (object: T) => { - const Mock = vi.mocked(object) as MockedObject; - // @ts-ignore - Mock.mockImplementation((args) => ({ ...args } as object)); - return Mock; -}; - type ERC721PortalInput = { token: Address; sender: Address; @@ -50,6 +42,12 @@ type ERC20PortalInput = { execLayerData: Hex; }; +type EtherPortalInput = { + sender: Address; + value: bigint; + execLayerData: Hex; +}; + type EvmAdvanceInput = { chainId: bigint; appContract: Address; @@ -65,6 +63,16 @@ const baseExecLayerAbiParameters = parseAbiParameters( 'bytes baseLayer, bytes execLayer', ); +export const encodeEtherPortalInput = ({ + sender, + value, + execLayerData, +}: EtherPortalInput) => + encodePacked( + ['address', 'uint256', 'bytes'], + [sender, value, execLayerData], + ); + export const encodeErc20PortalInput = ({ token, sender,