Skip to content

Commit

Permalink
feat: adding gas snapshots to integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase committed May 10, 2024
1 parent 1a87b42 commit 849095f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions .forge-snapshots/swapExactAmountIn.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
143158
2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ sort_imports = true
solc_version = '0.8.23'
libs = ["node_modules", "lib"]
optimizer_runs = 10_000
ffi = true
fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}]

[profile.optimized]
via_ir = true
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@defi-wonderland/natspec-smells": "1.1.1",
"@defi-wonderland/smock-foundry": "1.5.0",
"forge-std": "github:foundry-rs/forge-std#5475f85",
"forge-gas-snapshot": "github:marktoda/forge-gas-snapshot#9161f7c",
"husky": ">=8",
"lint-staged": ">=10",
"solhint": "github:solhint-community/solhint-community#v4.0.0-rc01",
Expand Down
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ds-test/=node_modules/ds-test/src
forge-std/=node_modules/forge-std/src
forge-gas-snapshot/=node_modules/forge-gas-snapshot/src
solmate/=node_modules/solmate/src

contracts/=src/contracts
6 changes: 5 additions & 1 deletion test/integration/PoolSwap.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {BFactory} from 'contracts/BFactory.sol';
import {BPool} from 'contracts/BPool.sol';
import {IERC20} from 'contracts/BToken.sol';

abstract contract PoolSwapIntegrationTest is Test {
import {GasSnapshot} from "forge-gas-snapshot/GasSnapshot.sol";

Check failure on line 9 in test/integration/PoolSwap.t.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Use single quotes for string literals

abstract contract PoolSwapIntegrationTest is Test, GasSnapshot {
BFactory public factory;
BPool public pool;

Expand Down Expand Up @@ -66,7 +68,9 @@ contract DirectPoolSwapIntegrationTest is PoolSwapIntegrationTest {
tokenA.approve(address(pool), type(uint256).max);

// swap 0.5 tokenA for tokenB
snapStart('swapExactAmountIn');
pool.swapExactAmountIn(address(tokenA), 0.5e18, address(tokenB), 0, type(uint256).max);
snapEnd();

vm.stopPrank();
}
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,10 @@ for-each@^0.3.3:
dependencies:
is-callable "^1.1.3"

"forge-gas-snapshot@github:marktoda/forge-gas-snapshot#9161f7c":
version "0.0.0"
resolved "https://codeload.github.com/marktoda/forge-gas-snapshot/tar.gz/9161f7c0b6c6788a89081e2b3b9c67592b71e689"

"forge-std@github:foundry-rs/forge-std#5475f85":
version "1.7.6"
resolved "https://codeload.github.com/foundry-rs/forge-std/tar.gz/5475f852e3f530d7e25dfb4596aa1f9baa8ffdfc"
Expand Down

0 comments on commit 849095f

Please sign in to comment.