diff --git a/contracts/tokenization/AToken.sol b/contracts/tokenization/AToken.sol index e0e874d7..2a810641 100644 --- a/contracts/tokenization/AToken.sol +++ b/contracts/tokenization/AToken.sol @@ -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); diff --git a/test/helpers/actions.ts b/test/helpers/actions.ts index 616e8ffa..2a84fa66 100644 --- a/test/helpers/actions.ts +++ b/test/helpers/actions.ts @@ -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) => { diff --git a/test/helpers/utils/helpers.ts b/test/helpers/utils/helpers.ts index aa564de0..ccd7d1d1 100644 --- a/test/helpers/utils/helpers.ts +++ b/test/helpers/utils/helpers.ts @@ -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() ]; };