mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
updated interest redirection tests
This commit is contained in:
parent
223690f5f1
commit
0f06c3b72e
|
@ -404,6 +404,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
|
||||||
function _resetDataOnZeroBalance(address user) internal returns (bool) {
|
function _resetDataOnZeroBalance(address user) internal returns (bool) {
|
||||||
//if the user has 0 principal balance, the interest stream redirection gets reset
|
//if the user has 0 principal balance, the interest stream redirection gets reset
|
||||||
_interestRedirectionAddresses[user] = address(0);
|
_interestRedirectionAddresses[user] = address(0);
|
||||||
|
_interestRedirectionIndexes[user] = 0;
|
||||||
|
|
||||||
//emits a InterestStreamRedirected event to notify that the redirection has been reset
|
//emits a InterestStreamRedirected event to notify that the redirection has been reset
|
||||||
emit InterestStreamRedirected(user, address(0), 0, 0);
|
emit InterestStreamRedirected(user, address(0), 0, 0);
|
||||||
|
|
|
@ -49,14 +49,13 @@ const almostEqualOrEqual = function (
|
||||||
key === 'marketStableRate' ||
|
key === 'marketStableRate' ||
|
||||||
key === 'symbol' ||
|
key === 'symbol' ||
|
||||||
key === 'aTokenAddress' ||
|
key === 'aTokenAddress' ||
|
||||||
key === 'initialATokenExchangeRate' ||
|
|
||||||
key === 'decimals'
|
key === 'decimals'
|
||||||
) {
|
) {
|
||||||
// skipping consistency check on accessory data
|
// skipping consistency check on accessory data
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.assert(actual[key] != undefined, `Property ${key} is undefined in the actual data`);
|
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`);
|
expect(expected[key] != undefined, `Property ${key} is undefined in the expected data`);
|
||||||
|
|
||||||
|
@ -682,7 +681,7 @@ export const redirectInterestStream = async (
|
||||||
const {userData: toDataAfter} = await getContractsData(reserve, to, testEnv);
|
const {userData: toDataAfter} = await getContractsData(reserve, to, testEnv);
|
||||||
|
|
||||||
const [expectedFromData, expectedToData] = calcExpectedUsersDataAfterRedirectInterest(
|
const [expectedFromData, expectedToData] = calcExpectedUsersDataAfterRedirectInterest(
|
||||||
reserveDataBefore,
|
reserveDataBefore,
|
||||||
fromDataBefore,
|
fromDataBefore,
|
||||||
toDataBefore,
|
toDataBefore,
|
||||||
user.address,
|
user.address,
|
||||||
|
@ -692,7 +691,10 @@ export const redirectInterestStream = async (
|
||||||
txTimestamp
|
txTimestamp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log("Checking from data");
|
||||||
|
|
||||||
expectEqual(fromDataAfter, expectedFromData);
|
expectEqual(fromDataAfter, expectedFromData);
|
||||||
|
console.log("Checking to data");
|
||||||
expectEqual(toDataAfter, expectedToData);
|
expectEqual(toDataAfter, expectedToData);
|
||||||
|
|
||||||
// truffleAssert.eventEmitted(txResult, 'InterestStreamRedirected', (ev: any) => {
|
// truffleAssert.eventEmitted(txResult, 'InterestStreamRedirected', (ev: any) => {
|
||||||
|
|
|
@ -82,7 +82,7 @@ export const getUserData = async (
|
||||||
return {
|
return {
|
||||||
scaledATokenBalance: new BigNumber(scaledATokenBalance),
|
scaledATokenBalance: new BigNumber(scaledATokenBalance),
|
||||||
interestRedirectionAddress,
|
interestRedirectionAddress,
|
||||||
interestRedirectionIndex,
|
interestRedirectionIndex: new BigNumber(interestRedirectionIndex),
|
||||||
redirectionAddressRedirectedBalance: new BigNumber(redirectionAddressRedirectedBalance),
|
redirectionAddressRedirectedBalance: new BigNumber(redirectionAddressRedirectedBalance),
|
||||||
redirectedBalance: new BigNumber(redirectedBalance),
|
redirectedBalance: new BigNumber(redirectedBalance),
|
||||||
currentATokenBalance: new BigNumber(userData.currentATokenBalance.toString()),
|
currentATokenBalance: new BigNumber(userData.currentATokenBalance.toString()),
|
||||||
|
@ -136,6 +136,6 @@ const getATokenUserData = async (reserve: string, user: string, pool: LendingPoo
|
||||||
scaledATokenBalance.toString(),
|
scaledATokenBalance.toString(),
|
||||||
redirectionAddressRedirectedBalance.toString(),
|
redirectionAddressRedirectedBalance.toString(),
|
||||||
interestRedirectionAddress,
|
interestRedirectionAddress,
|
||||||
interestRedirectionIndex
|
interestRedirectionIndex.toString()
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user