Skip to content

Commit

Permalink
test: add fuzzed calls to burn and mint
Browse files Browse the repository at this point in the history
  • Loading branch information
0xteddybear committed Aug 28, 2024
1 parent 7bba3f0 commit cd2b64b
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,39 @@ contract ProtocolUnguided is ProtocolHandler {
}
}

/// @custom:property-id 12
/// @custom:property supertoken total supply only increases on calls to mint() by the L2toL2StandardBridge
function fuzz_mint(uint256 tokenIndex, address to, address sender, uint256 amount) external {
address token = allSuperTokens[bound(tokenIndex, 0, allSuperTokens.length)];
bytes32 salt = MESSENGER.superTokenInitDeploySalts(token);
amount = bound(amount, 0, type(uint256).max - OptimismSuperchainERC20(token).totalSupply());
vm.prank(sender);
try OptimismSuperchainERC20(token).mint(to, amount) {
assert(sender == BRIDGE);
(, uint256 currentValue) = ghost_totalSupplyAcrossChains.tryGet(salt);
ghost_totalSupplyAcrossChains.set(salt, currentValue - amount);
} catch {
assert(sender != BRIDGE);
}
}


/// @custom:property-id 13
/// @custom:property supertoken total supply only increases on calls to mint() by the L2toL2StandardBridge
function fuzz_burn(uint256 tokenIndex, address from, address sender, uint256 amount) external {
address token = allSuperTokens[bound(tokenIndex, 0, allSuperTokens.length)];
bytes32 salt = MESSENGER.superTokenInitDeploySalts(token);
uint256 senderBalance = OptimismSuperchainERC20(token).balanceOf(sender);
vm.prank(sender);
try OptimismSuperchainERC20(token).burn(from, amount) {
assert(sender == BRIDGE);
(, uint256 currentValue) = ghost_totalSupplyAcrossChains.tryGet(salt);
ghost_totalSupplyAcrossChains.set(salt, currentValue - amount);
} catch {
assert(sender != BRIDGE || senderBalance < amount);
}
}

/// @custom:property-id 25
/// @custom:property supertokens can't be reinitialized
function fuzz_initialize(
Expand Down

0 comments on commit cd2b64b

Please sign in to comment.