From 577a12f8b8e46605b932d8c9fa8bab9a51ffce6c Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Thu, 24 Aug 2023 18:19:54 +0200 Subject: [PATCH] Removed block check from setrefunded (#419) --- .../challengeV2/libraries/ChallengeEdgeLib.sol | 5 +---- .../challengeV2/EdgeChallengeManager.t.sol | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/contracts/src/challengeV2/libraries/ChallengeEdgeLib.sol b/contracts/src/challengeV2/libraries/ChallengeEdgeLib.sol index 9928ec4e1..693f4acab 100644 --- a/contracts/src/challengeV2/libraries/ChallengeEdgeLib.sol +++ b/contracts/src/challengeV2/libraries/ChallengeEdgeLib.sol @@ -244,14 +244,11 @@ library ChallengeEdgeLib { } /// @notice Set the refunded flag of an edge - /// @dev Checks internally that edge is confirmed, Block type, layer zero edge and hasnt been refunded already + /// @dev Checks internally that edge is confirmed, layer zero edge and hasnt been refunded already function setRefunded(ChallengeEdge storage edge) internal { if (edge.status != EdgeStatus.Confirmed) { revert EdgeNotConfirmed(ChallengeEdgeLib.id(edge), edge.status); } - if (edge.eType != EdgeType.Block) { - revert EdgeTypeNotBlock(edge.eType); - } if (!isLayerZero(edge)) { revert EdgeNotLayerZero(ChallengeEdgeLib.id(edge), edge.staker, edge.claimId); } diff --git a/contracts/test/challengeV2/EdgeChallengeManager.t.sol b/contracts/test/challengeV2/EdgeChallengeManager.t.sol index cdec487b0..025c494bb 100644 --- a/contracts/test/challengeV2/EdgeChallengeManager.t.sol +++ b/contracts/test/challengeV2/EdgeChallengeManager.t.sol @@ -1395,16 +1395,26 @@ contract EdgeChallengeManagerTest is Test { ei.challengeManager.refundStake(allWinners[16].lowerChildId); } - function testRevertRefundStakeBigStep() external { + function testRefundStakeBigStep() external { (EdgeInitData memory ei, BisectionChildren[] memory allWinners) = testCanConfirmByOneStep(); - vm.expectRevert(abi.encodeWithSelector(EdgeTypeNotBlock.selector, EdgeType.BigStep)); + + IERC20 stakeToken = ei.challengeManager.stakeToken(); + uint256 beforeBalance = stakeToken.balanceOf(address(this)); + vm.prank(nobody); // call refund as nobody ei.challengeManager.refundStake(allWinners[11].lowerChildId); + uint256 afterBalance = stakeToken.balanceOf(address(this)); + assertEq(afterBalance - beforeBalance, ei.challengeManager.stakeAmount(), "Stake refunded"); } - function testRevertRefundStakeSmallStep() external { + function testRefundStakeSmallStep() external { (EdgeInitData memory ei, BisectionChildren[] memory allWinners) = testCanConfirmByOneStep(); - vm.expectRevert(abi.encodeWithSelector(EdgeTypeNotBlock.selector, EdgeType.SmallStep)); + + IERC20 stakeToken = ei.challengeManager.stakeToken(); + uint256 beforeBalance = stakeToken.balanceOf(address(this)); + vm.prank(nobody); // call refund as nobody ei.challengeManager.refundStake(allWinners[5].lowerChildId); + uint256 afterBalance = stakeToken.balanceOf(address(this)); + assertEq(afterBalance - beforeBalance, ei.challengeManager.stakeAmount(), "Stake refunded"); } function testRevertRefundStakeNotConfirmed() external {