ERCx Test suites

What's being tested in ERCx

Details of the test levels

ERCx runs property tests. The properties and the corresponding tests are described in the tables below. Each test has its own row, indicating the conformance level of that test (ABI, Minimal, Recommended, and Desirable) the name of that test (as displayed in the report) and an informal description of the property being tested. Test levels are understood as follows.

  • Tests of level ABI (Signature) check the signatures (i.e., name, inputs, and outputs) of the token functions/events.

  • Tests of level Standard check obligations and recommendations from the standard, i.e., the properties that contain the keywords MUST and SHOULD respectively, but also any property stated in the respective EIP specification.

  • Tests of level Security check properties we deem important to the sane functioning of a token and complement the standard specification. Some of these properties were violated in ERC-20 hacks. Some othesr consider additional functions not in the standard. Examples of security properties include (i) self-transferring tokens is allowed but must not modify the balance (ii) increase of allowance should rely on an increaseAllowance function.

  • Tests of level Features check feature properties of the contract; these are neither desirable nor undesirable properties but indicate implementation choices of the contract. Examples of fingerprint properties include the infinite approval property; which holds if once the approval is set to type(uint256).max, it is not decreased by transferFrom operations.

Outcomes of test results

  • Pass: The token has passed the check as stated in the property description.

  • Fail: The token has failed the check as stated in the property description. To know more about the possible reason/s of the failed test, you can simply click on the failed test's feedback description and find out more from the json output displayed. Fields such as reason, decoded_logs could provide more insights to why the test failed. Some possible reasons that you could see are:

    • stdStorage find(StdStorage): Slot(s) not found. - There are some inaccessibility issues with the storage slots of the token and as a result, we are unable to initialize tokens to the intended dummy users.

    • EvmError: Revert - Some functions reverted when called during the execution of the test suite.

    • Any other reasons, e.g., Error: Assertion Failed - The token indeed does not satisfy all these properties OR there are some issues with the token's transfer or minting function which result in insufficient tokens to test the intended property.

    However, if the test failed unexpectedly, i.e., false negative, please contact us so that we can resolve the issue ASAP.

  • Inconclusive: A test is inconclusive if EITHER (a) it is an ABI test of an optional function OR (b) its result is inconclusive as certain conditions are not met while testing the said property test. Some possible reasons for a test to be inconclusive are failure to deal tokens to dummy users before running the test and failure to call the required function before making the property check especially in cases where large values of inputs are used in the test. Note that inconclusive tests from non-ABI levels are still important property tests that a token should satisfy. Thus, it is essential to manually check whether the token satisfies those properties. If the reason The 'vm.assume' cheatcode rejected too many inputs (65536 allowed) is shown in the reason field, then the test is considered as inconclusive as the test suite cannot generate sufficient appropriate inputs required to satisfy the assumptions in the test.

Specifications of property tests

In the below description of properties, we use the following terminology:

  • tokenSender: address that sends tokens (usually in a transaction);

  • tokenReceiver: address that receives tokens (usually in a transaction);

  • tokenApprover: address that approves tokens (usually in an approval);

  • tokenApprovee: address that tokenApprover approves (usually in an approval).

ERC-20 test suite

PROPERTY
TEST NAME

The allowance(address,address) function conforms to the EIP-20 standard.

testAllowanceAbi

The allowance(address,address) function is present in the contract.

testAllowanceSignature

The Approval(address,address,uint256) event is present in the contract.

testApprovalEventSignature

The approve(address,uint256) function conforms to the EIP-20 standard.

testApproveAbi

The approve(address,uint256) function is present in the contract.

testApproveSignature

The balanceOf(address) function conforms to the EIP-20 standard.

testBalanceOfAbi

The balanceOf(address) function is present in the contract.

testBalanceOfSignature

The decimals() function conforms to the EIP-20 standard.

testDecimalsAbi

The decimals() function is present in the contract.

testDecimalsSignature

The name() function conforms to the EIP-20 standard.

testNameAbi

The name() function is present in the contract.

testNameSignature

The symbol() function conforms to the EIP-20 standard.

testSymbolAbi

The symbol() function is present in the contract.

testSymbolSignature

The totalSupply() function conforms to the EIP-20 standard.

testTotalSupplyAbi

The totalSupply() function is present in the contract.

testTotalSupplySignature

The transfer(address,uint256) function conforms to the EIP-20 standard.

testTransferAbi

The Transfer(address,address,uint256) event is present in the contract.

testTransferEventSignature

The transferFrom(address,address,uint256) function conforms to the EIP-20 standard.

testTransferFromAbi

The transferFrom(address,address,uint256) function is present in the contract.

testTransferFromSignature

The transfer(address,uint256) function is present in the contract.

testTransferSignature

The increaseAllowance(address,uint256) function is present in the contract.

testIncreaseAllowanceSignature

The increaseAllowance(address,uint256) function conforms to the EIP-20 standard.

testIncreaseAllowanceAbi

The decreaseAllowance(address,uint256) function is present in the contract.

testDecreaseAllowanceSignature

The decreaseAllowance(address,uint256) function conforms to the EIP-20 standard.

testDecreaseAllowanceAbi

The pause() function is present in the contract.

testPauseSignature

The pause() function conforms to the EIP-20 standard.

testPauseAbi

The burn(uint256) function is present in the contract.

testBurnUint256Signature

The burn(uint256) function conforms to the EIP-20 standard.

testBurnUint256Abi

The burnToken(uint256) function is present in the contract.

testBurnTokenUint256Signature

The burnToken(uint256) function conforms to the EIP-20 standard.

testBurnTokenUint256Abi

The burn(address,uint256) function is present in the contract.

testBurnAddressUint256Signature

The burn(address,uint256) function conforms to the EIP-20 standard.

testBurnAddressUint256Abi

The burnToken(address,uint256) function is present in the contract.

testBurnTokenAddressUint256Signature

The burnToken(address,uint256) function conforms to the EIP-20 standard.

testBurnTokenAddressUint256Abi

The burnFrom(address,uint256) function is present in the contract.

testBurnFromAddressUint256Signature

The burnFrom(address,uint256) function conforms to the EIP-20 standard.

testBurnFromAddressUint256Abi

The mint(address,uint256) function is present in the contract.

testMintSignature

The mint(address,uint256) function conforms to the EIP-20 standard.

testMintAbi

The mintToken(address,uint256) function is present in the contract.

testMintTokenSignature

The mintToken(address,uint256) function conforms to the EIP-20 standard.

testMintTokenAbi

The issue(address,uint256) function is present in the contract.

testIssueSignature

The issue(address,uint256) function conforms to the EIP-20 standard.

testIssueAbi

The enableTokenTransfer() function is present in the contract.

testEnableTokenTransferSignature

The enableTokenTransfer() function conforms to the EIP-20 standard.

testEnableTokenTransferAbi

The disableTokenTransfer() function is present in the contract.

testDisableTokenTransferSignature

The disableTokenTransfer() function conforms to the EIP-20 standard.

testDisableTokenTransferAbi

The owned() function is present in the contract.

testOwnedSignature

The owned() function conforms to the EIP-20 standard.

testOwnedAbi

The setOwner(address) function is present in the contract.

testSetOwnerSignature

The setOwner(address) function conforms to the EIP-20 standard.

testSetOwnerAbi

The batchTransfer(address[],uint256) function is present in the contract.

testBatchTransferSignature

The batchTransfer(address[],uint256) function conforms to the EIP-20 standard.

testBatchTransferAbi

The sell(uint256) function is present in the contract.

testSellSignature

The sell(uint256) function conforms to the EIP-20 standard.

testSellAbi

The setPrices(uint256,uint256) function is present in the contract.

testSetPricesSignature

The setPrices(uint256,uint256) function conforms to the EIP-20 standard.

testSetPricesAbi

ERC-721 test suite

PROPERTY
TEST NAME

The balanceOf(address) function is present in the contract.

testBalanceOfSignature

The balanceOf(address) function conforms to the EIP-721 standard.

testBalanceOfAbi

The ownerOf(uint256) function is present in the contract.

testOwnerOfSignature

The ownerOf(uint256) function conforms to the EIP-721 standard.

testOwnerOfAbi

The safeTransferFrom(address,address,uint256,bytes) function is present in the contract.

testSafeTransferFrom4Signature

The safeTransferFrom(address,address,uint256,bytes) function conforms to the EIP-721 standard.

testSafeTransferFrom4Abi

The safeTransferFrom(address,address,uint256) function is present in the contract.

testSafeTransferFrom3Signature

The safeTransferFrom(address,address,uint256) function conforms to the EIP-721 standard.

testSafeTransferFrom3Abi

The transferFrom(address,address,uint256) function is present in the contract.

testTransferFromPayableSignature

The transferFrom(address,address,uint256) function conforms to the EIP-721 standard.

testTransferFromPayableAbi

The approve(address,uint256) function is present in the contract.

testApprovePayableSignature

The approve(address,uint256) function conforms to the EIP-721 standard.

testApprovePayableAbi

The setApprovalForAll(address,bool) function is present in the contract.

testSetApprovalForAllSignature

The setApprovalForAll(address,bool) function conforms to the EIP-721 standard.

testSetApprovalForAllAbi

The getApproved(uint256) function is present in the contract.

testGetApprovedSignature

The getApproved(uint256) function conforms to the EIP-721 standard.

testGetApprovedAbi

The isApprovedForAll(address,address) function is present in the contract.

testIsApprovedForAllSignature

The isApprovedForAll(address,address) function conforms to the EIP-721 standard.

testIsApprovedForAllAbi

The name() function is present in the contract.

testNameSignature

The name() function conforms to the EIP-721 standard.

testNameAbi

The symbol() function is present in the contract.

testSymbolSignature

The symbol() function conforms to the EIP-721 standard.

testSymbolAbi

The tokenURI(uint256) function is present in the contract.

testTokenURISignature

The tokenURI(uint256) function conforms to the EIP-721 standard.

testTokenURIAbi

The totalSupply() function is present in the contract.

testTotalSupplySignature

The totalSupply() function conforms to the EIP-721 standard.

testTotalSupplyAbi

The tokenByIndex(uint256) function is present in the contract.

testTokenByIndexSignature

The tokenByIndex(uint256) function conforms to the EIP-721 standard.

testTokenByIndexAbi

The tokenOfOwnerByIndex(address,uint256) function is present in the contract.

testTokenOfOwnerByIndexSignature

The tokenOfOwnerByIndex(address,uint256) function conforms to the EIP-721 standard.

testTokenOfOwnerByIndexAbi

The Transfer(address,address,uint256) event is present in the contract.

testTransferEventSignature

The Approval(address,address,bool) event is present in the contract.

testApprovalEventSignature

The ApprovalForAll(address,address,bool) event is present in the contract.

testApprovalForAllEventSignature

The supportsInterface(bytes4) function is present in the contract.

testSupportsInterfaceSignature

The supportsInterface(bytes4) function conforms to the EIP-721 standard.

testSupportsInterfaceAbi

ERC-1155 test suite

PROPERTY
TEST NAME

The safeTransferFrom(address,address,uint256,uint256,bytes) function is present in the contract.

testSafeTransferFrom5Signature

The safeTransferFrom(address,address,uint256,uint256,bytes) function conforms to the EIP-1155 standard.

testSafeTransferFrom5Abi

The safeBatchTransferFrom(address,address,uint256[],uint256[],bytes) function is present in the contract.

testSafeBatchTransferFromSignature

The safeBatchTransferFrom(address,address,uint256[],uint256[],bytes) function conforms to the EIP-1155 standard.

testSafeBatchTransferFromAbi

The balanceOf(address,uint256) function is present in the contract.

testBalanceOf2Signature

The balanceOf(address,uint256) function conforms to the EIP-1155 standard.

testBalanceOf2Abi

The balanceOfBatch(address[],uint256[]) function is present in the contract.

testBalanceOfBatchSignature

The balanceOfBatch(address[],uint256[]) function conforms to the EIP-1155 standard.

testBalanceOfBatchAbi

The setApprovalForAll(address,bool) function is present in the contract.

testSetApprovalForAllSignature

The setApprovalForAll(address,bool) function conforms to the EIP-1155 standard.

testSetApprovalForAllAbi

The isApprovedForAll(address,address) function is present in the contract.

testIsApprovedForAllSignature

The isApprovedForAll(address,address) function conforms to the EIP-1155 standard.

testIsApprovedForAllAbi

The uri(uint256) function is present in the contract.

testUriSignature

The uri(uint256) function conforms to the EIP-1155 standard.

testUriAbi

The supportsInterface(bytes4) function is present in the contract.

testSupportsInterfaceSignature

The supportsInterface(bytes4) function conforms to the EIP-1155 standard.

testSupportsInterfaceAbi

The TransferSingle(address,address,address,uint256,uint256) function is present in the contract.

testTransferSingleEventSignature

The TransferBatch(address,address,address,uint256[],uint256[]) function is present in the contract.

testTransferBatchEventSignature

The ApprovalForAll(address,address,bool) function is present in the contract.

testApprovalForAllEventSignature

The URI(string,uint256) function is present in the contract.

testURIEventSignature

ERC-4626 test suite

PROPERTY
TEST NAME

The asset() function conforms to the EIP-4626 standard.

testAssetAbi

The asset() function is present in the contract.

testAssetSignature

The convertToAssets(uint256) function conforms to the EIP-4626 standard.

testConvertToAssetsAbi

The convertToAssets(uint256) function is present in the contract.

testConvertToAssetsSignature

The convertToShares(uint256) function conforms to the EIP-4626 standard.

testConvertToSharesAbi

The convertToShares(uint256) function is present in the contract.

testConvertToSharesSignature

The deposit(uint256,address) function conforms to the EIP-4626 standard.

testDepositAbi

The Deposit(address,address,uint256,uint256) event is present in the contract.

testDepositEventSignature

The deposit(uint256,address) function is present in the contract.

testDepositSignature

The maxDeposit(address) function conforms to the EIP-4626 standard.

testMaxDepositAbi

The maxDeposit(address) function is present in the contract.

testMaxDepositSignature

The maxMint(address) function conforms to the EIP-4626 standard.

testMaxMintAbi

The maxMint(address) function is present in the contract.

testMaxMintSignature

The maxRedeem(address) function conforms to the EIP-4626 standard.

testMaxRedeemAbi

The maxRedeem(address) function is present in the contract.

testMaxRedeemSignature

The maxWithdraw(address) function conforms to the EIP-4626 standard.

testMaxWithdrawAbi

The maxWithdraw(address) function is present in the contract.

testMaxWithdrawSignature

The mint(uint256,address) function conforms to the EIP-4626 standard.

testMintAbi

The mint(uint256,address) function is present in the contract.

testMintSignature

The previewDeposit(uint256) function conforms to the EIP-4626 standard.

testPreviewDepositAbi

The previewDeposit(uint256) function is present in the contract.

testPreviewDepositSignature

The previewMint(uint256) function conforms to the EIP-4626 standard.

testPreviewMintAbi

The previewMint(uint256) function is present in the contract.

testPreviewMintSignature

The previewRedeem(uint256) function conforms to the EIP-4626 standard.

testPreviewRedeemAbi

The previewRedeem(uint256) function is present in the contract.

testPreviewRedeemSignature

The previewWithdraw(uint256) function conforms to the EIP-4626 standard.

testPreviewWithdrawAbi

The previewWithdraw(uint256) function is present in the contract.

testPreviewWithdrawSignature

The redeem(uint256,address,address) function conforms to the EIP-4626 standard.

testRedeemAbi

The redeem(uint256,address,address) function signature is present in the contract.

testRedeemSignature

The totalAssets() function conforms to the EIP-4626 standard.

testTotalAssetsAbi

The totalAssets() function is present in the contract.

testTotalAssetsSignature

The withdraw(uint256,address,address) function conforms to the EIP-4626 standard.

testWithdrawAbi

The Withdraw(address,address,address,uint256,uint256) event is present in the contract.

testWithdrawEventSignature

The withdraw(uint256,address,address) function signature is present in the contract.

testWithdrawSignature

For ERC-4626 test suite, there are several tests with the phrase "up todelta-approximation" in their test descriptions. These are the tests where calling of functions such as deposit,withdraw, etc, are being carried out and conversation of shares to assets, and vice-versa, will take place. As math operations in Solidity is done entirely using fixed-point (i.e., no decimal value), rounding errors may occur if the contract does not follow the required rounding rules stated in the EIP-4626 standard. However, in the event where the contract does not follow the required rounding rules, there is a global uint256 variable, delta, for the test suite where the user can set to provide some leeway for such errors. This delta value represents the maximum approximation error size (an absolute value given in the smallest unit such as Wei) whenever equality assertion check is carried out. For example, x - y <= delta is being checked whenever there is a check for x == y. It is important to note that delta should only be set to a reasonable small value so that the adversarial profit of exploiting such rounding errors stays relatively small compared to the gas cost. The default value of delta is set to 0 as all tests are supposed to pass at this value if the contract follows the required rounding rules.

Last updated