Skip to content

Commit

Permalink
chore: improving fuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase committed Jul 26, 2024
1 parent bf9bb4d commit d755a22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
11 changes: 5 additions & 6 deletions test/integration/BPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ abstract contract BPoolIntegrationTest is Test, GasSnapshot {
}

function test_extremeCase() public virtual {
uint256 _DAI_WEIGHT = 21095347289582322017;
uint256 _WETH_WEIGHT = 14053292305279328903;
uint256 _DAI_BALANCE = 1000000000000000000;
uint256 _WETH_BALANCE = 839390325460697805479509969833437577;
uint256 _DAI_AMOUNT_OUT = 1000000000000000000;
uint256 _DAI_WEIGHT = 21_095_347_289_582_322_017;

Check warning on line 117 in test/integration/BPool.t.sol

View workflow job for this annotation

GitHub Actions / Static Analysis

Variable name must be in mixedCase
uint256 _WETH_WEIGHT = 14_053_292_305_279_328_903;

Check warning on line 118 in test/integration/BPool.t.sol

View workflow job for this annotation

GitHub Actions / Static Analysis

Variable name must be in mixedCase
uint256 _DAI_BALANCE = 1_000_000_000_000_000_000;

Check warning on line 119 in test/integration/BPool.t.sol

View workflow job for this annotation

GitHub Actions / Static Analysis

Variable name must be in mixedCase
uint256 _WETH_BALANCE = 839_390_325_460_697_805_479_509_969_833_437_577;

Check warning on line 120 in test/integration/BPool.t.sol

View workflow job for this annotation

GitHub Actions / Static Analysis

Variable name must be in mixedCase
uint256 _DAI_AMOUNT_OUT = 1_000_000_000_000_000_000;

Check warning on line 121 in test/integration/BPool.t.sol

View workflow job for this annotation

GitHub Actions / Static Analysis

Variable name must be in mixedCase
uint256 _FEE = 1e18 / 10 ** 6;

Check warning on line 122 in test/integration/BPool.t.sol

View workflow job for this annotation

GitHub Actions / Static Analysis

Variable name must be in mixedCase
uint256 _WHITNESS_FEE = 0.999999e18;

Check warning on line 123 in test/integration/BPool.t.sol

View workflow job for this annotation

GitHub Actions / Static Analysis

Variable name must be in mixedCase

Expand Down Expand Up @@ -153,7 +153,6 @@ abstract contract BPoolIntegrationTest is Test, GasSnapshot {
pool.finalize();
whitnessPool.finalize();


vm.startPrank(swapper.addr);
dai.approve(address(pool), type(uint256).max);
dai.approve(address(whitnessPool), type(uint256).max);
Expand Down
16 changes: 5 additions & 11 deletions test/invariants/fuzz/BMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contract FuzzBMath is EchidnaTest {
MIN_WEIGHT = bmath.MIN_WEIGHT();
MAX_WEIGHT = bmath.MAX_WEIGHT();
MAX_TOTAL_WEIGHT = bmath.MAX_TOTAL_WEIGHT();
MIN_FEE = bmath.MAX_FEE(); //bmath.MIN_FEE();
MIN_FEE = 0.1e18; // 10% fee
MAX_FEE = bmath.MAX_FEE();
}

Expand Down Expand Up @@ -151,18 +151,15 @@ contract FuzzBMath is EchidnaTest {
uint256 tokenBalanceOut,
uint256 tokenWeightOut,
uint256 tokenAmountIn,
uint256 poolSupply,
uint256 totalWeight,
uint256 swapFee
) public {
tokenWeightIn = clamp(tokenWeightIn, MIN_WEIGHT, MAX_WEIGHT - MIN_WEIGHT);
tokenWeightOut = clamp(tokenWeightOut, MIN_WEIGHT, MAX_TOTAL_WEIGHT - tokenWeightIn);
totalWeight = clamp(totalWeight, tokenWeightIn + tokenWeightOut, MAX_TOTAL_WEIGHT);
totalWeight = tokenWeightIn + tokenWeightOut;
uint256 totalWeight = tokenWeightIn + tokenWeightOut;
tokenBalanceIn = clamp(tokenBalanceIn, 1e6, type(uint256).max);
tokenBalanceOut = clamp(tokenBalanceOut, 1e6, type(uint256).max);
tokenAmountIn = clamp(tokenAmountIn, 1e6, type(uint256).max);
poolSupply = clamp(poolSupply, 100 * BONE, type(uint256).max);
uint256 poolSupply = 100 * BONE;
swapFee = clamp(swapFee, MIN_FEE, MAX_FEE);

emit Log('tokenWeightIn', tokenWeightIn);
Expand Down Expand Up @@ -202,17 +199,14 @@ contract FuzzBMath is EchidnaTest {
uint256 tokenBalanceOut,
uint256 tokenWeightOut,
uint256 tokenAmountOut,
uint256 poolSupply,
uint256 totalWeight,
uint256 swapFee
) public {
tokenWeightIn = clamp(tokenWeightIn, MIN_WEIGHT, MAX_WEIGHT - MIN_WEIGHT);
tokenWeightOut = clamp(tokenWeightOut, MIN_WEIGHT, MAX_TOTAL_WEIGHT - tokenWeightIn);
totalWeight = clamp(totalWeight, tokenWeightIn + tokenWeightOut, MAX_TOTAL_WEIGHT);
totalWeight = tokenWeightIn + tokenWeightOut;
uint256 totalWeight = tokenWeightIn + tokenWeightOut;
tokenBalanceIn = clamp(tokenBalanceIn, 1e6, type(uint256).max);
tokenBalanceOut = clamp(tokenBalanceOut, 1e6, type(uint256).max);
poolSupply = clamp(poolSupply, 100 * BONE, type(uint256).max);
uint256 poolSupply = 100 * BONE;
tokenAmountOut = clamp(tokenAmountOut, 1e6, type(uint256).max);
swapFee = clamp(swapFee, MIN_FEE, MAX_FEE);

Expand Down

0 comments on commit d755a22

Please sign in to comment.