From 71ef9c3979c2bdf5110617a9d49d29b54eed1d76 Mon Sep 17 00:00:00 2001 From: Mark Hinschberger Date: Fri, 5 Jan 2024 16:40:03 +0000 Subject: [PATCH] fix: debug --- .../uiStakeDataProvider.test.ts | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/uiStakeDataProvider.test.ts diff --git a/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/uiStakeDataProvider.test.ts b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/uiStakeDataProvider.test.ts new file mode 100644 index 00000000..d1e83c40 --- /dev/null +++ b/packages/contract-helpers/src/V3-uiStakeDataProvider-contract-copy/uiStakeDataProvider.test.ts @@ -0,0 +1,108 @@ +import { BigNumber, providers } from 'ethers'; +import { + GeneralStakeUIDataHumanized, + GeneralStakeUIDataRaw, + GetUserStakeTotalsRaw, + GetUserStakeUIDataHumanized, + GetUserStakeUIDataRaw, +} from './_mocks'; +import { + Abi as IStakedTokenDataProvider, + Abi__factory as StakedTokenDataProvider__factory, +} from './typechain'; +import { + StakedTokenData, + HumanizedStakeResponse, + // GeneralStakeUIData, + // GeneralStakeUIDataHumanized, + // GetUserStakeUIData, + // GetUserStakeUIDataHumanized, +} from './types'; + +describe('UiStakeDataProvider', () => { + const user = '0x0000000000000000000000000000000000000001'; + const uiStakeDataProvider = '0x0000000000000000000000000000000000000002'; + const dataProvider: providers.Provider = new providers.JsonRpcProvider(); + + // jest.spyOn(StakedTokenDataProvider__factory, 'connect').mockReturnValue({ + // // getGeneralStakeUIData: async () => Promise.resolve(GeneralStakeUIDataRaw), + // // getUserStakeUIData: async () => Promise.resolve(GetUserStakeUIDataRaw), + // // getGeneralStakeUIDataHumanized: async () => + // // Promise.resolve(GeneralStakeUIDataHumanized), + // // getUserStakeUIDataHumanized: async () => + // // Promise.resolve(GetUserStakeUIDataHumanized), + // // getAllStakedTokenData: async () => Promise.resolve(GeneralStakeUIDataRaw), + // // getAllStakedTokenUserData: async () => + // // Promise.resolve(GetUserStakeTotalsRaw), + // } as unknown as IStakedTokenDataProvider); + + describe('Init', () => { + it('Expects to create the instance', () => { + // const instance: UiStakeDataProviderInterface = new UiStakeDataProvider({ + // uiStakeDataProvider, + // provider: dataProvider, + // }); + + // expect(instance instanceof UiStakeDataProvider); + expect(true); + }); + }); + // describe('getUserStakeUIData', () => { + // const instance: UiStakeDataProviderInterface = new UiStakeDataProvider({ + // uiStakeDataProvider, + // provider: dataProvider, + // }); + // it('Expects to get user raw data', async () => { + // const rawData = await instance.getUserStakeUIData({ user }); + // expect(rawData.stkAaveData.stakedTokenUserBalance).toEqual( + // BigNumber.from(0), + // ); + // }); + // it('Expects to fail if user not eth address', async () => { + // const user = 'asdf'; + // await expect(async () => + // instance.getUserStakeUIData({ user }), + // ).rejects.toThrowError( + // new Error(`Address: ${user} is not a valid ethereum Address`), + // ); + // }); + // }); + // describe('getGeneralStakeUIData', () => { + // const instance: UiStakeDataProviderInterface = new UiStakeDataProvider({ + // uiStakeDataProvider, + // provider: dataProvider, + // }); + // it('Expects to get general stake raw data', async () => { + // const rawData = await instance.getGeneralStakeUIData(); + // expect(rawData).toEqual(GeneralStakeUIDataRaw); + // }); + // }); + // describe('getUserStakeUIDataHumanized', () => { + // const instance: UiStakeDataProviderInterface = new UiStakeDataProvider({ + // uiStakeDataProvider, + // provider: dataProvider, + // }); + // it('Expects to get user data in a humanized format', async () => { + // const rawData = await instance.getUserStakeUIDataHumanized({ user }); + // expect(rawData).toEqual(GetUserStakeUIDataHumanized); + // }); + // it('Expects to fail if user not eth address', async () => { + // const user = 'asdf'; + // await expect(async () => + // instance.getUserStakeUIDataHumanized({ user }), + // ).rejects.toThrowError( + // new Error(`Address: ${user} is not a valid ethereum Address`), + // ); + // }); + // }); + // describe('getGeneralStakeUIDataHumanized', () => { + // const instance: UiStakeDataProviderInterface = new UiStakeDataProvider({ + // uiStakeDataProvider, + // provider: dataProvider, + // }); + // it('Expects to get general stake data in a humanized format', async () => { + // const rawData = await instance.getGeneralStakeUIDataHumanized(); + // expect(rawData).toEqual(GeneralStakeUIDataHumanized); + // }); + // }); +});