Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
alecps committed Jan 23, 2024
1 parent 8719440 commit 2e9f1dd
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ truffle(rc1)> let exchange = await kit.contracts.getExchange()

### Testing

Warning / TODO: We are migrating our tests to Foundry, so this section may be out of date. For instruction on how to run tests with Foundry see [here](./test-sol/README.md).

To test the smart contracts, run:

```bash
Expand Down
48 changes: 48 additions & 0 deletions packages/protocol/test-sol/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
### Building

You can build this project by simply running

```bash
forge build
```

### 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 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.



0 comments on commit 2e9f1dd

Please sign in to comment.