Fixes aToken bug

This commit is contained in:
The3D 2020-07-14 14:43:43 +02:00
parent 89ad335912
commit 92f2f2a9b3
2 changed files with 16 additions and 1 deletions

View File

@ -554,7 +554,7 @@ contract AToken is ERC20 {
bool fromIndexReset = false;
//reset the user data if the remaining balance is 0
if (fromBalance.sub(_value) == 0) {
if (fromBalance.sub(_value) == 0 && _from != _to) {
fromIndexReset = resetDataOnZeroBalanceInternal(_from);
}

View File

@ -188,4 +188,19 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => {
INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER
);
});
it('User 1 transfers the whole amount to himself', async () => {
const {users, pool, aDai, dai} = testEnv;
const user1BalanceBefore = await aDai.balanceOf(users[1].address);
await aDai.connect(users[1].signer).transfer(users[1].address, user1BalanceBefore);
const user1BalanceAfter = await aDai.balanceOf(users[1].address);
expect(user1BalanceAfter.toString()).to.be.equal(
user1BalanceBefore,
INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER
);
});
});