From 760c33cbf4b4ad84c82c645ae4073c1409d87bbc Mon Sep 17 00:00:00 2001 From: BCLeFevre Date: Wed, 27 Mar 2024 10:36:57 -0500 Subject: [PATCH 1/6] First commit --- foundry.toml | 4 ++++ test/foundry/TestTstorish.t.sol | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/foundry/TestTstorish.t.sol diff --git a/foundry.toml b/foundry.toml index 19d478a..1f44df6 100644 --- a/foundry.toml +++ b/foundry.toml @@ -3,5 +3,9 @@ src = "src" out = "out" libs = ["lib"] evm_version = "cancun" +test = 'test/foundry' +remappings = [ + 'forge-std/=lib/forge-std/src/', + ] # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options diff --git a/test/foundry/TestTstorish.t.sol b/test/foundry/TestTstorish.t.sol new file mode 100644 index 0000000..fd42bb7 --- /dev/null +++ b/test/foundry/TestTstorish.t.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +import {Test} from "forge-std/Test.sol"; + +import {Tstorish} from "../../src/Tstorish.sol"; + +contract TestTstorish is Test { + Tstorish tstorish; + + function setUp() public override { + _deployTstorish(); + } + + function _deployTstorish() private { + tstorish = new Tstorish(); + } +} From 1bfd0044482ac4bbf983f3d6841647b4010b433c Mon Sep 17 00:00:00 2001 From: BCLeFevre Date: Wed, 27 Mar 2024 10:37:08 -0500 Subject: [PATCH 2/6] forge install: forge-std v1.8.1 --- .gitmodules | 3 +++ lib/forge-std | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 lib/forge-std diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..888d42d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/forge-std"] + path = lib/forge-std + url = https://github.com/foundry-rs/forge-std diff --git a/lib/forge-std b/lib/forge-std new file mode 160000 index 0000000..bb4ceea --- /dev/null +++ b/lib/forge-std @@ -0,0 +1 @@ +Subproject commit bb4ceea94d6f10eeb5b41dc2391c6c8bf8e734ef From 0e603ba7238156f8682e6c66bbd50848ccf7465c Mon Sep 17 00:00:00 2001 From: BCLeFevre Date: Wed, 27 Mar 2024 10:54:40 -0500 Subject: [PATCH 3/6] Base test --- test/foundry/TestTstorish.t.sol | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/foundry/TestTstorish.t.sol b/test/foundry/TestTstorish.t.sol index fd42bb7..7771cb2 100644 --- a/test/foundry/TestTstorish.t.sol +++ b/test/foundry/TestTstorish.t.sol @@ -8,11 +8,16 @@ import {Tstorish} from "../../src/Tstorish.sol"; contract TestTstorish is Test { Tstorish tstorish; - function setUp() public override { + function setUp() public { _deployTstorish(); } function _deployTstorish() private { tstorish = new Tstorish(); } + + function testActivateTstore() public { + vm.expectRevert(abi.encodeWithSignature("TStoreAlreadyActivated()")); + tstorish.__activateTstore(); + } } From 8a1c577470d91fa7c5becd844563321d2baab241 Mon Sep 17 00:00:00 2001 From: BCLeFevre Date: Wed, 27 Mar 2024 11:10:19 -0500 Subject: [PATCH 4/6] Add workflow --- .github/workflows/test.yml | 35 +++++++++++++++++++++++++++++++++++ foundry.toml | 4 ++++ 2 files changed, 39 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7bdc538 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +name: Test CI + +on: + push: + branches: [main] + tags: ["*"] + pull_request: + types: [opened, reopened, synchronize] + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true + +jobs: + forge: + name: Run Forge Tests (via_ir = true; fuzz_runs = 5000) + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.GH_PAT_TOKEN }} + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Install forge dependencies + run: forge install + + - name: Run tests + run: FOUNDRY_PROFILE=test forge test -vvv diff --git a/foundry.toml b/foundry.toml index 1f44df6..b0c11be 100644 --- a/foundry.toml +++ b/foundry.toml @@ -8,4 +8,8 @@ remappings = [ 'forge-std/=lib/forge-std/src/', ] +[profile.test] +src = 'test/foundry' +cache_path='test-cache' + # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options From 9ef9d12c7948500f6d9dd8150dab420548d78bb2 Mon Sep 17 00:00:00 2001 From: BCLeFevre Date: Wed, 27 Mar 2024 11:13:51 -0500 Subject: [PATCH 5/6] Add workflow --- .github/workflows/test.yml | 2 +- .gitignore | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7bdc538..6257119 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ concurrency: jobs: forge: - name: Run Forge Tests (via_ir = true; fuzz_runs = 5000) + name: Run Forge Tests runs-on: ubuntu-latest timeout-minutes: 30 steps: diff --git a/.gitignore b/.gitignore index f0e124c..4e0257d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,11 @@ cache/ out/ +#foundry test compilation files +cache +out +test-cache + # Ignores development broadcast logs !/broadcast /broadcast/*/31337/ @@ -13,4 +18,4 @@ docs/ # Dotenv file .env -.DS_Store \ No newline at end of file +.DS_Store From f4f67018f806fc4623c7f528b91c27acb3975096 Mon Sep 17 00:00:00 2001 From: BCLeFevre Date: Wed, 27 Mar 2024 11:19:39 -0500 Subject: [PATCH 6/6] Add workflow --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6257119..967424d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,8 +19,6 @@ jobs: steps: - uses: actions/checkout@v3 with: - ref: ${{ github.head_ref }} - token: ${{ secrets.GH_PAT_TOKEN }} submodules: recursive - name: Install Foundry