Skip to content

Commit 832ec8a

Browse files
authored
test: adapt and remove sleeps (#158)
1 parent f5c9a9c commit 832ec8a

File tree

22 files changed

+327
-187
lines changed

22 files changed

+327
-187
lines changed

packages/client/src/test-utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export const ETHEREUM_USDS_ADDRESS = evmAddress(
4949
export const ETHEREUM_WSTETH_ADDRESS = evmAddress(
5050
'0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
5151
);
52+
export const ETHEREUM_MKR_ADDRESS = evmAddress(
53+
'0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2',
54+
);
5255

5356
// Spoke addresses and ids
5457
export const ETHEREUM_SPOKE_CORE_ADDRESS = evmAddress(

packages/spec/borrow/business.spec.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {
1212
} from '@aave/client-next/test-utils';
1313
import { sendWith } from '@aave/client-next/viem';
1414
import { beforeAll, describe, expect, it } from 'vitest';
15+
1516
import { findReservesToBorrow } from '../helpers/reserves';
1617
import { findReserveAndSupply } from '../helpers/supplyBorrow';
17-
import { sleep } from '../helpers/tools';
1818
import { assertSingleElementArray } from '../test-utils';
1919

2020
const user = await createNewWallet();
@@ -39,7 +39,6 @@ describe('Feature: Borrowing Assets on Aave V4', () => {
3939

4040
describe('When the user wants to preview the borrow action before performing it', () => {
4141
it('Then the user can review the borrow details before proceeding', async () => {
42-
await sleep(1000); // TODO: Remove after fixed bug with delays of propagation
4342
const borrowPreviewResult = await findReservesToBorrow(client, user, {
4443
spoke: ETHEREUM_SPOKE_CORE_ADDRESS,
4544
}).andThen((reserves) =>
@@ -68,7 +67,6 @@ describe('Feature: Borrowing Assets on Aave V4', () => {
6867

6968
describe('When the user borrows an ERC20 asset', () => {
7069
it(`Then the user's borrow position is updated to reflect the ERC20 loan`, async () => {
71-
await sleep(1000); // TODO: Remove after fixed bug with delays of propagation
7270
const reservesToBorrow = await findReservesToBorrow(client, user, {
7371
spoke: ETHEREUM_SPOKE_CORE_ADDRESS,
7472
});
@@ -90,7 +88,6 @@ describe('Feature: Borrowing Assets on Aave V4', () => {
9088
})
9189
.andThen(sendWith(user))
9290
.andThen(client.waitForTransaction)
93-
.andTee(() => sleep(1000)) // TODO: Remove after fixed bug with delays of propagation
9491
.andThen(() =>
9592
userBorrows(client, {
9693
query: {
@@ -128,7 +125,7 @@ describe('Feature: Borrowing Assets on Aave V4', () => {
128125
asCollateral: true,
129126
}),
130127
);
131-
await sleep(1000); // TODO: Remove after fixed bug with delays of propagation
128+
132129
assertOk(setup);
133130
});
134131
it(`Then the user's borrow position is updated to reflect the native asset loan`, async () => {
@@ -156,7 +153,6 @@ describe('Feature: Borrowing Assets on Aave V4', () => {
156153
})
157154
.andThen(sendWith(user))
158155
.andThen(client.waitForTransaction)
159-
.andTee(() => sleep(1000)) // TODO: Remove after fixed bug with delays of propagation
160156
.andThen(() =>
161157
userBorrows(client, {
162158
query: {
@@ -178,13 +174,10 @@ describe('Feature: Borrowing Assets on Aave V4', () => {
178174
4,
179175
);
180176

181-
// BUG: The amount is slightly different from the total borrow amount
182177
expect(result.value[0].debt.amount.value).toBeBigDecimalCloseTo(
183178
amountToBorrow,
184179
4,
185180
);
186-
// BUG: It should be wrapped native
187-
// expect(result.value[0].amount.isWrappedNative).toBe(true);
188181
});
189182
});
190183
});

packages/spec/borrow/multipleBorrows.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import {
1010
} from '@aave/client-next/test-utils';
1111
import { sendWith } from '@aave/client-next/viem';
1212
import { beforeAll, describe, expect, it } from 'vitest';
13+
1314
import { findReservesToBorrow } from '../helpers/reserves';
1415
import { findReserveAndSupply } from '../helpers/supplyBorrow';
15-
import { sleep } from '../helpers/tools';
1616

1717
const user = await createNewWallet();
1818

@@ -36,7 +36,6 @@ describe('Borrowing from Multiple Reserves on Aave V4', () => {
3636
}, 120_000);
3737

3838
it('Then the user has two active borrow positions with correct amounts', async () => {
39-
await sleep(1000); // TODO: Remove after fixed bug with delays of propagation
4039
const reservesToBorrow = await findReservesToBorrow(client, user, {
4140
spoke: ETHEREUM_SPOKE_CORE_ADDRESS,
4241
});
@@ -76,7 +75,6 @@ describe('Borrowing from Multiple Reserves on Aave V4', () => {
7675
assertOk(secondBorrow);
7776

7877
// Verify user has two borrow positions
79-
await sleep(1000); // TODO: Remove after fixed bug with delays of propagation
8078
const borrowPositions = await userBorrows(client, {
8179
query: {
8280
userSpoke: {

packages/spec/helpers/supplyBorrow.ts

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
findReservesToBorrow,
2727
findReservesToSupply,
2828
} from '../helpers/reserves';
29-
import { sleep } from './tools';
3029

3130
export function supplyToReserve(
3231
client: AaveClient,
@@ -118,32 +117,32 @@ export function supplyAndBorrow(
118117
amount: { erc20: { value: params.amountToSupply } },
119118
sender: evmAddress(user.account.address),
120119
enableCollateral: true,
121-
})
122-
.andTee(() => sleep(1000)) // TODO: Remove after fixed bug with delays of propagation
123-
.andThen(() =>
124-
reserve(client, {
125-
user: evmAddress(user.account.address),
126-
reserve: params.reserveToBorrow.id,
127-
}).andThen((reserve) =>
128-
borrow(client, {
129-
sender: evmAddress(user.account.address),
130-
reserve: reserve!.id,
131-
amount: {
132-
erc20: {
133-
value: reserve!.userState!.borrowable.amount.value.times(
134-
params.ratioToBorrow ?? 0.25,
135-
),
136-
},
120+
}).andThen(() =>
121+
reserve(client, {
122+
user: evmAddress(user.account.address),
123+
query: {
124+
reserveId: params.reserveToBorrow.id,
125+
},
126+
}).andThen((reserve) =>
127+
borrow(client, {
128+
sender: evmAddress(user.account.address),
129+
reserve: reserve!.id,
130+
amount: {
131+
erc20: {
132+
value: reserve!.userState!.borrowable.amount.value.times(
133+
params.ratioToBorrow ?? 0.25,
134+
),
137135
},
138-
})
139-
.andThen(sendWith(user))
140-
.andThen(client.waitForTransaction)
141-
.map(() => ({
142-
borrowReserve: params.reserveToBorrow,
143-
supplyReserve: params.reserveToSupply,
144-
})),
145-
),
146-
);
136+
},
137+
})
138+
.andThen(sendWith(user))
139+
.andThen(client.waitForTransaction)
140+
.map(() => ({
141+
borrowReserve: params.reserveToBorrow,
142+
supplyReserve: params.reserveToSupply,
143+
})),
144+
),
145+
);
147146
}
148147

149148
export function supplyWSTETHAndBorrowETH(
@@ -160,7 +159,6 @@ export function supplyWSTETHAndBorrowETH(
160159
sender: evmAddress(user.account.address),
161160
enableCollateral: true,
162161
})
163-
.andTee(() => sleep(1000)) // TODO: Remove after fixed bug with delays of propagation
164162
.andThen(() =>
165163
findReservesToBorrow(client, user, {
166164
token: ETHEREUM_WETH_ADDRESS,

packages/spec/helpers/tools.ts

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

packages/spec/liquidity/__snapshots__/hub.spec.ts.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exports[`Aave V4 Hub Scenarios > Given a user who wants to know assets in a hub
2929
"explorerUrl": "https://etherscan.io",
3030
"icon": "https://statics.aave.com/ethereum.svg",
3131
"isTestnet": true,
32-
"name": "ForkedEthereum",
32+
"name": "Devnet",
3333
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
3434
"nativeInfo": {
3535
"__typename": "TokenInfo",
@@ -84,7 +84,7 @@ exports[`Aave V4 Hub Scenarios > Given a user who wants to know assets in a hub
8484
"explorerUrl": "https://etherscan.io",
8585
"icon": "https://statics.aave.com/ethereum.svg",
8686
"isTestnet": true,
87-
"name": "ForkedEthereum",
87+
"name": "Devnet",
8888
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
8989
"nativeInfo": {
9090
"__typename": "TokenInfo",
@@ -139,7 +139,7 @@ exports[`Aave V4 Hub Scenarios > Given a user who wants to know assets in a hub
139139
"explorerUrl": "https://etherscan.io",
140140
"icon": "https://statics.aave.com/ethereum.svg",
141141
"isTestnet": true,
142-
"name": "ForkedEthereum",
142+
"name": "Devnet",
143143
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
144144
"nativeInfo": {
145145
"__typename": "TokenInfo",
@@ -194,7 +194,7 @@ exports[`Aave V4 Hub Scenarios > Given a user who wants to know assets in a hub
194194
"explorerUrl": "https://etherscan.io",
195195
"icon": "https://statics.aave.com/ethereum.svg",
196196
"isTestnet": true,
197-
"name": "ForkedEthereum",
197+
"name": "Devnet",
198198
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
199199
"nativeInfo": {
200200
"__typename": "TokenInfo",
@@ -249,7 +249,7 @@ exports[`Aave V4 Hub Scenarios > Given a user who wants to know assets in a hub
249249
"explorerUrl": "https://etherscan.io",
250250
"icon": "https://statics.aave.com/ethereum.svg",
251251
"isTestnet": true,
252-
"name": "ForkedEthereum",
252+
"name": "Devnet",
253253
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
254254
"nativeInfo": {
255255
"__typename": "TokenInfo",
@@ -304,7 +304,7 @@ exports[`Aave V4 Hub Scenarios > Given a user who wants to know assets in a hub
304304
"explorerUrl": "https://etherscan.io",
305305
"icon": "https://statics.aave.com/ethereum.svg",
306306
"isTestnet": true,
307-
"name": "ForkedEthereum",
307+
"name": "Devnet",
308308
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
309309
"nativeInfo": {
310310
"__typename": "TokenInfo",
@@ -359,7 +359,7 @@ exports[`Aave V4 Hub Scenarios > Given a user who wants to know assets in a hub
359359
"explorerUrl": "https://etherscan.io",
360360
"icon": "https://statics.aave.com/ethereum.svg",
361361
"isTestnet": true,
362-
"name": "ForkedEthereum",
362+
"name": "Devnet",
363363
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
364364
"nativeInfo": {
365365
"__typename": "TokenInfo",
@@ -395,7 +395,7 @@ exports[`Aave V4 Hub Scenarios > Given a user who wants to list available hubs >
395395
"explorerUrl": "https://etherscan.io",
396396
"icon": "https://statics.aave.com/ethereum.svg",
397397
"isTestnet": true,
398-
"name": "ForkedEthereum",
398+
"name": "Devnet",
399399
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
400400
"nativeInfo": {
401401
"__typename": "TokenInfo",
@@ -423,7 +423,7 @@ exports[`Aave V4 Hub Scenarios > Given a user who wants to list available hubs >
423423
"explorerUrl": "https://etherscan.io",
424424
"icon": "https://statics.aave.com/ethereum.svg",
425425
"isTestnet": true,
426-
"name": "ForkedEthereum",
426+
"name": "Devnet",
427427
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
428428
"nativeInfo": {
429429
"__typename": "TokenInfo",
@@ -451,7 +451,7 @@ exports[`Aave V4 Hub Scenarios > Given a user who wants to list available hubs >
451451
"explorerUrl": "https://etherscan.io",
452452
"icon": "https://statics.aave.com/ethereum.svg",
453453
"isTestnet": true,
454-
"name": "ForkedEthereum",
454+
"name": "Devnet",
455455
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
456456
"nativeInfo": {
457457
"__typename": "TokenInfo",

packages/spec/liquidity/__snapshots__/spokes.spec.ts.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes by cha
1111
"explorerUrl": "https://etherscan.io",
1212
"icon": "https://statics.aave.com/ethereum.svg",
1313
"isTestnet": true,
14-
"name": "ForkedEthereum",
14+
"name": "Devnet",
1515
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
1616
"nativeInfo": {
1717
"__typename": "TokenInfo",
@@ -35,7 +35,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes by cha
3535
"explorerUrl": "https://etherscan.io",
3636
"icon": "https://statics.aave.com/ethereum.svg",
3737
"isTestnet": true,
38-
"name": "ForkedEthereum",
38+
"name": "Devnet",
3939
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
4040
"nativeInfo": {
4141
"__typename": "TokenInfo",
@@ -59,7 +59,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes by cha
5959
"explorerUrl": "https://etherscan.io",
6060
"icon": "https://statics.aave.com/ethereum.svg",
6161
"isTestnet": true,
62-
"name": "ForkedEthereum",
62+
"name": "Devnet",
6363
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
6464
"nativeInfo": {
6565
"__typename": "TokenInfo",
@@ -83,7 +83,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes by cha
8383
"explorerUrl": "https://etherscan.io",
8484
"icon": "https://statics.aave.com/ethereum.svg",
8585
"isTestnet": true,
86-
"name": "ForkedEthereum",
86+
"name": "Devnet",
8787
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
8888
"nativeInfo": {
8989
"__typename": "TokenInfo",
@@ -112,7 +112,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes by hub
112112
"explorerUrl": "https://etherscan.io",
113113
"icon": "https://statics.aave.com/ethereum.svg",
114114
"isTestnet": true,
115-
"name": "ForkedEthereum",
115+
"name": "Devnet",
116116
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
117117
"nativeInfo": {
118118
"__typename": "TokenInfo",
@@ -136,7 +136,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes by hub
136136
"explorerUrl": "https://etherscan.io",
137137
"icon": "https://statics.aave.com/ethereum.svg",
138138
"isTestnet": true,
139-
"name": "ForkedEthereum",
139+
"name": "Devnet",
140140
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
141141
"nativeInfo": {
142142
"__typename": "TokenInfo",
@@ -160,7 +160,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes by hub
160160
"explorerUrl": "https://etherscan.io",
161161
"icon": "https://statics.aave.com/ethereum.svg",
162162
"isTestnet": true,
163-
"name": "ForkedEthereum",
163+
"name": "Devnet",
164164
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
165165
"nativeInfo": {
166166
"__typename": "TokenInfo",
@@ -184,7 +184,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes by hub
184184
"explorerUrl": "https://etherscan.io",
185185
"icon": "https://statics.aave.com/ethereum.svg",
186186
"isTestnet": true,
187-
"name": "ForkedEthereum",
187+
"name": "Devnet",
188188
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
189189
"nativeInfo": {
190190
"__typename": "TokenInfo",
@@ -213,7 +213,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes in a h
213213
"explorerUrl": "https://etherscan.io",
214214
"icon": "https://statics.aave.com/ethereum.svg",
215215
"isTestnet": true,
216-
"name": "ForkedEthereum",
216+
"name": "Devnet",
217217
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
218218
"nativeInfo": {
219219
"__typename": "TokenInfo",
@@ -237,7 +237,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes in a h
237237
"explorerUrl": "https://etherscan.io",
238238
"icon": "https://statics.aave.com/ethereum.svg",
239239
"isTestnet": true,
240-
"name": "ForkedEthereum",
240+
"name": "Devnet",
241241
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
242242
"nativeInfo": {
243243
"__typename": "TokenInfo",
@@ -261,7 +261,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes in a h
261261
"explorerUrl": "https://etherscan.io",
262262
"icon": "https://statics.aave.com/ethereum.svg",
263263
"isTestnet": true,
264-
"name": "ForkedEthereum",
264+
"name": "Devnet",
265265
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
266266
"nativeInfo": {
267267
"__typename": "TokenInfo",
@@ -285,7 +285,7 @@ exports[`Aave V4 Spokes Scenario > Given a user who wants to fetch spokes in a h
285285
"explorerUrl": "https://etherscan.io",
286286
"icon": "https://statics.aave.com/ethereum.svg",
287287
"isTestnet": true,
288-
"name": "ForkedEthereum",
288+
"name": "Devnet",
289289
"nativeGateway": "0x10568906206cfa2604489ABDB5E469021f5FCAa7",
290290
"nativeInfo": {
291291
"__typename": "TokenInfo",

packages/spec/liquidity/hub.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ETHEREUM_WETH_ADDRESS,
88
} from '@aave/client-next/test-utils';
99
import { describe, expect, it } from 'vitest';
10+
1011
import { assertNonEmptyArray } from '../test-utils';
1112

1213
describe('Aave V4 Hub Scenarios', () => {

0 commit comments

Comments
 (0)