Ante
Ante v0.5
Ante v0.5
  • Welcome to Ante v0.5
  • How Ante works
  • Why use Ante?
    • How is Ante different?
    • What does Ante cost to use?
  • What's in Ante v0.5?
  • Using the Ante App
    • Navigating Ante
    • How to Stake
    • How to Challenge & Check Tests
    • The Decentralized Trust Score
      • Decentralized Trust Tiers
    • Deposit Limits
  • For Developers
    • Writing an Ante Test
      • Coming up with an invariant
      • Explaining IAnteTest.sol and AnteTest.sol
      • Ante Test Examples
      • Writing and Testing an Ante Test
      • Test an Ante Test Offline
      • Adding an Ante Test to Ante Github
      • Development FAQs
    • Integrating Ante
      • Integrate Ante using React
      • Integrate Ante using HTML
    • Deploying an Ante Test
      • Deploy an Ante Test
      • Create an Ante Pool
      • Verifying an Ante Pool
    • Contracts
  • About Ante
    • FAQs
    • Glossary
    • Security
    • Possible Future Work
    • Changelog
    • Terms of Service
Powered by GitBook
On this page
  • 1. Think of the invariant you want to test
  • 2. Fork the Ante community test repository
  • 3. Write your Ante Test
  • 4. Create a pull request to the Ante community test repository
  1. For Developers

Writing an Ante Test

Four steps to writing your first Ante Test

PreviousDeposit LimitsNextComing up with an invariant

Last updated 3 years ago

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.

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!

2. Fork the Ante community test repository

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.

3. Write your Ante Test

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:

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
    }
}

4. Create a pull request to the Ante community test repository

  1. Click Pull request on the repository page.

  2. Select the base and head branches you want to merge

  3. 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.

On the page, click Fork to create a copy of the repository under your GitHub profile.

Once you've forked the repository, you can to your local machine.

It's time to open up your favorite /text editor and start coding!

If you're comfortable deploying your own smart contracts, you can .

If you don't want to go through the hassle of deploying the test yourself, though, you can to the ante community test repository:

Coming up with an invariant
repository
clone the repository
IDE
Explaining IAnteTest.sol and AnteTest.sol
do it yourself
open a pull request
Is this the face of a liar? I think not.