Skip to content

Commit fecbee6

Browse files
committed
withdrawal when gameWasNotRespectedGameType reverts
1 parent 2e0181d commit fecbee6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,36 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
14271427
optimismPortal2.finalizeWithdrawalTransaction(_defaultTx);
14281428
}
14291429

1430+
/// @dev Tests that `finalizeWithdrawalTransaction` reverts if the game was not the respected game type when it was
1431+
/// created. `proveWithdrawalTransaction` should already prevent this, but we remove that assumption here.
1432+
function test_finalizeWithdrawalTransaction_gameWasNotRespectedGameType_reverts() external {
1433+
vm.expectEmit(address(optimismPortal2));
1434+
emit WithdrawalProven(_withdrawalHash, alice, bob);
1435+
vm.expectEmit(address(optimismPortal2));
1436+
emit WithdrawalProvenExtension1(_withdrawalHash, address(this));
1437+
optimismPortal2.proveWithdrawalTransaction({
1438+
_tx: _defaultTx,
1439+
_disputeGameIndex: _proposedGameIndex,
1440+
_outputRootProof: _outputRootProof,
1441+
_withdrawalProof: _withdrawalProof
1442+
});
1443+
1444+
// Warp past the finalization period.
1445+
vm.warp(block.timestamp + optimismPortal2.proofMaturityDelaySeconds() + 1);
1446+
1447+
// Resolve the dispute game.
1448+
game.resolveClaim(0, 0);
1449+
game.resolve();
1450+
1451+
// Warp past the dispute game finality delay.
1452+
vm.warp(block.timestamp + optimismPortal2.disputeGameFinalityDelaySeconds() + 1);
1453+
1454+
vm.mockCall(address(game), abi.encodeCall(game.wasRespectedGameTypeWhenCreated, ()), abi.encode(false));
1455+
1456+
vm.expectRevert(InvalidGameType.selector);
1457+
optimismPortal2.finalizeWithdrawalTransaction(_defaultTx);
1458+
}
1459+
14301460
/// @dev Tests an e2e prove -> finalize path, checking the edges of each delay for correctness.
14311461
function test_finalizeWithdrawalTransaction_delayEdges_succeeds() external {
14321462
// Prove the withdrawal transaction.

0 commit comments

Comments
 (0)