Skip to content

testAssertUint128 validates wrong failure path instead of uint128 overflow #779

@BZAghalarov

Description

@BZAghalarov

Hi,

In the testAssertUint128 author checks ExceedsMaxDeposit and ExceedsMaxRedeem conditions.

Due to at the end of vault.deposit(amount, randomUser, self); (also vault.redeem) call priceAssetPerShare.isZero() return True
we get ExceedsMaxDeposit error.

But actually its not intended check, if you change the amount to any random(not more than MAX_UINT128) number this test(attached test function) still will be pass but doesn't check overflow condition.

The deposit function comparison returns true for the following equation
require(assets <= _maxDeposit(vault_, controller), ExceedsMaxDeposit());
because _maxDeposit returns "0"

But actually here when we set vm.assume(amount > 0 && amount < MAX_UINT128);
condition assets variable doesn't go over MAXUINT128. but still we get ExceedsMaxDeposit.

Probably you should remove those 2 checks to the different test function and exact scenario when we get Uint128_Overflow from deposit/redeem call.

P.S I’m not sure whether it would be appropriate to create a PR myself as SR, so I chose not to open one.

function testAssertExceedsMax(uint256 amount) public {
    vm.assume(amount > 0 && amount < MAX_UINT128); // amount has to overflow UINT128
    (, address vault_, ) = deploySimpleVault(VaultKind.Async);
    AsyncVault vault = AsyncVault(vault_);

    vm.expectRevert(IAsyncRequestManager.ExceedsMaxDeposit.selector);
    vault.deposit(amount, randomUser, self);

    vm.expectRevert(IAsyncRequestManager.ExceedsMaxRedeem.selector);
    vault.redeem(amount, randomUser, self);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions