Skip to content

Commit

Permalink
Update docs: forge build specific paths and afterInvariant hook (#1222)
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy authored Jun 18, 2024
1 parent 247dbec commit d8f860f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/forge/invariant-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ These and other invariant configuration aspects are explained [`here`](#configur

Similar to how standard tests are run in Foundry by prefixing a function name with `test`, invariant tests are denoted by prefixing the function name with `invariant` (e.g., `function invariant_A()`).

`afterInvariant()` function is called at the end of each invariant run (if declared), allowing post campaign processing. This function can be used for logging campaign metrics (e.g. how many times a selector was called) and post fuzz campaign testing (e.g. close out all positions and assert all funds are able to exit the system).

### Configuring invariant test execution

Invariant tests execution is governed by parameters that can be controlled by users via Forge configuration primitives. Configs can be applied globally or on a per-test basis. For details on this topic please refer to
Expand Down
9 changes: 9 additions & 0 deletions src/reference/forge/forge-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ it will download it and install it in `~/.svm`. You can disable this behavior by
The build is incremental, and the build cache is saved in `cache/` in the project root by default. If you
want to clear the cache, pass `--force`, and if you want to change the cache directory, pass `--cache-path <PATH>`.

It is possible to choose sources to build by specifying multiple path options (can be paths to source directories or files).

#### Build Modes

There are three build modes:
Expand Down Expand Up @@ -183,6 +185,8 @@ The model checker will run when `forge build` is invoked, and will show findings
`--skip`
&nbsp;&nbsp;&nbsp;&nbsp;Skip compilation of non-essential contract directories like test or script (usage `--skip test`).

`[PATHS]...`&nbsp;&nbsp;&nbsp;&nbsp;Build source files from specified paths.

{{#include core-build-options.md}}

{{#include watch-options.md}}
Expand Down Expand Up @@ -211,6 +215,11 @@ The model checker will run when `forge build` is invoked, and will show findings
forge build --watch
```

5. Build source files from `test/invariant` directory and `test/RegressionTest.sol`:
```sh
forge build test/invariant test/RegressionTest.sol
```

### SEE ALSO

[forge](./forge.md), [forge clean](./forge-clean.md), [forge inspect](./forge-inspect.md)
Expand Down

0 comments on commit d8f860f

Please sign in to comment.