mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
add failing test for setUsingAsCollateral
This commit is contained in:
parent
4912f3bb73
commit
77ca4b47f8
|
@ -7,6 +7,7 @@ import {APPROVAL_AMOUNT_LENDING_POOL} from '../helpers/constants';
|
|||
import {getContractsData, getTxCostAndTimestamp} from './helpers/actions';
|
||||
import {calcExpectedATokenBalance} from './helpers/utils/calculations';
|
||||
import {waitForTx} from './__setup.spec';
|
||||
import {advanceBlock, timeLatest} from '../helpers/misc-utils';
|
||||
|
||||
const {expect} = require('chai');
|
||||
|
||||
|
@ -133,4 +134,46 @@ makeSuite('LendingPool CollateralSwap function', (testEnv: TestEnv) => {
|
|||
pool.collateralSwap(_mockSwapAdapter.address, weth.address, dai.address, amountToSwap, '0x10')
|
||||
).to.be.revertedWith(HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD);
|
||||
});
|
||||
|
||||
it('Should set usage as collateral to false if no leftovers after swap', async () => {
|
||||
const {pool, weth, dai, aEth} = testEnv;
|
||||
const userAddress = await pool.signer.getAddress();
|
||||
|
||||
// cleanup borrowings, to be abe to swap whole weth
|
||||
const amountToRepay = ethers.utils.parseEther('0.2');
|
||||
await weth.mint(amountToRepay);
|
||||
await pool.repay(weth.address, amountToRepay, '1', userAddress);
|
||||
const txTimestamp = (await timeLatest()).plus(100);
|
||||
|
||||
const {
|
||||
reserveData: wethReserveDataBefore,
|
||||
userData: wethUserDataBefore,
|
||||
} = await getContractsData(weth.address, userAddress, testEnv);
|
||||
const amountToSwap = calcExpectedATokenBalance(
|
||||
wethReserveDataBefore,
|
||||
wethUserDataBefore,
|
||||
txTimestamp
|
||||
);
|
||||
|
||||
await advanceBlock(txTimestamp.toNumber());
|
||||
|
||||
console.log('before', amountToSwap.toString());
|
||||
await pool.collateralSwap(
|
||||
_mockSwapAdapter.address,
|
||||
weth.address,
|
||||
dai.address,
|
||||
'1'.toString(),
|
||||
'0x10'
|
||||
);
|
||||
console.log('after', (await aEth.balanceOf(userAddress)).toString());
|
||||
const {userData: wethUserDataAfter} = await getContractsData(
|
||||
weth.address,
|
||||
userAddress,
|
||||
testEnv
|
||||
);
|
||||
expect(wethUserDataAfter.usageAsCollateralEnabled).to.be.equal(
|
||||
false,
|
||||
'usageAsCollateralEnabled are not set to false'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user