-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* setup * deprecated random contract calls * bump version * fixed version * remove version restriction
- Loading branch information
Showing
11 changed files
with
164 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,56 @@ | ||
### Building | ||
|
||
## Naming Convention | ||
You can build this project by simply running | ||
|
||
Our tests generally follow the Foundry Book best [practices](https://book.getfoundry.sh/tutorials/best-practices#general-test-guidance), however, a few notable exepctions are enforced: | ||
```bash | ||
forge build | ||
``` | ||
|
||
1. Naming of contracts. Contract names for test are called `ContractTest_functionToTest_[When|After]`. In case necesary, a contract with setUp `ContractTest` and basic general test are created. Most other contracts are expected to inherit from this. | ||
2. Function naming. | ||
1. In case of a emit expected `test_Emits_EventName_[When|After]` | ||
2. In case of a revert expected `test_Reverts_EventName_[When|After]` | ||
### Testing | ||
|
||
We are in the process of migrating our tests to use [Foundry](https://book.getfoundry.sh/). The tests in this folder have already been migrated from [Truffle](../test). | ||
|
||
To run tests with Foundry there's no need to `yarn` or manage any Javascript dependencies. Instead, run | ||
|
||
```bash | ||
forge test | ||
``` | ||
|
||
This will run all tests in this folder. To run only a specific file you can use | ||
|
||
```bash | ||
forge test --match-path ./path/to/file.t.sol | ||
``` | ||
|
||
To run only a specific contract in a test file, you can use | ||
|
||
```bash | ||
forge test --match-contract CONTRACT_NAME | ||
``` | ||
|
||
To run only a specific test, you can use | ||
|
||
```bash | ||
forge test --match-test test_ToMatch | ||
``` | ||
|
||
You can specify a verbosity level with the `-v`, `-vv`, `-vvv`, and `-vvvv` flags. The more `v`s you put the more verbose the output will be. | ||
|
||
Putting it all together, you might run something like | ||
|
||
```bash | ||
forge test --match-path ./path/to/file.t.sol --match-test test_ToMatch -vvv | ||
``` | ||
|
||
You can read more about the `forge test` command [here](https://book.getfoundry.sh/reference/forge/forge-test). | ||
|
||
To skip a specific test, you can add `vm.skip(true);` as the first line of the test. | ||
|
||
If a test name begins with `testFail` rather than `test`, foundry will expect the test to fail / revert. | ||
|
||
Please follow the naming convention `test_NameOfTest` / `testFail_NameOfTest`. | ||
|
||
If you're new to Forge / Foundry, we recommend looking through the [Cheatcode Reference](https://book.getfoundry.sh/cheatcodes/) for a list of useful commands that make writing tests easier. | ||
|
||
|
||
Generally, words as "should" are expected to be omitted. The world `If` is generally not used in favor of `When`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.