Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test case #12

Open
wants to merge 1 commit into
base: develop_1.20_nary4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/src/dispute/FaultDisputeGameN.sol
Original file line number Diff line number Diff line change
Expand Up @@ -910,12 +910,12 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver {

// If the move is a defense, the disputed output could have been made by either party. In this case, we
// need to search for the parent output to determine what the expected status byte should be.
Position disputedLeafPos = Position.wrap(_parentPos.raw() + 1);
Position disputedLeafPos = Position.wrap(_parentPos.raw() + _attackBranch);
(Claim disputedClaim, Position disputedPos) =
_findTraceAncestorV2({ _pos: disputedLeafPos, _start: _parentIdx, _global: true });
uint8 vmStatus = uint8(_rootClaim.raw()[0]);

if ((0 != _attackBranch) || (disputedPos.depth() / N_BITS) % 2 == (SPLIT_DEPTH / N_BITS) % 2) {
if (((1 << N_BITS - 1) != _attackBranch) || (disputedPos.depth() / N_BITS) % 2 == (SPLIT_DEPTH / N_BITS) % 2) {
// If the move is an attack, the parent output is always deemed to be disputed. In this case, we only need
// to check that the root claim signals that the VM panicked or resulted in an invalid transition.
// If the move is a defense, and the disputed output and creator of the execution trace subgame disagree,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,14 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init {
(,,,, Claim root,,) = gameProxy.claimData(0);
// Attempt to make a move. Should revert.
vm.expectRevert(GameNotInProgress.selector);
gameProxy.attack(root, 0, Claim.wrap(0));
gameProxy.attackV2(root, 0, Claim.wrap(0), 0);
}

/// @dev Tests that an attempt to defend the root claim reverts with the `CannotDefendRootClaim` error.
function test_move_defendRoot_reverts() public {
(,,,, Claim root,,) = gameProxy.claimData(0);
vm.expectRevert(CannotDefendRootClaim.selector);
gameProxy.defend(root, 0, _dummyClaim());
gameProxy.attackV2(root, 0, _dummyClaim(), 1);
}

/// @dev Tests that an attempt to move against a claim that does not exist reverts with the
Expand All @@ -378,11 +378,11 @@ contract FaultDisputeGameN_Test is FaultDisputeGame_Init {

// Expect an out of bounds revert for an attack
vm.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x32));
gameProxy.attack(_dummyClaim(), 1, claim);
gameProxy.attackV2(_dummyClaim(), 1, claim, 0);

// Expect an out of bounds revert for a defense
vm.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x32));
gameProxy.defend(_dummyClaim(), 1, claim);
gameProxy.attackV2(_dummyClaim(), 1, claim, 3);
}

/// @dev Tests that an attempt to move at the maximum game depth reverts with the
Expand Down