ethereum / hevm

symbolic EVM evaluator
https://hevm.dev
GNU Affero General Public License v3.0
227 stars 46 forks source link

Different behaviors for expected to revert function #418

Closed acmLL closed 9 months ago

acmLL commented 10 months ago

Configuration: MacBook Pro, Apple M1 Pro, Sonoma 14.0, 32GB

hevm version: 0.52.0 (static version)

+++++++++++++++ Scenario +++++++++++++++++++ Given this function

function setSlippageTolerance(uint256 newSlippageTolerance) external onlyAdmin {
    if (newSlippageTolerance > C.ONE) revert InvalidSlippageTolerance();
    slippageTolerance = newSlippageTolerance;
    emit SlippageToleranceUpdated(msg.sender, newSlippageTolerance);
}

where uint256 public constant ONE = 1e18;

and this test function

function test_reverts_setSlippageTolerance(uint256 newslippageTolerance) public {
    if(newslippageTolerance > C.ONE) {
        try vault.setSlippageTolerance(newslippageTolerance) {
            assert(false);
        }
        catch {
            assert(true);
        }
    }
}

The above test function reports PASS in forge test and hevm test (using prove instead of test). The above code is the only one that seems to work properly with hevm test. But when we change the test function to

function test_reverts_setSlippageTolerance(uint256 newslippageTolerance) public {
    if(newslippageTolerance > C.ONE) {
        vm.expectRevert();
        vault.setSlippageTolerance(C.ONE);
    }
}

Only forge test reports FAIL because the above function will not revert indeed. hevm test reports PASS (using the prefix prove). And by changing the prefix to proveFail, hevm test reports FAIL with "result: Successful execution". What is the expected behavior here? Or is it a bug indeed?

acmLL commented 10 months ago

Forget about this. This is related to another issue that I opened up and already closed... Thanks

msooseth commented 10 months ago

Oh, do you mean issue #419 ? Can I close this issue then? :smiley:

acmLL commented 10 months ago

Hi, I just provided an example @d_xo asked. Thanks!

On Tue, Nov 7, 2023 at 11:01 AM Mate Soos @ Ethereum Foundation < @.***> wrote:

Oh, do you mean issue #419 https://github.com/ethereum/hevm/issues/419 ? Can I close this issue then? 😃

— Reply to this email directly, view it on GitHub https://github.com/ethereum/hevm/issues/418#issuecomment-1798579249, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2CNL6KM47H552NU7I2JTK3YDI5MJAVCNFSM6AAAAAA67KM7B6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJYGU3TSMRUHE . You are receiving this because you authored the thread.Message ID: @.***>

msooseth commented 9 months ago

OK, thanks! So we'll track this at #419 I'm closing this and picking that up :) Thanks again for reporting!