ubiquity-dollar icon indicating copy to clipboard operation
ubiquity-dollar copied to clipboard

Invariant Testing

Open 0x4007 opened this issue 2 years ago • 19 comments

We should implement invariant testing for LibUbiquityPool.

So collaborator who's going to take this issue should carefully study the LibUbiquityPool and think of the invariants that should be tested.

Invariants could be:

  • user can not mint more Dollars in USD than provided collateral
  • user can not redeem more collateral in USD than provided Dollar tokens
  • https://github.com/ubiquity/ubiquity-dollar/issues/925#issuecomment-2128859442

Possible solutions for invariant testing (I would simply start with foundry since we're using it as a development framework + it also contains fuzz testing):

  • https://book.getfoundry.sh/forge/invariant-testing
  • https://github.com/crytic/echidna
  • https://github.com/crytic/medusa

What should be done:

  1. Impelent invariant tests for the LibUbiquityPool contract (you may create them in a separate test file like UbiquityPoolFacet.invariant.t.sol so we could distinguish unit, fuzz and invariant tests)
  2. Setup testing CI this way: a) On PR invariant tests should run with a small number of runs (so that we could merge PRs fast) b) On merge to the development branch invariant tests should run with a great number of runs to test many cases (keep in mind that github action runnners can run for 6 hours)

Original description:

Determine if this is beneficial for us:

https://twitter.com/PaulRBerg/status/1624014054254690304
https://github.com/foundry-rs/book/pull/760

---

https://twitter.com/gakonst/status/1624146214412521483?s=46&t=gH3q4dow54h4x7JQWCQSeg

0x4007 avatar Feb 10 '23 14:02 0x4007