Skip to content

Commit

Permalink
test(presets): test migrate treasury funds preset (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
envin3 authored Mar 6, 2024
1 parent 0b2c76c commit f15a935
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
5 changes: 5 additions & 0 deletions src/__mocks__/@wagmi/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const wagmi = require('@wagmi/core')

module.exports = {
...wagmi
}
17 changes: 4 additions & 13 deletions src/utils/__tests__/migrateTreasuryFunds.test.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -29,7 +20,7 @@ describe('migrateTreasuryFunds', () => {
const script = encodeCallScript(actions)

const expectedScript =
'0x00000001dd92eb1478d3189707ab7f4a5ace3a615cdd047600000064beabacc8000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000000000000005f5e100a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000005f5e100e396757ec7e6ac7c8e5abe7285dde47b98f22db800000144c322525d0000000000000000000000000000000000000000000000000000000005f5e100000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a3078663166363536386137363535396438356346363845363539376641353837353434313834644434360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022b34000000000000000000000000000000000000000000000000000000000000'
'0x00000001dd92eb1478d3189707ab7f4a5ace3a615cdd047600000064beabacc8000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b20000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000056bc75e2d63100000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000056bc75e2d63100000e396757ec7e6ac7c8e5abe7285dde47b98f22db800000124c322525d0000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a307866316636353638613736353539643835634636384536353937664135383735343431383464443436000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'

expect(script).toStrictEqual(expectedScript)
})
Expand Down

0 comments on commit f15a935

Please sign in to comment.