Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
feat: use soldeer
Browse files Browse the repository at this point in the history
  • Loading branch information
marktoda committed Aug 27, 2024
1 parent 9fc447c commit fed0eb1
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/manySstore.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
70348
49284
2 changes: 1 addition & 1 deletion .forge-snapshots/singleSstore.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
48459
27395
2 changes: 1 addition & 1 deletion .forge-snapshots/singleSstoreClosure.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
46269
25205
2 changes: 1 addition & 1 deletion .forge-snapshots/singleSstoreLastCall.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
43429
22365
2 changes: 1 addition & 1 deletion .forge-snapshots/sstoreClosure.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
68158
47094
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
out/
lib/
cache/
dependencies/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

5 changes: 5 additions & 0 deletions .soldeerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git/
.github/
.forge_snapshots/
out/
dependencies/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Forge has native gas reporting with `forge snapshot` and `forge test --gas-repor

# Installation
```solidity
forge install marktoda/forge-gas-snapshot
soldeer install forge-gas-snapshot~v0.0.5
```

- NOTE: foundry.toml must be updated to allow forge to write the snapshots
Expand Down
13 changes: 13 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,16 @@ out = 'out'
libs = ['lib']
ffi = true
fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}]

[soldeer]
# whether soldeer manages remappings
remappings_generated = true

# whether soldeer re-generates all remappings when installing, updating or uninstalling deps
remappings_regenerate = true

# whether to suffix the remapping with the version: `name-a.b.c`
remappings_version = false

[dependencies]
forge-std = "1.9.2"
1 change: 0 additions & 1 deletion lib/forge-std
Submodule forge-std deleted from 2d8b7b
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
forge-std/=dependencies/forge-std-1.9.2/
6 changes: 6 additions & 0 deletions soldeer.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[dependencies]]
name = "forge-std"
version = "1.9.2"
source = "https://soldeer-revisions.s3.amazonaws.com/forge-std/1_9_2_06-08-2024_17:31:25_forge-std-1.9.2.zip"
checksum = "20fd008c7c69b6c737cc0284469d1c76497107bc3e004d8381f6d8781cb27980"
integrity = "ae8b0d2637a0bdd85b6134117c0a7549dbe0ee8af66db454c66060547b654a89"
4 changes: 2 additions & 2 deletions src/GasSnapshot.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "forge-std/console2.sol";
import {Script} from "forge-std/Script.sol";
import "forge-std/src/console2.sol";
import {Script} from "forge-std/src/Script.sol";
import {UintString} from "./utils/UintString.sol";

contract GasSnapshot is Script {
Expand Down
16 changes: 8 additions & 8 deletions test/GasSnapshot.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import "forge-std/console2.sol";
import {Test} from "forge-std/Test.sol";
import "forge-std/src/console2.sol";
import {Test} from "forge-std/src/Test.sol";
import {GasSnapshot} from "../src/GasSnapshot.sol";
import {SimpleOperations} from "../src/test/SimpleOperations.sol";

Expand All @@ -26,7 +26,7 @@ contract GasSnapshotTest is Test, GasSnapshot {
snapEnd();

string memory value = vm.readLine(".forge-snapshots/singleSstore.snap");
assertEq(value, "48459");
assertEq(value, "27395");
}

function testSingleSstoreLastCall() public {
Expand All @@ -35,21 +35,21 @@ contract GasSnapshotTest is Test, GasSnapshot {

string memory value = vm.readLine(".forge-snapshots/singleSstoreLastCall.snap");
// includes 21,000 overhead for transaction, 20,000 clean SSTORE
assertEq(value, "43429");
assertEq(value, "22365");
}

function testSingleSstoreClosure() public {
snap("singleSstoreClosure", simpleOperations.singleSstore);

string memory value = vm.readLine(".forge-snapshots/singleSstoreClosure.snap");
assertEq(value, "46269");
assertEq(value, "25205");
}

function testManySstoreClosure() public {
snap("sstoreClosure", simpleOperations.manySstore);

string memory value = vm.readLine(".forge-snapshots/sstoreClosure.snap");
assertEq(value, "68158");
assertEq(value, "47094");
}

function testInternalClosure() public {
Expand Down Expand Up @@ -96,7 +96,7 @@ contract GasSnapshotTest is Test, GasSnapshot {
snapEnd();

string memory value = vm.readLine(".forge-snapshots/manySstore.snap");
assertEq(value, "70348");
assertEq(value, "49284");
}

function testSnapshotCodeSize() public {
Expand Down Expand Up @@ -132,7 +132,7 @@ contract GasSnapshotTest is Test, GasSnapshot {
// preloaded with the wrong value
snapStart("checkManySstore");
simpleOperations.manySstore();
vm.expectRevert(abi.encodeWithSelector(GasSnapshot.GasMismatch.selector, 1, 73825));
vm.expectRevert(abi.encodeWithSelector(GasSnapshot.GasMismatch.selector, 1, 52761));
snapEnd();
}

Expand Down

0 comments on commit fed0eb1

Please sign in to comment.