Skip to content

Commit

Permalink
Minor improvements in Escrow unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sandstone-ag committed Aug 23, 2024
1 parent 60d34bb commit ff5c382
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions test/mocks/DualGovernanceMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {ExternalCall} from "contracts/libraries/ExternalCalls.sol";
import {IEscrow} from "contracts/interfaces/IEscrow.sol";
import {Duration} from "contracts/types/Duration.sol";

/* solhint-disable no-unused-vars,custom-errors */
contract DualGovernanceMock is IDualGovernance {
function submitProposal(ExternalCall[] calldata calls) external returns (uint256 proposalId) {
revert("Not Implemented");
Expand Down
1 change: 1 addition & 0 deletions test/mocks/StETHMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.26;
import {ERC20Mock} from "@openzeppelin/contracts/mocks/token/ERC20Mock.sol";
import {IStETH} from "contracts/interfaces/IStETH.sol";

/* solhint-disable no-unused-vars,custom-errors */
contract StETHMock is ERC20Mock, IStETH {
function getSharesByPooledEth(uint256 ethAmount) external view returns (uint256) {
revert("Not Implemented");
Expand Down
11 changes: 6 additions & 5 deletions test/mocks/WithdrawalQueueMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ 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";

/* solhint-disable no-unused-vars,custom-errors */
contract WithdrawalQueueMock is IWithdrawalQueue {
uint256 _lastRequestId;
uint256 _lastFinalizedRequestId;
uint256 _minStETHWithdrawalAmount;
uint256 _maxStETHWithdrawalAmount;
uint256[] _requestWithdrawalsResult;
uint256 private _lastRequestId;
uint256 private _lastFinalizedRequestId;
uint256 private _minStETHWithdrawalAmount;
uint256 private _maxStETHWithdrawalAmount;
uint256[] private _requestWithdrawalsResult;

constructor() {}

Expand Down
1 change: 1 addition & 0 deletions test/mocks/WstETHMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.26;
import {ERC20Mock} from "@openzeppelin/contracts/mocks/token/ERC20Mock.sol";
import {IWstETH} from "contracts/interfaces/IWstETH.sol";

/* solhint-disable no-unused-vars,custom-errors */
contract WstETHMock is ERC20Mock, IWstETH {
function wrap(uint256 stETHAmount) external returns (uint256) {
revert("Not Implemented");
Expand Down
17 changes: 7 additions & 10 deletions test/unit/Escrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {IEscrow} from "contracts/interfaces/IEscrow.sol";
import {IStETH} from "contracts/interfaces/IStETH.sol";
import {IWstETH} from "contracts/interfaces/IWstETH.sol";
import {IDualGovernance} from "contracts/interfaces/IDualGovernance.sol";
import {IWithdrawalQueue} from "contracts/interfaces/IWithdrawalQueue.sol";
import {Escrow} from "contracts/Escrow.sol";
import {EscrowState as EscrowStateLib, State as EscrowState} from "contracts/libraries/EscrowState.sol";
import {WithdrawalsBatchesQueue} from "contracts/libraries/WithdrawalBatchesQueue.sol";
Expand All @@ -18,15 +16,14 @@ import {WstETHMock} from "test/mocks/WstETHMock.sol";
import {DualGovernanceMock} from "test/mocks/DualGovernanceMock.sol";
import {WithdrawalQueueMock} from "test/mocks/WithdrawalQueueMock.sol";
import {UnitTest} from "test/utils/unit-test.sol";
import {LidoUtils} from "test/utils/lido-utils.sol";
import {Random} from "test/utils/random.sol";

contract EscrowUnitTests is UnitTest {
Random.Context _random;
IStETH _stETH;
IWstETH _wstETH;
WithdrawalQueueMock _withdrawalQueue;
DualGovernanceMock _dualGovernance;
Random.Context private _random;
IStETH private _stETH;
IWstETH private _wstETH;
WithdrawalQueueMock private _withdrawalQueue;
DualGovernanceMock private _dualGovernance;

function setUp() external {
_random = Random.create(block.timestamp);
Expand Down Expand Up @@ -204,7 +201,7 @@ contract EscrowUnitTests is UnitTest {
IEscrow instance = createInitializedEscrowProxy(100, Durations.ZERO);

bool res = instance.isRageQuitExtensionDelayStarted();
assert(res == false);
assertFalse(res);
}

// ---
Expand All @@ -215,7 +212,7 @@ contract EscrowUnitTests is UnitTest {
IEscrow instance = createInitializedEscrowProxy(100, Durations.ZERO);

Timestamp res = instance.getRageQuitExtensionDelayStartedAt();
assert(res.toSeconds() == Timestamps.ZERO.toSeconds());
assertEq(res.toSeconds(), Timestamps.ZERO.toSeconds());
}

// ---
Expand Down
6 changes: 3 additions & 3 deletions test/unit/libraries/WithdrawalBatchesQueue.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ contract WithdrawalsBatchesQueueTest is UnitTest {

uint256 res = _batchesQueue.getTotalUnclaimedUnstETHIdsCount();

assert(res == totalCount - totalClaimed);
assertEq(res, totalCount - totalClaimed);
}

function testFuzz_getTotalUnclaimedUnstETHIdsCount_RevertOn_AccountingError_IncorrectTotals() external {
Expand Down Expand Up @@ -666,7 +666,7 @@ contract WithdrawalsBatchesQueueTest is UnitTest {
_batchesQueue.info.totalUnstETHIdsCount = count;

bool res = _batchesQueue.isAllBatchesClaimed();
assert(res == true);
assertTrue(res);
}

function testFuzz_isAllBatchesClaimed_HappyPath_ReturnsFalse(
Expand All @@ -678,7 +678,7 @@ contract WithdrawalsBatchesQueueTest is UnitTest {
_batchesQueue.info.totalUnstETHIdsCount = totalUnstETHCount;

bool res = _batchesQueue.isAllBatchesClaimed();
assert(res == false);
assertFalse(res);
}

// ---
Expand Down

0 comments on commit ff5c382

Please sign in to comment.