From f1b40329c413ac4ee6b01d4127fd81b49860a853 Mon Sep 17 00:00:00 2001 From: Aleksandr Tarelkin Date: Mon, 11 Nov 2024 17:33:33 +0300 Subject: [PATCH 1/2] github workflow for CI testing --- .github/workflows/tests.yml | 64 +++++++++++++++++++++++++++++++++++++ foundry.toml | 4 +++ 2 files changed, 68 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..b1589c5b --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,64 @@ +name: Run Forge Tests +on: [pull_request] + +jobs: + bootstrap: + name: Bootstrap environment + runs-on: ubuntu-latest + outputs: + cache-path: ${{ steps.cache.outputs.path }} + cache-key: ${{ steps.cache.outputs.key }} + env: + FORGE_REV: 03ea54c + steps: + - name: Build cache params + id: cache + run: | + echo "path=$CACHE_PATH" >> "$GITHUB_OUTPUT" + echo "$KEY_INPUT" | md5sum | awk '{print $1}' | xargs -I% echo "key=cargobin-%-${RUNNER_OS}" >> "$GITHUB_OUTPUT" + env: + CACHE_PATH: | + ~/.cargo/bin/ + KEY_INPUT: | + forge:${{env.FORGE_REV}} + + - uses: actions/cache@v4 + id: get-cache + with: + path: ${{ steps.cache.outputs.path }} + key: ${{ steps.cache.outputs.key }} + + - name: Install forge & anvil + run: cargo install --git https://github.com/foundry-rs/foundry --rev "$FORGE_REV" --profile release --locked forge anvil + if: steps.get-cache.outputs.cache-hit != 'true' + + foundry: + name: Foundry tests + runs-on: ubuntu-latest + needs: bootstrap + env: + FORGE_REV: 03ea54c + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - uses: actions/cache@v4 + with: + path: ${{ needs.bootstrap.outputs.cache-path }} + key: ${{ needs.bootstrap.outputs.cache-key }} + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + cache: yarn + cache-dependency-path: "**/yarn.lock" + + - name: Build + run: forge build --sizes + + - name: Run local integration tests + run: forge test + env: + MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }} \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index a41bd76c..db79f96d 100644 --- a/foundry.toml +++ b/foundry.toml @@ -15,3 +15,7 @@ test = 'test/kontrol' [fmt] line_length = 120 multiline_func_header = 'params_first_multi' + +[fuzz] +runs = 2048 +max_test_rejects = 500000 \ No newline at end of file From ce58033f0d7e9d6271ce7c98c3708548f7158689 Mon Sep 17 00:00:00 2001 From: Aleksandr Tarelkin Date: Mon, 11 Nov 2024 17:33:56 +0300 Subject: [PATCH 2/2] fix: test --- test/unit/committees/TiebreakerSubCommittee.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/committees/TiebreakerSubCommittee.t.sol b/test/unit/committees/TiebreakerSubCommittee.t.sol index 9412fe14..6b826b06 100644 --- a/test/unit/committees/TiebreakerSubCommittee.t.sol +++ b/test/unit/committees/TiebreakerSubCommittee.t.sol @@ -42,7 +42,7 @@ contract TiebreakerSubCommitteeUnitTest is UnitTest { tiebreakerSubCommittee = new TiebreakerSubCommittee(owner, committeeMembers, quorum, tiebreakerCore); } - function test_constructor_HappyPath(address _owner, uint256 _quorum, address _tiebreakerCore) external { + function testFuzz_constructor_HappyPath(address _owner, uint256 _quorum, address _tiebreakerCore) external { vm.assume(_owner != address(0)); vm.assume(_quorum > 0 && _quorum <= committeeMembers.length); new TiebreakerSubCommittee(_owner, committeeMembers, _quorum, _tiebreakerCore);