updated interest redirection tests

This commit is contained in:
The3D 2020-09-09 17:20:36 +02:00
parent 223690f5f1
commit 0f06c3b72e
3 changed files with 8 additions and 5 deletions

View File

@ -404,6 +404,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
function _resetDataOnZeroBalance(address user) internal returns (bool) {
//if the user has 0 principal balance, the interest stream redirection gets reset
_interestRedirectionAddresses[user] = address(0);
_interestRedirectionIndexes[user] = 0;
//emits a InterestStreamRedirected event to notify that the redirection has been reset
emit InterestStreamRedirected(user, address(0), 0, 0);

View File

@ -49,14 +49,13 @@ const almostEqualOrEqual = function (
key === 'marketStableRate' ||
key === 'symbol' ||
key === 'aTokenAddress' ||
key === 'initialATokenExchangeRate' ||
key === 'decimals'
) {
// skipping consistency check on accessory data
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`);
@ -682,7 +681,7 @@ export const redirectInterestStream = async (
const {userData: toDataAfter} = await getContractsData(reserve, to, testEnv);
const [expectedFromData, expectedToData] = calcExpectedUsersDataAfterRedirectInterest(
reserveDataBefore,
reserveDataBefore,
fromDataBefore,
toDataBefore,
user.address,
@ -692,7 +691,10 @@ export const redirectInterestStream = async (
txTimestamp
);
console.log("Checking from data");
expectEqual(fromDataAfter, expectedFromData);
console.log("Checking to data");
expectEqual(toDataAfter, expectedToData);
// truffleAssert.eventEmitted(txResult, 'InterestStreamRedirected', (ev: any) => {

View File

@ -82,7 +82,7 @@ export const getUserData = async (
return {
scaledATokenBalance: new BigNumber(scaledATokenBalance),
interestRedirectionAddress,
interestRedirectionIndex,
interestRedirectionIndex: new BigNumber(interestRedirectionIndex),
redirectionAddressRedirectedBalance: new BigNumber(redirectionAddressRedirectedBalance),
redirectedBalance: new BigNumber(redirectedBalance),
currentATokenBalance: new BigNumber(userData.currentATokenBalance.toString()),
@ -136,6 +136,6 @@ const getATokenUserData = async (reserve: string, user: string, pool: LendingPoo
scaledATokenBalance.toString(),
redirectionAddressRedirectedBalance.toString(),
interestRedirectionAddress,
interestRedirectionIndex
interestRedirectionIndex.toString()
];
};