Skip to content

Commit

Permalink
readme: invariant testing
Browse files Browse the repository at this point in the history
  • Loading branch information
reednaa committed Dec 6, 2023
1 parent 0e85289 commit a3f86ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion evm/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,10 @@ Contains various mocks used throughout testing.

The majority of testing is for the Catalyst vaults, since this is where the majority of the contract risk exists. To test many different variations of vaults without having to repeat code several times, vault tests (which aren't integration tests) are written such that they can be inherited and the deployment configuration is then provided to the test.

For the simplest example, see *./CatalystVault/LocalSwap.t.sol*. This contract is inherited by *./CatalystVault/Volatile/VolatileLocalSwap.t.sol* where the test is run.
For the simplest example, see *./CatalystVault/LocalSwap/LocalSwap.t.sol*. This contract is inherited by *./CatalystVault/Volatile/VolatileLocalSwap.t.sol* where the test is run.

## Invariant testing

Many tests are implemented as invariant testing with fuzzing. An example of such a test is *./CatalystVault/LocalSwap/LocalSwap.t.sol*

The test *test_local_swap_invariance* is implemented as an fuzz test on the invariant. It collects vaults from the config and then tries various swap values and computes the invariant before and after the swap. If it decreased below a certain margin, then the test fails.

0 comments on commit a3f86ac

Please sign in to comment.