From a0aa280eb78c3ed6ec998315dd6782861a07eca2 Mon Sep 17 00:00:00 2001 From: "dandhee.damarrama" Date: Mon, 9 Oct 2023 18:50:10 +0700 Subject: [PATCH] chore: add unit test for stored Erc20Deposit --- tests/handlers/InputAdded.test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/handlers/InputAdded.test.ts b/tests/handlers/InputAdded.test.ts index dc07782..4b4ce2b 100644 --- a/tests/handlers/InputAdded.test.ts +++ b/tests/handlers/InputAdded.test.ts @@ -123,5 +123,34 @@ describe('InputAdded', () => { expect(mockApplicationStorage.size).toBe(1); expect(mockInputStorage.size).toBe(1); }); + test('Erc20Deposit Stored', async () => { + const name = 'SimpleERC20'; + const symbol = 'SIM20'; + const decimals = 18; + const token = new Token({ + id: tokenAddress, + name, + symbol, + decimals, + }); + erc20.name.mockResolvedValueOnce('SimpleERC20'); + erc20.symbol.mockResolvedValue('SIM20'); + erc20.decimals.mockResolvedValue(18); + const deposit = new Erc20Deposit({ + id: input.id, + amount, + from, + token, + }); + vi.spyOn(inputAdded, 'handlePayload').mockImplementation( + (input, block, ctx) => { + return new Promise((resolve) => { + resolve(deposit); + }); + }, + ); + await inputAdded.handle(logs[0], block, ctx); + expect(mockDepositStorage.size).toBe(1); + }); }); });