Skip to content

Commit

Permalink
docs: rewrite invariant docs in a way compliant with autogen scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
0xteddybear committed Sep 3, 2024
1 parent 827ac0a commit 710e0bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# `OptimismSuperchainERC20` Invariants

## Calls to sendERC20 should always succeed as long as the actor has enough balance. Actor's balance should also not increase out of nowhere but instead should decrease by the amount sent.
**Test:** [`OptimismSuperchainERC20.t.sol#L194`](../test/invariants/OptimismSuperchainERC20.t.sol#L194)
## sum of supertoken total supply across all chains is always <= to convert(legacy, super)- convert(super, legacy)
**Test:** [`OptimismSuperchainERC20#L36`](../test/invariants/OptimismSuperchainERC20#L36)



## Calls to relayERC20 should always succeeds when a message is received from another chain. Actor's balance should only increase by the amount relayed.
**Test:** [`OptimismSuperchainERC20.t.sol#L212`](../test/invariants/OptimismSuperchainERC20.t.sol#L212)
## sum of supertoken total supply across all chains is equal to convert(legacy, super)- convert(super, legacy) when all when all cross-chain messages are processed
**Test:** [`OptimismSuperchainERC20#L57`](../test/invariants/OptimismSuperchainERC20#L57)



## many other assertion mode invariants are also defined under `test/invariants/OptimismSuperchainERC20/fuzz/` . since setting`fail_on_revert=false` also ignores StdAssertion failures, this invariant explicitly asks the handler for assertion test failures
**Test:** [`OptimismSuperchainERC20#L79`](../test/invariants/OptimismSuperchainERC20#L79)

Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ contract OptimismSuperchainERC20Properties is Test {

// TODO: will need rework after
// - `convert`
/// @custom:property-id 19
/// @custom:property sum of supertoken total supply across all chains is always <= to convert(legacy, super)-
/// @custom:invariant sum of supertoken total supply across all chains is always <= to convert(legacy, super)-
/// convert(super, legacy)
function invariant_totalSupplyAcrossChainsEqualsMintsMinusFundsInTransit() external view {
// iterate over unique deploy salts aka supertokens that are supposed to be compatible with each other
Expand All @@ -52,8 +51,7 @@ contract OptimismSuperchainERC20Properties is Test {

// TODO: will need rework after
// - `convert`
/// @custom:property-id 21
/// @custom:property sum of supertoken total supply across all chains is equal to convert(legacy, super)-
/// @custom:invariant sum of supertoken total supply across all chains is equal to convert(legacy, super)-
/// convert(super, legacy) when all when all cross-chain messages are processed
function invariant_totalSupplyAcrossChainsEqualsMintsWhenQueueIsEmpty() external view {
if (MESSENGER.messageQueueLength() != 0) {
Expand All @@ -74,8 +72,9 @@ contract OptimismSuperchainERC20Properties is Test {
}
}

///@notice `fail_on_revert=false` also ignores StdAssertion failures, so we
/// can't simply override compatibleAssert to call StdAssertions.assertTrue
/// @custom:invariant many other assertion mode invariants are also defined under `test/invariants/OptimismSuperchainERC20/fuzz/` .
/// since setting`fail_on_revert=false` also ignores StdAssertion failures, this invariant explicitly asks the
/// handler for assertion test failures
function invariant_handlerAssertions() external view {
assertFalse(handler.failed());
}
Expand Down

0 comments on commit 710e0bf

Please sign in to comment.