Commit 3c30fa18 authored by DenseDenise's avatar DenseDenise Committed by GitHub

add stepDefend success testcase (#11148)

parent f6f8cd53
......@@ -846,6 +846,39 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
gameProxy.step(8, true, claimData5, hex"");
}
/// @dev Tests that successfully step with true defend claim when there is a true defend claim(claim7) in the
/// middle of the dispute game.
function test_stepDefendDummyClaim_defendTrueClaimInTheMiddle_succeeds() public {
// Give the test contract some ether
vm.deal(address(this), 1000 ether);
// Make claims all the way down the tree.
(,,,, Claim disputed,,) = gameProxy.claimData(0);
gameProxy.attack{ value: _getRequiredBond(0) }(disputed, 0, _dummyClaim());
(,,,, disputed,,) = gameProxy.claimData(1);
gameProxy.attack{ value: _getRequiredBond(1) }(disputed, 1, _dummyClaim());
(,,,, disputed,,) = gameProxy.claimData(2);
gameProxy.attack{ value: _getRequiredBond(2) }(disputed, 2, _dummyClaim());
(,,,, disputed,,) = gameProxy.claimData(3);
gameProxy.attack{ value: _getRequiredBond(3) }(disputed, 3, _dummyClaim());
(,,,, disputed,,) = gameProxy.claimData(4);
gameProxy.attack{ value: _getRequiredBond(4) }(disputed, 4, _changeClaimStatus(_dummyClaim(), VMStatuses.PANIC));
bytes memory claimData7 = abi.encode(7, 7);
Claim postState_ = Claim.wrap(gameImpl.vm().step(claimData7, hex"", bytes32(0)));
(,,,, disputed,,) = gameProxy.claimData(5);
gameProxy.attack{ value: _getRequiredBond(5) }(disputed, 5, _dummyClaim());
(,,,, disputed,,) = gameProxy.claimData(6);
bytes memory _dummyClaimData = abi.encode(gasleft(), gasleft());
gameProxy.defend{ value: _getRequiredBond(6) }(disputed, 6, postState_);
(,,,, disputed,,) = gameProxy.claimData(7);
gameProxy.attack{ value: _getRequiredBond(7) }(disputed, 7, Claim.wrap(keccak256(claimData7)));
gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 8, 0);
gameProxy.step(8, false, claimData7, hex"");
}
/// @dev Tests that step reverts with false attacking claim when there is a true defend claim(claim5) in the middle
/// of the dispute game.
function test_stepAttackTrueClaim_defendTrueClaimInTheMiddle_reverts() public {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment