Skip to content

Commit

Permalink
Increase test coverage for Escrow contract
Browse files Browse the repository at this point in the history
  • Loading branch information
sandstone-ag committed Aug 23, 2024
1 parent b2db067 commit 60d34bb
Show file tree
Hide file tree
Showing 6 changed files with 487 additions and 0 deletions.
7 changes: 7 additions & 0 deletions contracts/interfaces/IEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
pragma solidity 0.8.26;

import {Duration} from "../types/Duration.sol";
import {Timestamp} from "../types/Timestamp.sol";
import {PercentD16} from "../types/PercentD16.sol";

interface IEscrow {
function initialize(Duration minAssetsLockDuration) external;

function startRageQuit(Duration rageQuitExtraTimelock, Duration rageQuitWithdrawalsTimelock) external;
function requestNextWithdrawalsBatch(uint256 batchSize) external;
function claimNextWithdrawalsBatch(uint256 maxUnstETHIdsCount) external;
function claimNextWithdrawalsBatch(uint256 fromUnstETHId, uint256[] calldata hints) external;
function startRageQuitExtensionDelay() external;

function isRageQuitFinalized() external view returns (bool);
function getRageQuitSupport() external view returns (PercentD16 rageQuitSupport);
function setMinAssetsLockDuration(Duration newMinAssetsLockDuration) external;
function isRageQuitExtensionDelayStarted() external view returns (bool);
function getRageQuitExtensionDelayStartedAt() external view returns (Timestamp);
}
57 changes: 57 additions & 0 deletions test/mocks/DualGovernanceMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {IDualGovernance} from "contracts/interfaces/IDualGovernance.sol";
import {ExternalCall} from "contracts/libraries/ExternalCalls.sol";
import {IEscrow} from "contracts/interfaces/IEscrow.sol";
import {Duration} from "contracts/types/Duration.sol";

contract DualGovernanceMock is IDualGovernance {
function submitProposal(ExternalCall[] calldata calls) external returns (uint256 proposalId) {
revert("Not Implemented");
}

function scheduleProposal(uint256 proposalId) external {
revert("Not Implemented");
}

function cancelAllPendingProposals() external {
revert("Not Implemented");
}

function canScheduleProposal(uint256 proposalId) external view returns (bool) {
revert("Not Implemented");
}

function activateNextState() external {
revert("Not Implemented");
}

function resealSealable(address sealables) external {
revert("Not Implemented");
}

function tiebreakerScheduleProposal(uint256 proposalId) external {
revert("Not Implemented");
}

function tiebreakerResumeSealable(address sealable) external {
revert("Not Implemented");
}

function initializeEscrow(IEscrow instance, Duration minAssetsLockDuration) external {
instance.initialize(minAssetsLockDuration);
}

function startRageQuitForEscrow(
IEscrow instance,
Duration rageQuitExtensionDelay,
Duration rageQuitWithdrawalsTimelock
) external {
instance.startRageQuit(rageQuitExtensionDelay, rageQuitWithdrawalsTimelock);
}

function setMinAssetsLockDurationForEscrow(IEscrow instance, Duration newMinAssetsLockDuration) external {
instance.setMinAssetsLockDuration(newMinAssetsLockDuration);
}
}
27 changes: 27 additions & 0 deletions test/mocks/StETHMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {ERC20Mock} from "@openzeppelin/contracts/mocks/token/ERC20Mock.sol";
import {IStETH} from "contracts/interfaces/IStETH.sol";

contract StETHMock is ERC20Mock, IStETH {
function getSharesByPooledEth(uint256 ethAmount) external view returns (uint256) {
revert("Not Implemented");
}

function getPooledEthByShares(uint256 sharesAmount) external view returns (uint256) {
revert("Not Implemented");
}

function transferShares(address to, uint256 amount) external {
revert("Not Implemented");
}

function transferSharesFrom(
address _sender,
address _recipient,
uint256 _sharesAmount
) external returns (uint256) {
revert("Not Implemented");
}
}
134 changes: 134 additions & 0 deletions test/mocks/WithdrawalQueueMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

// import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; /*, ERC721("test", "test")*/
import {IWithdrawalQueue, WithdrawalRequestStatus} from "contracts/interfaces/IWithdrawalQueue.sol";

contract WithdrawalQueueMock is IWithdrawalQueue {
uint256 _lastRequestId;
uint256 _lastFinalizedRequestId;
uint256 _minStETHWithdrawalAmount;
uint256 _maxStETHWithdrawalAmount;
uint256[] _requestWithdrawalsResult;

constructor() {}

function MIN_STETH_WITHDRAWAL_AMOUNT() external view returns (uint256) {
return _minStETHWithdrawalAmount;
}

function MAX_STETH_WITHDRAWAL_AMOUNT() external view returns (uint256) {
return _maxStETHWithdrawalAmount;
}

function claimWithdrawals(uint256[] calldata requestIds, uint256[] calldata hints) external {
revert("Not Implemented");
}

function getLastRequestId() external view returns (uint256) {
return _lastRequestId;
}

function getLastFinalizedRequestId() external view returns (uint256) {
return _lastFinalizedRequestId;
}

function getWithdrawalStatus(uint256[] calldata _requestIds)
external
view
returns (WithdrawalRequestStatus[] memory statuses)
{
revert("Not Implemented");
}

/// @notice Returns amount of ether available for claim for each provided request id
/// @param _requestIds array of request ids
/// @param _hints checkpoint hints. can be found with `findCheckpointHints(_requestIds, 1, getLastCheckpointIndex())`
/// @return claimableEthValues amount of claimable ether for each request, amount is equal to 0 if request
/// is not finalized or already claimed
function getClaimableEther(
uint256[] calldata _requestIds,
uint256[] calldata _hints
) external view returns (uint256[] memory claimableEthValues) {
revert("Not Implemented");
}

function findCheckpointHints(
uint256[] calldata _requestIds,
uint256 _firstIndex,
uint256 _lastIndex
) external view returns (uint256[] memory hintIds) {
revert("Not Implemented");
}

function getLastCheckpointIndex() external view returns (uint256) {
revert("Not Implemented");
}

function requestWithdrawals(
uint256[] calldata _amounts,
address _owner
) external returns (uint256[] memory requestIds) {
return _requestWithdrawalsResult;
}

function balanceOf(address owner) external view returns (uint256 balance) {
revert("Not Implemented");
}

function ownerOf(uint256 tokenId) external view returns (address owner) {
revert("Not Implemented");
}

function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external {
revert("Not Implemented");
}

function safeTransferFrom(address from, address to, uint256 tokenId) external {
revert("Not Implemented");
}

function transferFrom(address from, address to, uint256 tokenId) external {
revert("Not Implemented");
}

function approve(address to, uint256 tokenId) external {
revert("Not Implemented");
}

function setApprovalForAll(address operator, bool approved) external {
revert("Not Implemented");
}

function getApproved(uint256 tokenId) external view returns (address operator) {
revert("Not Implemented");
}

function isApprovedForAll(address owner, address operator) external view returns (bool) {
revert("Not Implemented");
}

function supportsInterface(bytes4 interfaceId) external view returns (bool) {
revert("Not Implemented");
}

function setLastRequestId(uint256 id) public {
_lastRequestId = id;
}

function setLastFinalizedRequestId(uint256 id) public {
_lastFinalizedRequestId = id;
}

function setMinStETHWithdrawalAmount(uint256 amount) public {
_minStETHWithdrawalAmount = amount;
}

function setMaxStETHWithdrawalAmount(uint256 amount) public {
_maxStETHWithdrawalAmount = amount;
}

function setRequestWithdrawalsResult(uint256[] memory requestIds) public {
_requestWithdrawalsResult = requestIds;
}
}
19 changes: 19 additions & 0 deletions test/mocks/WstETHMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {ERC20Mock} from "@openzeppelin/contracts/mocks/token/ERC20Mock.sol";
import {IWstETH} from "contracts/interfaces/IWstETH.sol";

contract WstETHMock is ERC20Mock, IWstETH {
function wrap(uint256 stETHAmount) external returns (uint256) {
revert("Not Implemented");
}

function unwrap(uint256 wstETHAmount) external returns (uint256) {
revert("Not Implemented");
}

function getStETHByWstETH(uint256 wstethAmount) external view returns (uint256) {
revert("Not Implemented");
}
}
Loading

0 comments on commit 60d34bb

Please sign in to comment.