Skip to content

Commit 9674cf7

Browse files
committed
test: fix unit tests
1 parent e0d002c commit 9674cf7

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

app/components/Views/confirmations/components/activity/transaction-details-hero/transaction-details-hero.test.tsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { Interface } from '@ethersproject/abi';
32
import renderWithProvider from '../../../../../../util/test/renderWithProvider';
43
import { useTransactionDetails } from '../../../hooks/activity/useTransactionDetails';
54
import {
@@ -10,7 +9,8 @@ import { TransactionDetailsHero } from './transaction-details-hero';
109
import { merge } from 'lodash';
1110
import { otherControllersMock } from '../../../__mocks__/controllers/other-controllers-mock';
1211
import { useTokenWithBalance } from '../../../hooks/tokens/useTokenWithBalance';
13-
import { DISTRIBUTOR_CLAIM_ABI } from '../../../../../UI/Earn/components/MerklRewards/constants';
12+
import { MERKL_DISTRIBUTOR_ADDRESS } from '../../../../../UI/Earn/components/MerklRewards/constants';
13+
import { MUSD_TOKEN_ADDRESS } from '../../../../../UI/Earn/constants/musd';
1414

1515
jest.mock('../../../hooks/activity/useTransactionDetails');
1616
jest.mock('../../../hooks/tokens/useTokenWithBalance');
@@ -170,23 +170,32 @@ describe('TransactionDetailsHero', () => {
170170

171171
it('renders claim amount for musdClaim with valid claim data', () => {
172172
const USER_ADDRESS = '0x1234567890123456789012345678901234567890';
173-
const TOKEN_ADDRESS = '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd';
174173
const claimAmount = '75500000'; // 75.5 mUSD (6 decimals)
175174

176-
const contractInterface = new Interface(DISTRIBUTOR_CLAIM_ABI);
177-
const claimData = contractInterface.encodeFunctionData('claim', [
178-
[USER_ADDRESS],
179-
[TOKEN_ADDRESS],
180-
[claimAmount],
181-
[[]],
182-
]);
175+
const ERC20_TRANSFER_TOPIC =
176+
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
177+
const mockLogs = [
178+
{
179+
address: MUSD_TOKEN_ADDRESS,
180+
data: '0x' + BigInt(claimAmount).toString(16).padStart(64, '0'),
181+
topics: [
182+
ERC20_TRANSFER_TOPIC,
183+
'0x000000000000000000000000' +
184+
MERKL_DISTRIBUTOR_ADDRESS.slice(2).toLowerCase(),
185+
'0x000000000000000000000000' + USER_ADDRESS.slice(2).toLowerCase(),
186+
],
187+
},
188+
];
183189

184190
useTransactionDetailsMock.mockReturnValue({
185191
transactionMeta: {
186192
...TRANSACTION_META_MOCK,
187193
type: TransactionType.musdClaim,
188194
txParams: {
189-
data: claimData,
195+
from: USER_ADDRESS,
196+
},
197+
txReceipt: {
198+
logs: mockLogs,
190199
},
191200
} as unknown as TransactionMeta,
192201
});

0 commit comments

Comments
 (0)