Skip to content

Commit

Permalink
Avoid wrong token address in tests mocks (#2775)
Browse files Browse the repository at this point in the history
* Avoid wrong token address in tests mocks

* Add address to mocked pool
  • Loading branch information
agualis authored Feb 9, 2023
1 parent 65924e7 commit 2d270f3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
"watchPostEffect": true,
"watchSyncEffect": true
}
}
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist/
build/
public/data/tokenlists.json
public/data/tokenlists/*.json
.eslintrc-auto-import.json
1 change: 1 addition & 0 deletions src/__mocks__/weighted-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type DeepPartial<T> = {

const defaults: DeepPartial<Pool> = {
totalLiquidity: '100000000',
address: '0x702605F43471183158938C1a3e5f5A359d7b31ba',
tokens: [
aPoolToken({
address: '0x3Ec8798B81485A254928B70CDA1cf0A2BB0B74D7',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ vi.mock('@/providers/tokens.provider', () => {
};
});

vi.mock('@ethersproject/address', () => {
return {
getAddress: address => address,
};
});

const rootPool = BoostedPoolMock;
// Values used to calculate userPoolPercentage (15)
rootPool.totalLiquidity = '100';
Expand Down
12 changes: 4 additions & 8 deletions src/providers/tokens.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ import { tokensProvider } from './tokens.provider';

vi.spyOn(console, 'log').mockImplementation(noop);

vi.mock('@ethersproject/address', () => ({
getAddress: address => address,
isAddress: () => true,
}));

initDependenciesWithDefaultMocks();

async function mountTokenProvider() {
Expand Down Expand Up @@ -73,7 +68,8 @@ test('injects veBAL onchain data', async () => {
test('injects new tokens', async () => {
const { injectTokens, injectedTokens } = await mountTokenProvider();

await injectTokens(['new token address']);
const newTokenAddress = '0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce';
await injectTokens([newTokenAddress]);

expect(injectedTokens.value).toMatchInlineSnapshot(`
{
Expand All @@ -85,8 +81,8 @@ test('injects new tokens', async () => {
"name": "mocked onchain token name",
"symbol": "mocked onchain token symbol",
},
"new token address": {
"address": "new token address",
"0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE": {
"address": "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE",
"chainId": 5,
"decimals": 18,
"logoURI": "",
Expand Down

0 comments on commit 2d270f3

Please sign in to comment.