Skip to content

Commit 16d7556

Browse files
committed
test: separate tests in supply and withdraw
1 parent 43c2fe2 commit 16d7556

File tree

7 files changed

+296
-272
lines changed

7 files changed

+296
-272
lines changed
File renamed without changes.
Lines changed: 117 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,129 @@
1-
import { describe, expect, it } from 'vitest';
1+
import type { Reserve } from '@aave/graphql';
2+
import { assertOk, bigDecimal, evmAddress } from '@aave/types';
3+
import { beforeAll, describe, expect, it } from 'vitest';
4+
import {
5+
client,
6+
createNewWallet,
7+
fetchReserve,
8+
fundErc20Address,
9+
fundNativeAddress,
10+
WETH_ADDRESS,
11+
} from '../test-utils';
12+
import { sendWith } from '../viem';
13+
import { supply } from './transactions';
14+
import { userSupplies } from './user';
215

316
describe('Given an Aave Market', () => {
417
describe('When the user supplies tokens to a Reserve', () => {
5-
it(`Then it should be available in the user's supply positions`, () => {
6-
expect(true).toBe(true);
18+
const wallet = createNewWallet();
19+
const amountToSupply = '0.01';
20+
let reserveInfo: Reserve;
21+
22+
beforeAll(async () => {
23+
await fundErc20Address(
24+
WETH_ADDRESS,
25+
evmAddress(wallet.account!.address),
26+
bigDecimal('0.02'),
27+
);
28+
29+
reserveInfo = await fetchReserve(WETH_ADDRESS);
30+
// Check if the reserve is not frozen or paused
31+
expect(reserveInfo.isFrozen).toBe(false);
32+
expect(reserveInfo.isPaused).toBe(false);
733
});
34+
35+
it(`Then it should be available in the user's supply positions`, async () => {
36+
const result = await supply(client, {
37+
market: reserveInfo.market.address,
38+
supplier: evmAddress(wallet.account!.address),
39+
amount: {
40+
erc20: {
41+
value: amountToSupply,
42+
currency: WETH_ADDRESS,
43+
},
44+
},
45+
chainId: reserveInfo.market.chain.chainId,
46+
})
47+
.andThen(sendWith(wallet))
48+
.andThen(() =>
49+
userSupplies(client, {
50+
markets: [
51+
{
52+
address: reserveInfo.market.address,
53+
chainId: reserveInfo.market.chain.chainId,
54+
},
55+
],
56+
user: evmAddress(wallet.account!.address),
57+
}),
58+
);
59+
assertOk(result);
60+
expect(result.value).toEqual([
61+
expect.objectContaining({
62+
balance: expect.objectContaining({
63+
amount: expect.objectContaining({
64+
value: expect.toBeBigDecimalCloseTo(amountToSupply),
65+
}),
66+
}),
67+
}),
68+
]);
69+
}, 25_000);
870
});
971

1072
describe('And the Reserve allows to supply in native tokens', () => {
73+
let reserveInfo: Reserve;
74+
75+
beforeAll(async () => {
76+
reserveInfo = await fetchReserve(WETH_ADDRESS);
77+
// Check if the reserve is not frozen or paused
78+
expect(reserveInfo.isFrozen).toBe(false);
79+
expect(reserveInfo.isPaused).toBe(false);
80+
// And accepts native tokens
81+
expect(reserveInfo.acceptsNative?.symbol).toEqual('ETH');
82+
});
83+
1184
describe('When the user supplies to the reserve in native tokens', () => {
12-
it(`Then it should be available in the user's supply positions`, () => {
13-
expect(true).toBe(true);
85+
const wallet = createNewWallet();
86+
const amountToSupply = '0.01';
87+
88+
beforeAll(async () => {
89+
await fundNativeAddress(
90+
evmAddress(wallet.account!.address),
91+
bigDecimal('0.02'),
92+
);
1493
});
94+
95+
it(`Then it should be available in the user's supply positions`, async () => {
96+
const result = await supply(client, {
97+
market: reserveInfo.market.address,
98+
supplier: evmAddress(wallet.account!.address),
99+
amount: {
100+
native: amountToSupply,
101+
},
102+
chainId: reserveInfo.market.chain.chainId,
103+
})
104+
.andThen(sendWith(wallet))
105+
.andThen(() =>
106+
userSupplies(client, {
107+
markets: [
108+
{
109+
address: reserveInfo.market.address,
110+
chainId: reserveInfo.market.chain.chainId,
111+
},
112+
],
113+
user: evmAddress(wallet.account!.address),
114+
}),
115+
);
116+
assertOk(result);
117+
expect(result.value).toEqual([
118+
expect.objectContaining({
119+
balance: expect.objectContaining({
120+
amount: expect.objectContaining({
121+
value: expect.toBeBigDecimalCloseTo(amountToSupply),
122+
}),
123+
}),
124+
}),
125+
]);
126+
}, 25_000);
15127
});
16128
});
17129
});

packages/client/src/actions/supplyWithdraw.test.ts

Lines changed: 0 additions & 257 deletions
This file was deleted.

0 commit comments

Comments
 (0)