Skip to content

Commit

Permalink
refactor: deprecate fuzzed integration valid order test in favour of …
Browse files Browse the repository at this point in the history
…unit test
  • Loading branch information
wei3erHase committed Jul 16, 2024
1 parent d0bba5c commit d8c49e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
25 changes: 0 additions & 25 deletions test/integration/BCoWHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,31 +91,6 @@ contract ConstantProductHelperForkedTest is Test {
assertEq(postSpotPrice, 1_052_631_578_947_368);
}

// NOTE: this test checks that the order generated by the helper is valid
function testValidOrder(uint256 priceSkewness) public {
IBCoWPool pool = IBCoWPool(address(basicPool));

// skew the price by max 50% (more could result in reverts bc of max swap ratio)
priceSkewness = bound(priceSkewness, 5000, 15_000);
vm.assume(priceSkewness != 10_000); // avoids no-skewness revert

uint256[] memory prices = new uint256[](2);
prices[0] = INITIAL_WETH_BALANCE;
prices[1] = INITIAL_DAI_BALANCE * priceSkewness / 10_000;

// the helper generates the AMM order
(GPv2Order.Data memory ammOrder,,,) = helper.order(address(pool), prices);

if (priceSkewness > 10_000) {
assertEq(address(ammOrder.buyToken), address(DAI));
} else {
assertEq(address(ammOrder.buyToken), address(WETH));
}

// it should not revert
pool.verify(ammOrder);
}

// NOTE: reverting test, weighted pools are not supported
function testWeightedOrder() public {
IBCoWPool pool = IBCoWPool(address(weightedPool));
Expand Down
2 changes: 2 additions & 0 deletions test/unit/BCoWHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ contract BCoWHelperTest is Test {
// it should return a valid pool order
(GPv2Order.Data memory ammOrder,,,) = helper.order(address(pool), prices);

assertEq(address(ammOrder.buyToken), priceSkewness > 10_000 ? tokens[0] : tokens[1]);

// this call should not revert
pool.verify(ammOrder);
}
Expand Down

0 comments on commit d8c49e6

Please sign in to comment.