From 57140feac306f063ed8f079e7c0e30dab51c23da Mon Sep 17 00:00:00 2001 From: a-t-0 Date: Thu, 28 Mar 2024 17:17:31 +0100 Subject: [PATCH 1/5] Wrote documentation for id function in contract Foo. --- src/Foo.sol | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Foo.sol b/src/Foo.sol index 466b911..8e5e34e 100644 --- a/src/Foo.sol +++ b/src/Foo.sol @@ -2,6 +2,16 @@ pragma solidity >=0.8.23; contract Foo { + /** + * @notice This returns the value that it is given. + * @dev The current dev does not yet know what the permissible range of the + * uint256 values may be, nor how this function handles a None/void/null + * input if those exist in Solidity. Nor do I know how it handles with an + * overflow input value, if that is possible. + * @param value An integer that is assumed to be stored in a 256 bit memory. + * @return The value that it receives as input. The developer does not yet + * know whether Solidity passes uint256 variables by value or by reference. + */ function id(uint256 value) external pure returns (uint256) { return value; } From 3ebacb63bae9aed0c907494c17b3080f8c357fbd Mon Sep 17 00:00:00 2001 From: a-t-0 Date: Thu, 28 Mar 2024 17:44:39 +0100 Subject: [PATCH 2/5] Included zero and -zero tests. --- test/Foo.t.sol | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/Foo.t.sol b/test/Foo.t.sol index 2f23c7f..9bc93bd 100644 --- a/test/Foo.t.sol +++ b/test/Foo.t.sol @@ -29,6 +29,18 @@ contract FooTest is PRBTest, StdCheats { assertEq(foo.id(x), x, "value mismatch"); } + /// @dev Basic test. Run it with `forge test -vvv` to see the console log. + function test_zero_input() external { + uint256 x = 0; + assertEq(foo.id(x), x, "value mismatch"); + } + + /// @dev Basic test. Run it with `forge test -vvv` to see the console log. + function test_negative_zero_input() external { + uint256 x = -0; + assertEq(foo.id(x), x, "value mismatch"); + } + /// @dev Fuzz test that provides random values for an unsigned integer, but which rejects zero as an input. /// If you need more sophisticated input validation, you should use the `bound` utility instead. /// See https://twitter.com/PaulRBerg/status/1622558791685242880 From 3130a7a2584c39917da95714ce75b1dcd06a51f2 Mon Sep 17 00:00:00 2001 From: a-t-0 Date: Thu, 28 Mar 2024 17:47:38 +0100 Subject: [PATCH 3/5] Deindented test. --- .github/workflows/ci.yml | 64 ++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e38561f..ef21d9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,35 +34,35 @@ on: echo "## Build result" >> $GITHUB_STEP_SUMMARY echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - test: - needs: ["build"] - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v4" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Install Bun" - uses: "oven-sh/setup-bun@v1" - - - name: "Install the Node.js dependencies" - run: "bun install" - - - name: "Show the Foundry config" - run: "forge config" - - - name: "Generate a fuzz seed that changes weekly to avoid burning through RPC allowance" - run: > - echo "FOUNDRY_FUZZ_SEED=$( - echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800)) - )" >> $GITHUB_ENV - - - name: "Run the tests" - run: "forge test" - - - name: "Add test summary" - run: | - echo "## Tests result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY +test: + needs: ["build"] + runs-on: "ubuntu-latest" + steps: + - name: "Check out the repo" + uses: "actions/checkout@v4" + + - name: "Install Foundry" + uses: "foundry-rs/foundry-toolchain@v1" + + - name: "Install Bun" + uses: "oven-sh/setup-bun@v1" + + - name: "Install the Node.js dependencies" + run: "bun install" + + - name: "Show the Foundry config" + run: "forge config" + + - name: "Generate a fuzz seed that changes weekly to avoid burning through RPC allowance" + run: > + echo "FOUNDRY_FUZZ_SEED=$( + echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800)) + )" >> $GITHUB_ENV + + - name: "Run the tests" + run: "forge test" + + - name: "Add test summary" + run: | + echo "## Tests result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY From 165b8959ccb4d0013ca123da104e31f497ba03c3 Mon Sep 17 00:00:00 2001 From: a-t-0 Date: Thu, 28 Mar 2024 17:49:05 +0100 Subject: [PATCH 4/5] De-indendted build. --- .github/workflows/ci.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef21d9e..1c8c5d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,28 +11,28 @@ on: branches: - "main" - build: - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v4" +build: + runs-on: "ubuntu-latest" + steps: + - name: "Check out the repo" + uses: "actions/checkout@v4" - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" + - name: "Install Foundry" + uses: "foundry-rs/foundry-toolchain@v1" - - name: "Install Bun" - uses: "oven-sh/setup-bun@v1" + - name: "Install Bun" + uses: "oven-sh/setup-bun@v1" - - name: "Install the Node.js dependencies" - run: "bun install" + - name: "Install the Node.js dependencies" + run: "bun install" - - name: "Build the contracts and print their size" - run: "forge build --sizes" + - name: "Build the contracts and print their size" + run: "forge build --sizes" - - name: "Add build summary" - run: | - echo "## Build result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + - name: "Add build summary" + run: | + echo "## Build result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY test: needs: ["build"] From cbc93035859335085c54ffbec6543ed98f4e0712 Mon Sep 17 00:00:00 2001 From: a-t-0 Date: Thu, 28 Mar 2024 17:51:10 +0100 Subject: [PATCH 5/5] Moved build and test under jobs header. --- .github/workflows/ci.yml | 111 ++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c8c5d3..3065d75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,58 +11,59 @@ on: branches: - "main" -build: - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v4" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Install Bun" - uses: "oven-sh/setup-bun@v1" - - - name: "Install the Node.js dependencies" - run: "bun install" - - - name: "Build the contracts and print their size" - run: "forge build --sizes" - - - name: "Add build summary" - run: | - echo "## Build result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - -test: - needs: ["build"] - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v4" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Install Bun" - uses: "oven-sh/setup-bun@v1" - - - name: "Install the Node.js dependencies" - run: "bun install" - - - name: "Show the Foundry config" - run: "forge config" - - - name: "Generate a fuzz seed that changes weekly to avoid burning through RPC allowance" - run: > - echo "FOUNDRY_FUZZ_SEED=$( - echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800)) - )" >> $GITHUB_ENV - - - name: "Run the tests" - run: "forge test" - - - name: "Add test summary" - run: | - echo "## Tests result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY +jobs: + build: + runs-on: "ubuntu-latest" + steps: + - name: "Check out the repo" + uses: "actions/checkout@v4" + + - name: "Install Foundry" + uses: "foundry-rs/foundry-toolchain@v1" + + - name: "Install Bun" + uses: "oven-sh/setup-bun@v1" + + - name: "Install the Node.js dependencies" + run: "bun install" + + - name: "Build the contracts and print their size" + run: "forge build --sizes" + + - name: "Add build summary" + run: | + echo "## Build result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + + test: + needs: ["build"] + runs-on: "ubuntu-latest" + steps: + - name: "Check out the repo" + uses: "actions/checkout@v4" + + - name: "Install Foundry" + uses: "foundry-rs/foundry-toolchain@v1" + + - name: "Install Bun" + uses: "oven-sh/setup-bun@v1" + + - name: "Install the Node.js dependencies" + run: "bun install" + + - name: "Show the Foundry config" + run: "forge config" + + - name: "Generate a fuzz seed that changes weekly to avoid burning through RPC allowance" + run: > + echo "FOUNDRY_FUZZ_SEED=$( + echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800)) + )" >> $GITHUB_ENV + + - name: "Run the tests" + run: "forge test" + + - name: "Add test summary" + run: | + echo "## Tests result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY