mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Fixed withdrawal tests
This commit is contained in:
parent
90de5d2b0f
commit
6454f040e8
|
@ -444,10 +444,6 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
|
|||
|
||||
uint256 scaledAmount = amount.rayDiv(index);
|
||||
|
||||
console.log("scaled balanceOf from: %s", scaledBalanceOf(from));
|
||||
console.log("scaled balanceOf to: %s", scaledBalanceOf(to));
|
||||
console.log("scaled amount: %s", scaledAmount);
|
||||
|
||||
super._transfer(from, to, scaledAmount);
|
||||
|
||||
//if the sender is redirecting his interest towards someone else,
|
||||
|
|
|
@ -56,16 +56,19 @@ const almostEqualOrEqual = function (
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
this.assert(actual[key] != undefined, `Property ${key} is undefined in the actual data`);
|
||||
expect(expected[key] != undefined, `Property ${key} is undefined in the expected data`);
|
||||
|
||||
if (!expected[key] || !actual[key]) {
|
||||
console.log('Found a undefined value for Key ', key, ' value ', expected[key], actual[key]);
|
||||
}
|
||||
|
||||
if (actual[key] instanceof BigNumber) {
|
||||
if (!expected[key]) {
|
||||
console.log('Key ', key, ' value ', expected[key], actual[key]);
|
||||
}
|
||||
|
||||
const actualValue = (<BigNumber>actual[key]).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||
const expectedValue = (<BigNumber>expected[key]).decimalPlaces(0, BigNumber.ROUND_DOWN);
|
||||
|
||||
|
||||
this.assert(
|
||||
actualValue.eq(expectedValue) ||
|
||||
actualValue.plus(1).eq(expectedValue) ||
|
||||
|
|
|
@ -120,7 +120,9 @@ export const calcExpectedUserDataAfterWithdraw = (
|
|||
}
|
||||
|
||||
expectedUserData.scaledATokenBalance = calcExpectedScaledATokenBalance(reserveDataAfterAction, userDataBeforeAction, new BigNumber(0), new BigNumber(amountWithdrawn));
|
||||
|
||||
|
||||
console.log("Scaled balance is ", expectedUserData.scaledATokenBalance.toFixed());
|
||||
|
||||
expectedUserData.currentATokenBalance = aTokenBalance.minus(
|
||||
amountWithdrawn
|
||||
);
|
||||
|
@ -161,8 +163,10 @@ export const calcExpectedUserDataAfterWithdraw = (
|
|||
|
||||
if (expectedUserData.currentATokenBalance.eq(0) && expectedUserData.redirectedBalance.eq(0)) {
|
||||
expectedUserData.interestRedirectionAddress = ZERO_ADDRESS;
|
||||
expectedUserData.interestRedirectionIndex = new BigNumber(0);
|
||||
} else {
|
||||
expectedUserData.interestRedirectionAddress = userDataBeforeAction.interestRedirectionAddress;
|
||||
expectedUserData.interestRedirectionIndex = userDataBeforeAction.interestRedirectionAddress == ZERO_ADDRESS ? new BigNumber(0) : reserveDataAfterAction.liquidityIndex;
|
||||
}
|
||||
|
||||
expectedUserData.redirectionAddressRedirectedBalance = calcExpectedRedirectedBalance(
|
||||
|
@ -172,7 +176,7 @@ export const calcExpectedUserDataAfterWithdraw = (
|
|||
new BigNumber(0),
|
||||
new BigNumber(amountWithdrawn)
|
||||
);
|
||||
|
||||
|
||||
return expectedUserData;
|
||||
};
|
||||
|
||||
|
@ -564,9 +568,10 @@ export const calcExpectedUserDataAfterBorrow = (
|
|||
userDataBeforeAction,
|
||||
currentTimestamp
|
||||
);
|
||||
expectedUserData.principalATokenBalance = userDataBeforeAction.principalATokenBalance;
|
||||
expectedUserData.scaledATokenBalance = userDataBeforeAction.scaledATokenBalance;
|
||||
expectedUserData.redirectedBalance = userDataBeforeAction.redirectedBalance;
|
||||
expectedUserData.interestRedirectionAddress = userDataBeforeAction.interestRedirectionAddress;
|
||||
expectedUserData.interestRedirectionIndex = userDataBeforeAction.interestRedirectionIndex;
|
||||
expectedUserData.redirectionAddressRedirectedBalance =
|
||||
userDataBeforeAction.redirectionAddressRedirectedBalance;
|
||||
expectedUserData.currentATokenUserIndex = userDataBeforeAction.currentATokenUserIndex;
|
||||
|
|
|
@ -12,7 +12,7 @@ BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN});
|
|||
|
||||
const scenarioFolder = './test/helpers/scenarios/';
|
||||
|
||||
const selectedScenarios: string[] = ['withdraw.json'];
|
||||
const selectedScenarios: string[] = [];
|
||||
|
||||
fs.readdirSync(scenarioFolder).forEach((file) => {
|
||||
if (selectedScenarios.length > 0 && !selectedScenarios.includes(file)) return;
|
||||
|
|
Loading…
Reference in New Issue
Block a user