forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: proxied setup + unguided handlers
- Loading branch information
1 parent
31f6095
commit a85aebb
Showing
7 changed files
with
96 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
packages/contracts-bedrock/contracts/test/invariants/balance-claimer/FuzzTest.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.15; | ||
|
||
import {BalanceClaimerGuidedHandlers} from './handlers/guided/BalanceClaimer.t.sol'; | ||
import {BalanceClaimerUnguidedHandlers} from './handlers/unguided/BalanceClaimer.t.sol'; | ||
import {BalanceClaimerProperties} from './properties/BalanceClaimer.t.sol'; | ||
import "forge-std/console.sol"; | ||
|
||
import {BalanceClaimerGuidedHandlers} from "./handlers/guided/BalanceClaimer.t.sol"; | ||
import {BalanceClaimerUnguidedHandlers} from "./handlers/unguided/BalanceClaimer.t.sol"; | ||
import {BalanceClaimerProperties} from "./properties/BalanceClaimer.t.sol"; | ||
import {IErc20BalanceWithdrawer} from "contracts/L1/interfaces/winddown/IErc20BalanceWithdrawer.sol"; | ||
|
||
contract FuzzTest is BalanceClaimerGuidedHandlers, BalanceClaimerUnguidedHandlers, BalanceClaimerProperties {} |
67 changes: 62 additions & 5 deletions
67
...-bedrock/contracts/test/invariants/balance-claimer/handlers/unguided/BalanceClaimer.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,68 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.15; | ||
|
||
import {BalanceClaimerSetup} from '../../setup/BalanceClaimer.t.sol'; | ||
import "forge-std/console.sol"; | ||
|
||
import {BalanceClaimerSetup} from "../../setup/BalanceClaimer.t.sol"; | ||
import {IErc20BalanceWithdrawer} from "contracts/L1/interfaces/winddown/IErc20BalanceWithdrawer.sol"; | ||
import {IBalanceClaimer} from "contracts/L1/interfaces/winddown/IBalanceClaimer.sol"; | ||
|
||
contract BalanceClaimerUnguidedHandlers is BalanceClaimerSetup { | ||
/// @custom:property-id | ||
/// @custom:property | ||
function handler_fooUnguided(address _caller, string memory _newGreeting) external { | ||
} | ||
function handler_initialize(address _ethBalanceWithdrawer, address _erc20BalanceWithdrawer, bytes32 _root) | ||
external | ||
{ | ||
try balanceClaimer.initialize(_ethBalanceWithdrawer, _erc20BalanceWithdrawer, _root) { | ||
assert(false); // balanceClaimer should only be initialized once | ||
} catch {} | ||
} | ||
|
||
function handler_claim( | ||
bytes32[] calldata _proof, | ||
address _user, | ||
uint256 _ethBalance, | ||
IErc20BalanceWithdrawer.Erc20BalanceClaim[] calldata _erc20Claim, | ||
address _caller | ||
) external { | ||
vm.prank(_caller); | ||
try balanceClaimer.claim(_proof, _user, _ethBalance, _erc20Claim) { | ||
// TODO: check claim isnt in the valid set | ||
assert(false); // random claim got accepted | ||
} catch { | ||
// TODO: assert claim is not in tree | ||
// TODO: assert user already claimed | ||
} | ||
} | ||
|
||
function handler_canClaim( | ||
bytes32[] calldata _proof, | ||
address _user, | ||
uint256 _ethBalance, | ||
IErc20BalanceWithdrawer.Erc20BalanceClaim[] calldata _erc20Claim | ||
) external { | ||
if (balanceClaimer.canClaim(_proof, _user, _ethBalance, _erc20Claim)) { | ||
// TODO: check claim isnt in the valid set | ||
assert(false); // random claim got accepted | ||
} else { | ||
// TODO: assert claim is not in tree | ||
// TODO: assert user already claimed | ||
} | ||
} | ||
|
||
function handler_withdrawEthBalance(address _user, uint256 _ethClaim, address _caller) external { | ||
try optimismPortal.withdrawEthBalance(_user, _ethClaim) { | ||
assert(_caller == address(balanceClaimer)); | ||
// TODO: update ghost variables | ||
} catch {} | ||
} | ||
|
||
function handler_withdrawErc20Balance( | ||
address _user, | ||
IErc20BalanceWithdrawer.Erc20BalanceClaim[] calldata _tokenClaims, | ||
address _caller | ||
) external { | ||
try l1StandardBridge.withdrawErc20Balance(_user, _tokenClaims) { | ||
assert(_caller == address(balanceClaimer)); | ||
// TODO: update ghost variables | ||
} catch {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters