Skip to content

Commit

Permalink
test: foundry support added
Browse files Browse the repository at this point in the history
  • Loading branch information
faheelsattar committed May 14, 2022
1 parent 79e556d commit 26a6e19
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TestContract:testBar() (gas: 401)
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI
on:
push:
branches:
- master
pull_request:

env:
FOUNDRY_PROFILE: ci

jobs:
run-ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install deps
run: forge install

- name: Check gas snapshots
run: forge snapshot --check

- name: Run tests
run: forge test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cache/
out/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions src/Contract.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.13;

contract Contract { }
23 changes: 23 additions & 0 deletions test/Contract.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.13;

import "forge-std/Test.sol";

import "src/Contract.sol";

contract TestContract is Test {
Contract c;

function setUp() public {
c = new Contract();
}

function testBar() public {
assertEq(uint256(1), uint256(1), "ok");
}

function testFoo(uint256 x) public {
vm.assume(x < type(uint128).max);
assertEq(x + x, x * 2);
}
}

0 comments on commit 26a6e19

Please sign in to comment.