confio / tfi

Contracts for Regulated DeFi on the Tgrade blockchain
Apache License 2.0
9 stars 0 forks source link

Add full stack whitelist AMM test #9

Closed ethanfrey closed 3 years ago

ethanfrey commented 3 years ago

In tests, create 4 contracts using multitest:

Actions:

hashedone commented 3 years ago

It looks like four separated tests cases too me:

Testing all scenario in single test makes big blob which is difficult to follow, and in case of failure it is slightly more difficult to find a reason. Splitting test to test well defined path is often better (it is also just single responsibility rule mapped to the QA world).

ethanfrey commented 3 years ago

Yes, 4 different tests make sense when you have this nice suite setup.

Full stack success tests (everyone is in cw4-group, so everyone can swap and provide liquidity)

Yes

Failure test where if tfi-pair is not in a group, noone can provide liquidity to it or trade (best way would be to initially make it belong to group, so it is possible to provide some initial liquidity to it, so it is clear it is not a reason)

tfi-pair doesn't have a group. the asset in it is a dso token and in a group. we can have it part of a group that has one member, that can fill liquidity. but all other users are not in the group and no one can do anything with it.

Failure test where if token itself is not in a group, noone can interact with it

I think this is already tested in dso-token code. you can improve those for sure.

Failure test where addresses from outside group cannot interact

Yes

ethanfrey commented 3 years ago

Clarifying something about tokens. There are three tokens we want to test.

For the suite, I would imagine setting something up which is cw20 to cw20. It takes group_a: Option<Addr> and group_b: Option<Addr>. If they are none, instantiate a cw20-base for that side. If it is some, instantiate dso-token for that side.

I would make a different suite setup that is only cw20-cw20 so the interfaces match and just a slightly different setup.

ethanfrey commented 3 years ago

The cases for me are:

"can swap" and "can provide liquidity" can both be tested, they have the same controls