Skip to content

Commit

Permalink
Improvements for Aave and Pool finder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-langa committed Jan 19, 2024
1 parent 99dd2ff commit 9b4db0d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 56 deletions.
9 changes: 9 additions & 0 deletions tests/noWallet/ajna/poolFinder/borrowPoolFinder.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from '#noWalletFixtures';
import { positionTimeout } from 'utils/config';
import { ajnaPoolAddress, usdcContractAddress, wEthContractAddress } from 'utils/testData';

test.describe('Pool finder - Borrow', async () => {
Expand Down Expand Up @@ -33,6 +34,8 @@ test.describe('Pool finder - Borrow', async () => {
description: '10913',
});

test.setTimeout(positionTimeout);

await app.poolFinder.filterBy({ filter: 'Pool address', value: ajnaPoolAddress });
await app.poolFinder.list.shouldHavePoolsCount(1);
await app.poolFinder.list.shouldHaveTokensPair('WSTETH/ETH');
Expand All @@ -47,6 +50,8 @@ test.describe('Pool finder - Borrow', async () => {
description: '10912',
});

test.setTimeout(positionTimeout);

await app.poolFinder.filterBy({ filter: 'Collateral token', value: wEthContractAddress });
await app.poolFinder.list.shouldHaveOneOrMorePools();
await app.poolFinder.list.allPoolsShouldBe('Borrow');
Expand All @@ -61,6 +66,8 @@ test.describe('Pool finder - Borrow', async () => {
description: '10914',
});

test.setTimeout(positionTimeout);

await app.poolFinder.filterBy({ filter: 'Quote token', value: wEthContractAddress });
await app.poolFinder.list.shouldHaveOneOrMorePools();
await app.poolFinder.list.allPoolsShouldBe('Borrow');
Expand All @@ -75,6 +82,8 @@ test.describe('Pool finder - Borrow', async () => {
description: '11553',
});

test.setTimeout(positionTimeout);

await app.poolFinder.filterBy({ filter: 'Collateral token', value: wEthContractAddress });
await app.poolFinder.filterBy({ filter: 'Quote token', value: usdcContractAddress });
await app.poolFinder.list.shouldHavePoolsCount(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,62 +231,6 @@ test.describe('Aave v3 Multiply - Ethereum - Wallet connected', async () => {
expect(updatedLoanToValue).toBeLessThan(initialLoanToValue);
});

test('It should close an existent Aave V3 Multiply Ethereum position - Close to collateral token (ETH) @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '12057',
});

test.setTimeout(veryLongTestTimeout);
// New fork needed to be able to close a Multiply position
await test.step('Test setup - New fork', async () => {
({ forkId } = await setupNewFork({ app, network: 'mainnet' }));
await tenderly.setEthBalance({ forkId, walletAddress, ethBalance: '100' });
});

await tenderly.changeAccountOwner({
account: '0x16f2c35e062c14f57475de0a466f7e08b03a9c7d',
newOwner: walletAddress,
forkId,
});

await app.page.goto('/ethereum/aave/v3/1218#overview');

await app.position.manage.openManageOptions({ currentLabel: 'Adjust' });
await app.position.manage.select('Close position');

await app.position.manage.closeTo('ETH');
await app.position.manage.shouldHaveTokenAmountAfterClosing({
token: 'ETH',
amount: '0.[0-9]{3,4}',
});

// Transaction randomly fails - Retry until it's completed.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

await app.page.goto('/ethereum/aave/v3/1218');
await app.position.overview.shouldHaveLiquidationPrice({
price: '0.00',
token: 'USDC',
timeout: positionTimeout,
});
await app.position.overview.shouldHaveLoanToValue('0.00');
await app.position.overview.shouldHaveBorrowCost('0.00');
await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'ETH' });
await app.position.overview.shouldHaveExposure({ amount: '0.00000', token: 'ETH' });
await app.position.overview.shouldHaveDebt({ amount: '0.0000', token: 'USDC' });
await app.position.overview.shouldHaveMultiple('1');
await app.position.overview.shouldHaveBuyingPower('0.00');
});

test.skip('It should list an opened Aave v3 Multiply Ethereum position in portfolio', async () => {
test.info().annotations.push(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,47 @@ test.describe('Aave v3 Multiply - Ethereum - Wallet connected', async () => {
});
await app.position.overview.shouldHaveDebt({ amount: '8,[0-9]{3}.[0-9]{4}', token: 'DAI' });
});

test('It should close an existent Aave V3 Multiply Ethereum position - Close to collateral token (RETH) @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '12057',
});

test.setTimeout(veryLongTestTimeout);

await app.position.manage.openManageOptions({ currentLabel: 'Adjust' });
await app.position.manage.select('Close position');

await app.position.manage.closeTo('RETH');
await app.position.manage.shouldHaveTokenAmountAfterClosing({
token: 'RETH',
amount: '[0-9]{2}.[0-9]{1,2}',
});

// Transaction randomly fails - Retry until it's completed.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

await app.page.goto('/ethereum/aave/v3/1276#overview');
await app.position.overview.shouldHaveLiquidationPrice({
price: '0.00',
token: 'DAI',
timeout: positionTimeout,
});
await app.position.overview.shouldHaveLoanToValue('0.00');
await app.position.overview.shouldHaveBorrowCost('0.00');
await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'RETH' });
await app.position.overview.shouldHaveExposure({ amount: '0.00000', token: 'RETH' });
await app.position.overview.shouldHaveDebt({ amount: '0.0000', token: 'DAI' });
await app.position.overview.shouldHaveMultiple('1');
await app.position.overview.shouldHaveBuyingPower('0.00');
});
});

0 comments on commit 9b4db0d

Please sign in to comment.