Writing an Ante Test
Four steps to writing your first Ante Test
Last updated
Four steps to writing your first Ante Test
Last updated
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.
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.
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 class AnteTest.sol
that any Ante Test can inherit.
You can start by copying another Ante Test in the repository, or you can use the following skeleton code:
If you're comfortable deploying your own smart contracts, you can do it yourself.
If you don't want to go through the hassle of deploying the test yourself, though, you can open a pull request to the ante community test repository:
Click Pull request on the repository page.
Select the base and head branches you want to merge
Add a quick description, and click Create Pull Request.
That's it! A member of the Ante team will review your test and add it to the main community repository.