Explaining IAnteTest.sol and AnteTest.sol
Ante Test basics
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.
Interface IAnteTest.sol
IAnteTest.sol// SPDX-License-Identifier: GPL-3.0-only
// ┏━━━┓━━━━━┏┓━━━━━━━━━┏━━━┓━━━━━━━━━━━━━━━━━━━━━━━
// ┃┏━┓┃━━━━┏┛┗┓━━━━━━━━┃┏━━┛━━━━━━━━━━━━━━━━━━━━━━━
// ┃┗━┛┃┏━┓━┗┓┏┛┏━━┓━━━━┃┗━━┓┏┓┏━┓━┏━━┓━┏━┓━┏━━┓┏━━┓
// ┃┏━┓┃┃┏┓┓━┃┃━┃┏┓┃━━━━┃┏━━┛┣┫┃┏┓┓┗━┓┃━┃┏┓┓┃┏━┛┃┏┓┃
// ┃┃ ┃┃┃┃┃┃━┃┗┓┃┃━┫━┏┓━┃┃━━━┃┃┃┃┃┃┃┗┛┗┓┃┃┃┃┃┗━┓┃┃━┫
// ┗┛ ┗┛┗┛┗┛━┗━┛┗━━┛━┗┛━┗┛━━━┗┛┗┛┗┛┗━━━┛┗┛┗┛┗━━┛┗━━┛
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
pragma solidity >=0.7.0;
/// @title The interface for the Ante V0.5 Ante Test
/// @notice The Ante V0.5 Ante Test wraps test logic for verifying fundamental invariants of a protocol
interface IAnteTest {
/// @notice Returns the author of the Ante Test
/// @dev This overrides the auto-generated getter for testAuthor as a public var
/// @return The address of the test author
function testAuthor() external view returns (address);
/// @notice Returns the name of the protocol the Ante Test is testing
/// @dev This overrides the auto-generated getter for protocolName as a public var
/// @return The name of the protocol in string format
function protocolName() external view returns (string memory);
/// @notice Returns a single address in the testedContracts array
/// @dev This overrides the auto-generated getter for testedContracts [] as a public var
/// @param i The array index of the address to return
/// @return The address of the i-th element in the list of tested contracts
function testedContracts(uint256 i) external view returns (address);
/// @notice Returns the name of the Ante Test
/// @dev This overrides the auto-generated getter for testName as a public var
/// @return The name of the Ante Test in string format
function testName() external view returns (string memory);
/// @notice Function containing test logic to inspect the protocol invariant
/// @dev This should usually return True
/// @return A single bool indicating if the Ante Test passes/fails
function checkTestPasses() external returns (bool);
}All Ante Tests must follow the interface outlined in IAnteTest.sol to work with Ante. The interface outlines 5 main components:
testAuthor: this overrides the auto-generated getter and allowstestAuthorto be used as a public variable.testName: this overrides the auto-generated getter and allowstestNameto be used as a public variable.protocolName: this overrides the auto-generated getter and allows the optional parameterprotocolNameto be used as a public variable.testedContracts: this overrides the auto-generated getter for the optional public variabletestedContracts.checkTestPasses(): the critical function that checks your invariant that is expected to returnTrue, else this will indicate a catastrophic failure.
To aid in working with the IAnteTest.sol interface, we've created an AnteTest.sol abstract class that any Ante Test can inherit.
Abstract Class AnteTest.sol
AnteTest.solThe AnteTest.sol is an abstract contract that once inherited, can be used to write any Ante Test. All that is needed to be provided is a name for the test, designated by _testName. The optional parameters protocolName and testedContracts can be set in the constructor of your Ante Test.
To use it, when declaring your Ante Test, you can write:
We'll see in the next section, how to use this abstract contract in some Ante Test examples.
Last updated