Test cases for Curve pools.
- Tests are organized according to the specific pool, and then split between integration and unitary tests.
- Common tests for all pools are located in
tests/common
. - Valid pool names are the names of the subdirectories within
contracts/pools
.
To run the entire suite:
brownie test
To run tests on a specific pool:
pytest tests --pool <POOL NAME>
You can optionally include the --coverage
flag to view a coverage report upon completion of the tests.
Fixtures are parametrized to work with every pool in contracts/pools
. To add a new pool to the test suite, create a pooldata.json
in the same subdirectory. You can read about the structure of this JSON file here.
Some commonly used fixtures:
A deployed StableSwap
contract for the pool being tested.
A deployed CurveToken
contract representing the LP token for the active pool.
A list of deployed ERC20 contracts representing the lent-out coins in the active pool. If the pool does not support lending, these will be the same as the underlying contracts.
A list of deployed ERC20 contracts representing the underlying coins in the active pool.
We use the following custom markers to parametrize common tests across different pools:
Exclude one or more pools from the given test.
@pytest.mark.skip_pool("compound", "usdt", "y")
def test_only_some_pools(swap):
...
Only run the given test against one or more pools specified in the marker.
@pytest.mark.target_pool("ren", "sbtc")
def test_btc_pools(swap):
...
Parametrizes each of the given arguments with a range of numbers equal to the total number of coins for the given pool. When multiple arguments are given, each argument has a unique value for every generated test.
For example, itercoins("send", "recv")
with a pool of 3 coins will parametrize with the sequence [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]
.
@pytest.mark.itercoins("send", "recv"):
def test_swap(accounts, swap, send, recv):
swap.exchange(send, recv, 0, 0, {'from': accounts[0]})