Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute Magic Amounts failure #53

Closed
gakonst opened this issue Feb 28, 2022 · 1 comment · Fixed by #54
Closed

Compute Magic Amounts failure #53

gakonst opened this issue Feb 28, 2022 · 1 comment · Fixed by #54

Comments

@gakonst
Copy link

gakonst commented Feb 28, 2022

Running forge t --optimize-runs 800 -vvvv --fork-block-number 13806816 while I was testing in foundry-rs/foundry#821, I got a failing test case for the test_computeMagicAmounts test, courtesy of our recently updated fuzzer logic (foundry-rs/foundry#735), which otherwise passes with dapptools:

Failed tests:
[FAIL. Counterexample: calldata=0x1e0eabea0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c9, args=[0, 0, 201]] test_computeMagicAmounts(uint256,uint256,uint24) (runs: 31, μ: 2428, ~: 1417)
  function test_computeMagicAmountsRegression() public {
        uint256 inventory0 = 0;
        uint256 inventory1 = 0;
        uint24 halfWidth = 201;
        if (int24(halfWidth) < blend.MIN_WIDTH() / 2) return;
        if (int24(halfWidth) > blend.MAX_WIDTH() / 2) return;

        (uint256 amount0, uint256 amount1) = blend.computeMagicAmounts(inventory0, inventory1, int24(halfWidth));

        assertLt(amount0, inventory0);
        assertLt(amount1, inventory1);
    }
@adamegyed
Copy link
Contributor

Thanks for pointing this out @gakonst! After investigating, we've found the issue to be specifically from the zero inventory case. To address this, we'll adjust the assertions to be <= rather than just <, which is a more accurate requirement for all cases in the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants