Skip to content

Commit

Permalink
test: refactor test to tests dir (#1095)
Browse files Browse the repository at this point in the history
  • Loading branch information
smol-ninja authored Nov 26, 2024
1 parent 1c2e385 commit 44c43a7
Show file tree
Hide file tree
Showing 200 changed files with 59 additions and 56 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci-deep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
with:
foundry-fuzz-runs: ${{ fromJSON(inputs.unitFuzzRuns || '50000') }}
foundry-profile: "test-optimized"
match-path: "test/unit/**/*.sol"
match-path: "tests/unit/**/*.sol"
name: "Unit tests"

test-integration:
Expand All @@ -51,7 +51,7 @@ jobs:
with:
foundry-fuzz-runs: ${{ fromJSON(inputs.integrationFuzzRuns || '50000') }}
foundry-profile: "test-optimized"
match-path: "test/integration/**/*.sol"
match-path: "tests/integration/**/*.sol"
name: "Integration tests"

test-invariant:
Expand All @@ -61,7 +61,7 @@ jobs:
foundry-invariant-depth: ${{ fromJSON(inputs.invariantDepth || '100') }}
foundry-invariant-runs: ${{ fromJSON(inputs.invariantRuns || '100') }}
foundry-profile: "test-optimized"
match-path: "test/invariant/**/*.sol"
match-path: "tests/invariant/**/*.sol"
name: "Invariant tests"

test-fork:
Expand All @@ -72,7 +72,7 @@ jobs:
with:
foundry-fuzz-runs: ${{ fromJSON(inputs.forkFuzzRuns || '1000') }}
foundry-profile: "test-optimized"
match-path: "test/fork/**/*.sol"
match-path: "tests/fork/**/*.sol"
name: "Fork tests"

notify-on-failure:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
foundry-fuzz-runs: 100
foundry-profile: "test-optimized"
fuzz-seed: true
match-path: "test/fork/**/*.sol"
match-path: "tests/fork/**/*.sol"
name: "Fork tests"

test-utils:
needs: ["lint", "build"]
uses: "sablier-labs/reusable-workflows/.github/workflows/forge-test.yml@main"
with:
foundry-profile: "test-optimized"
match-path: "test/utils/**/*.sol"
match-path: "tests/utils/**/*.sol"
name: "Utils tests"

notify-on-failure:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: "sablier-labs/reusable-workflows/.github/workflows/bulloak-check.yml@main"
with:
skip-modifiers: true
tree-path: "test"
tree-path: "tests"

build:
uses: "sablier-labs/reusable-workflows/.github/workflows/forge-build.yml@main"
Expand All @@ -33,7 +33,7 @@ jobs:
with:
foundry-fuzz-runs: 2000
foundry-profile: "test-optimized"
match-path: "test/unit/**/*.sol"
match-path: "tests/unit/**/*.sol"
name: "Unit tests"

test-integration:
Expand All @@ -42,15 +42,15 @@ jobs:
with:
foundry-fuzz-runs: 2000
foundry-profile: "test-optimized"
match-path: "test/integration/**/*.sol"
match-path: "tests/integration/**/*.sol"
name: "Integration tests"

test-invariant:
needs: ["lint", "build"]
uses: "sablier-labs/reusable-workflows/.github/workflows/forge-test.yml@main"
with:
foundry-profile: "test-optimized"
match-path: "test/invariant/**/*.sol"
match-path: "tests/invariant/**/*.sol"
name: "Invariant tests"

test-fork:
Expand All @@ -61,7 +61,7 @@ jobs:
with:
foundry-fuzz-runs: 20
foundry-profile: "test-optimized"
match-path: "test/fork/**/*.sol"
match-path: "tests/fork/**/*.sol"
name: "Fork tests"

coverage:
Expand All @@ -70,4 +70,4 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
uses: "sablier-labs/reusable-workflows/.github/workflows/forge-coverage.yml@main"
with:
match-path: "test/{integration,unit}/**/*.sol"
match-path: "tests/{integration,unit}/**/*.sol"
2 changes: 1 addition & 1 deletion .lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"*.{json,md,svg,yml}": "prettier --write"
"*.sol":
- "bun solhint {benchmark,precompiles,script,src,test}/**/*.sol --fix --noPrompt"
- "bun solhint {benchmark,precompiles,script,src,tests}/**/*.sol --fix --noPrompt"
- "forge fmt"
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ When making a pull request, ensure that:

- The base branch is `staging`.
- All tests pass.
- Fork testing requires environment variables to be set up in the forked repo.
- Concrete tests are generated using Bulloak and the Branching Tree Technique (BTT).
- You can learn more about this on the [Bulloak website](https://bulloak.dev).
- If you modify a test tree, use this command to generate the corresponding test contract that complies with BTT:
`bulloak scaffold -wf /path/to/file.tree`
- Code coverage remains the same or greater.
- All new code adheres to the style guide:
- All lint checks pass.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ docs, as well as these [diagrams](https://docs.sablier.com/contracts/v2/referenc
### Branching Tree Technique

You may notice that some test files are accompanied by `.tree` files. This is called the Branching Tree Technique, and
it is explained in depth [here](https://github.com/sablier-labs/lockup/wiki/Tests#branching-tree-technique).
it is explained in depth [here](https://www.bulloak.dev/).

## Deployments

Expand Down Expand Up @@ -124,6 +124,6 @@ The primary license for Sablier Lockup is the Business Source License 1.1 (`BUSL

- All files in `src/interfaces/` and `src/types` are licensed under `GPL-3.0-or-later`, see
[`LICENSE-GPL.md`](./LICENSE-GPL.md).
- Several files in `src`, `script`, and `test` are licensed under `GPL-3.0-or-later`, see
- Several files in `src`, `script`, and `tests` are licensed under `GPL-3.0-or-later`, see
[`LICENSE-GPL.md`](./LICENSE-GPL.md).
- Many files in `test/` remain unlicensed (as indicated in their SPDX headers).
- Many files in `tests/` remain unlicensed (as indicated in their SPDX headers).
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The scope of the Program is limited to bugs that result in the draining of funds

The Program does NOT cover the following:

- Code located in the [test](./test) or [script](./script) directories.
- Code located in the [tests](./tests) or [script](./script) directories.
- External code in `node_modules`, except for code that is explicitly used by a deployed contract located in the
[src](./src) directory.
- Contract deployments on test networks, such as Sepolia.
Expand Down
6 changes: 3 additions & 3 deletions benchmark/BatchLockup.Gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pragma solidity >=0.8.22;

import { ud2x18 } from "@prb/math/src/UD2x18.sol";

import { Lockup, LockupDynamic, LockupTranched } from "../src//types/DataTypes.sol";
import { BatchLockup } from "../src//types/DataTypes.sol";
import { BatchLockupBuilder } from "../test/utils/BatchLockupBuilder.sol";
import { Lockup, LockupDynamic, LockupTranched } from "../src/types/DataTypes.sol";
import { BatchLockup } from "../src/types/DataTypes.sol";
import { BatchLockupBuilder } from "../tests/utils/BatchLockupBuilder.sol";

import { Benchmark_Test } from "./Benchmark.t.sol";

Expand Down
2 changes: 1 addition & 1 deletion benchmark/Benchmark.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.22;

import { UD60x18, ud } from "@prb/math/src/UD60x18.sol";

import { Base_Test } from "../test/Base.t.sol";
import { Base_Test } from "../tests/Base.t.sol";

/// @notice Benchmark contract with common logic needed by all tests.
abstract contract Benchmark_Test is Base_Test {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/LockupDynamic.Gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.8.22;
import { ud2x18 } from "@prb/math/src/UD2x18.sol";
import { UD60x18, ud } from "@prb/math/src/UD60x18.sol";

import { Lockup, LockupDynamic } from "../src//types/DataTypes.sol";
import { Lockup, LockupDynamic } from "../src/types/DataTypes.sol";

import { Benchmark_Test } from "./Benchmark.t.sol";

Expand Down
2 changes: 1 addition & 1 deletion benchmark/LockupLinear.Gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.22;

import { ud } from "@prb/math/src/UD60x18.sol";

import { Lockup, LockupLinear } from "../src//types/DataTypes.sol";
import { Lockup, LockupLinear } from "../src/types/DataTypes.sol";

import { Benchmark_Test } from "./Benchmark.t.sol";

Expand Down
2 changes: 1 addition & 1 deletion benchmark/LockupTranched.Gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.22;

import { UD60x18, ud } from "@prb/math/src/UD60x18.sol";

import { Lockup, LockupTranched } from "../src//types/DataTypes.sol";
import { Lockup, LockupTranched } from "../src/types/DataTypes.sol";

import { Benchmark_Test } from "./Benchmark.t.sol";

Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ignore:
- "script"
- "src/libraries/NFTSVG.sol"
- "src/libraries/SVGElements.sol"
- "test"
- "tests"
6 changes: 3 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
sender = "0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38"
solc = "0.8.26"
src = "src"
test = "test"
test = "tests"

[profile.default.fuzz]
max_test_rejects = 1_000_000 # Number of times `vm.assume` can fail
Expand Down Expand Up @@ -45,7 +45,7 @@
"src/libraries/VestingMath.sol:VestingMath:0x26F9d826BDed47Fc472526aE8095B75ac336963C"
]
out = "out-optimized"
test = "test/mocks"
test = "tests/mocks"
via_ir = true


Expand Down Expand Up @@ -81,7 +81,7 @@

# Test the optimized contracts without re-compiling them
[profile.test-optimized]
src = "test"
src = "tests"

[doc]
ignore = ["**/*.t.sol"]
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"artifacts",
"precompiles",
"src",
"test/utils",
"tests/utils",
"CHANGELOG.md",
"LICENSE-GPL.md"
],
Expand Down Expand Up @@ -69,8 +69,8 @@
"clean": "rm -rf artifacts broadcast cache docs out out-optimized out-svg",
"lint": "bun run lint:sol && bun run prettier:check",
"lint:fix": "bun run lint:sol:fix && forge fmt",
"lint:sol": "forge fmt --check && bun solhint \"{benchmark,precompiles,script,src,test}/**/*.sol\"",
"lint:sol:fix": "bun solhint \"{benchmark,precompiles,script,src,test}/**/*.sol\" --fix --noPrompt",
"lint:sol": "forge fmt --check && bun solhint \"{benchmark,precompiles,script,src,tests}/**/*.sol\"",
"lint:sol:fix": "bun solhint \"{benchmark,precompiles,script,src,tests}/**/*.sol\" --fix --noPrompt",
"prepack": "bun install && bash ./shell/prepare-artifacts.sh",
"prepare": "husky",
"prettier:check": "prettier --check \"**/*.{json,md,svg,yml}\"",
Expand Down
2 changes: 1 addition & 1 deletion slither.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"detectors_to_exclude": "naming-convention,reentrancy-events,solc-version,timestamp",
"filter_paths": "(node_modules/,test/)",
"filter_paths": "(node_modules/,tests/)",
"solc_remaps": [
"@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
"@prb/math/=node_modules/@prb-math/",
Expand Down
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { console2 } from "forge-std/src/console2.sol";
import { StdStyle } from "forge-std/src/StdStyle.sol";
import { Base64 } from "solady/src/utils/Base64.sol";

import { Integration_Test } from "test/integration/Integration.t.sol";
import { Integration_Test } from "tests/integration/Integration.t.sol";

/// @dev Requirements for these tests to work:
/// - The stream ID must be 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.22 <0.9.0;

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract GenerateAccentColor_Integration_Concrete_Test is Base_Test {
function test_GenerateAccentColor() external view {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.22 <0.9.0;

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract IsAllowedCharacter_Integration_Concrete_Test is Base_Test {
function test_WhenEmptyString() external view {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MockERC721 } from "forge-std/src/mocks/MockERC721.sol";

import { Errors } from "src/libraries/Errors.sol";

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract MapSymbol_Integration_Concrete_Test is Base_Test {
function test_RevertGiven_UnknownNFTContract() external {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.22 <0.9.0;

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract SafeAssetDecimals_Integration_Concrete_Test is Base_Test {
function test_WhenAssetNotContract() external view {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.22 <0.9.0;

import { Base_Test } from "test/Base.t.sol";
import { ERC20Bytes32 } from "test/mocks/erc20/ERC20Bytes32.sol";
import { ERC20Mock } from "test/mocks/erc20/ERC20Mock.sol";
import { Base_Test } from "tests/Base.t.sol";
import { ERC20Bytes32 } from "tests/mocks/erc20/ERC20Bytes32.sol";
import { ERC20Mock } from "tests/mocks/erc20/ERC20Mock.sol";

contract SafeAssetSymbol_Integration_Concrete_Test is Base_Test {
function test_WhenAssetNotContract() external view {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.22 <0.9.0;

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract IsAllowedCharacter_Integration_Fuzz_Test is Base_Test {
bytes1 internal constant SPACE = 0x20; // ASCII 32
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ISablierLockup } from "src/interfaces/ISablierLockup.sol";
import { Lockup, LockupDynamic, LockupLinear, LockupTranched } from "src/types/DataTypes.sol";

import { Calculations } from "test/utils/Calculations.sol";
import { Calculations } from "tests/utils/Calculations.sol";
import { LockupStore } from "../stores/LockupStore.sol";
import { BaseHandler } from "./BaseHandler.sol";

Expand Down
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.22 <0.9.0;

import { SVGElements } from "src/libraries/SVGElements.sol";

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract AbbreviateAmount_Unit_Concrete_Test is Base_Test {
function aa(uint256 amount, uint256 decimals) internal view returns (string memory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.22 <0.9.0;

import { SVGElements } from "src/libraries/SVGElements.sol";

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract CalculateDurationInDays_Unit_Concrete_Test is Base_Test {
function test_CalculateDurationInDays_Zero() external view {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.22 <0.9.0;

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract CalculatePixelWidth_Unit_Concrete_Test is Base_Test {
uint256 internal constant CHAR_WIDTH_LARGE = 16;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.22 <0.9.0;

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract CalculateStreamedPercentage_Unit_Concrete_Test is Base_Test {
function test_CalculateStreamedPercentage_Zero() external view {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// solhint-disable max-line-length,quotes
pragma solidity >=0.8.22 <0.9.0;

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract GenerateAttributes_Unit_Concrete_Test is Base_Test {
function test_GenerateAttributes_Empty() external view {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// solhint-disable max-line-length,quotes
pragma solidity >=0.8.22 <0.9.0;

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract GenerateDescription_Unit_Concrete_Test is Base_Test {
string internal constant INFO_NON_TRANSFERABLE =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.22 <0.9.0;

import { Base_Test } from "test/Base.t.sol";
import { Base_Test } from "tests/Base.t.sol";

contract GenerateName_Unit_Concrete_Test is Base_Test {
function gn(string memory lockupModel, string memory streamId) internal view returns (string memory) {
Expand Down
Loading

0 comments on commit 44c43a7

Please sign in to comment.