From f15a9354db615118283a1e16310ff357c9a71b17 Mon Sep 17 00:00:00 2001 From: envin <26067523+envin3@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:26:26 +0100 Subject: [PATCH] test(presets): test migrate treasury funds preset (#33) --- src/__mocks__/@wagmi/core.js | 5 +++++ .../__tests__/migrateTreasuryFunds.test.js | 17 ++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) create mode 100644 src/__mocks__/@wagmi/core.js diff --git a/src/__mocks__/@wagmi/core.js b/src/__mocks__/@wagmi/core.js new file mode 100644 index 0000000..facf6c7 --- /dev/null +++ b/src/__mocks__/@wagmi/core.js @@ -0,0 +1,5 @@ +const wagmi = require('@wagmi/core') + +module.exports = { + ...wagmi +} diff --git a/src/utils/__tests__/migrateTreasuryFunds.test.js b/src/utils/__tests__/migrateTreasuryFunds.test.js index 677acb9..4cc5ebe 100644 --- a/src/utils/__tests__/migrateTreasuryFunds.test.js +++ b/src/utils/__tests__/migrateTreasuryFunds.test.js @@ -1,24 +1,15 @@ -import { readContract } from '@wagmi/core' import { getVotePresets } from '../vote-presets' import { encodeCallScript } from '../voting-scripts' -import erc20ABI from './abisMock/erc20ABI' - -jest.mock('@wagmi/core', () => { - return { - erc20ABI: jest.fn().mockReturnValueOnce(erc20ABI), - readContract: jest.fn().mockReturnValueOnce(18) - } -}) +const wagmi = require('@wagmi/core') describe('migrateTreasuryFunds', () => { test('Should match the generated script', async () => { - console.log(typeof erc20ABI) - // readContract.mockReturnValueOnce(18) + jest.spyOn(wagmi, 'readContract').mockReturnValue(18) const presets = getVotePresets({ presetParams: { 0: '0xf4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2', 1: 100, - 2: 100, + 2: '0x00f1918e', 3: '0xf1f6568a76559d85cF68E6597fA587544184dD46' }, setPresetParams: () => null, @@ -29,7 +20,7 @@ describe('migrateTreasuryFunds', () => { const script = encodeCallScript(actions) const expectedScript = - '0x00000001dd92eb1478d3189707ab7f4a5ace3a615cdd047600000064beabacc8000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000000000000005f5e100a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000005f5e100e396757ec7e6ac7c8e5abe7285dde47b98f22db800000144c322525d0000000000000000000000000000000000000000000000000000000005f5e100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a3078663166363536386137363535396438356346363845363539376641353837353434313834644434360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022b34000000000000000000000000000000000000000000000000000000000000' + '0x00000001dd92eb1478d3189707ab7f4a5ace3a615cdd047600000064beabacc8000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b20000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000056bc75e2d63100000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000056bc75e2d63100000e396757ec7e6ac7c8e5abe7285dde47b98f22db800000124c322525d0000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307866316636353638613736353539643835634636384536353937664135383735343431383464443436000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' expect(script).toStrictEqual(expectedScript) })