From 710e0bf6295548a29e22a484678b9404c348893d Mon Sep 17 00:00:00 2001 From: teddy Date: Tue, 3 Sep 2024 18:22:33 -0300 Subject: [PATCH] docs: rewrite invariant docs in a way compliant with autogen scripts --- .../invariant-docs/OptimismSuperchainERC20.md | 13 +++++++++---- .../OptimismSuperchainERC20.t.sol | 11 +++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/contracts-bedrock/invariant-docs/OptimismSuperchainERC20.md b/packages/contracts-bedrock/invariant-docs/OptimismSuperchainERC20.md index 0e3150624da52..6ce09e917e79c 100644 --- a/packages/contracts-bedrock/invariant-docs/OptimismSuperchainERC20.md +++ b/packages/contracts-bedrock/invariant-docs/OptimismSuperchainERC20.md @@ -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) diff --git a/packages/contracts-bedrock/test/invariants/OptimismSuperchainERC20/OptimismSuperchainERC20.t.sol b/packages/contracts-bedrock/test/invariants/OptimismSuperchainERC20/OptimismSuperchainERC20.t.sol index ee95cb8bbe7bb..648a2f6efd559 100644 --- a/packages/contracts-bedrock/test/invariants/OptimismSuperchainERC20/OptimismSuperchainERC20.t.sol +++ b/packages/contracts-bedrock/test/invariants/OptimismSuperchainERC20/OptimismSuperchainERC20.t.sol @@ -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 @@ -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) { @@ -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()); }