Writing an Ante Test is easy to do! It's also a fantastic way to level up your Solidity skills as you read and think about the workings of the smart contracts that underlie your favorite DeFi protocols. To guide you through the process, we've listed out the basic steps below.
Is this the face of a liar? I think not.
1. Think of the invariant you want to test
Ante Tests are single-failure tests of on-chain protocol invariants. Invariants should reflect fundamental guarantees that a protocol should satisfy. Some examples of invariants you could write an Ante Test for include:
Plunge protection test – Contract assets do not drop below some threshold
Loan solvency test – Collateral asset value exceeds issued liabilities by some factor
APY guarantee test – APY over a given time period exceeds the rate advertised
For more ideas, check out a longer list below. The possibilities are endless!
Forking the antefinance/ante-community-tests repository will allow you to work on your own local copy of the repository that includes all the necessary starter code and other community tests for reference.
On the repository page, click Fork to create a copy of the repository under your GitHub profile.
Once you've forked the repository, you can clone the repository to your local machine.
3. Write your Ante Test
It's time to open up your favorite IDE/text editor and start coding!
All Ante Tests need to implement the IAnteTest.sol interface to work with Ante. To make it easier to work with, we have implemented the abstract classAnteTest.sol that any Ante Test can inherit.
import "@antefinance/contracts/interfaces/AnteTest.sol";
contract MyAnteTest is AnteTest("String descriptor of test") {
// create Ante Test variables & insert logic here
// you can omit your constructor if not defining these optional parameters
constructor () {
protocolName = "My Protocol";
testedContracts = [0x000000000000000000000000000000000000dEaD];
}
function checkTestPasses() public view override returns (bool) {
// insert logic here to check the My Protocol invariant
}
}