From d2c74a301cf70e726c4089a40412de02f5953b49 Mon Sep 17 00:00:00 2001 From: gabrielstoica Date: Mon, 12 Aug 2024 13:22:34 +0300 Subject: [PATCH] test: add missing errors, events and 'ModuleKeeper' constructor test --- .../concrete/module-keeper/constructor.t.sol | 20 +++++++++++++++++++ test/utils/Errors.sol | 3 +++ test/utils/Events.sol | 8 +++++++- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/unit/concrete/module-keeper/constructor.t.sol diff --git a/test/unit/concrete/module-keeper/constructor.t.sol b/test/unit/concrete/module-keeper/constructor.t.sol new file mode 100644 index 0000000..6621bbf --- /dev/null +++ b/test/unit/concrete/module-keeper/constructor.t.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.26; + +import { ModuleKeeper } from "./../../../../src/ModuleKeeper.sol"; +import { Base_Test } from "../../../Base.t.sol"; + +contract Constructor_ModuleKeeper_Test is Base_Test { + function setUp() public virtual override { + Base_Test.setUp(); + } + + function test_Constructor() external { + // Run the test + ModuleKeeper moduleKeeper = new ModuleKeeper({ _initialOwner: users.admin }); + + // Assert the actual and expected owner + address owner = moduleKeeper.owner(); + assertEq(owner, users.admin); + } +} diff --git a/test/utils/Errors.sol b/test/utils/Errors.sol index 049041e..7906fb2 100644 --- a/test/utils/Errors.sol +++ b/test/utils/Errors.sol @@ -125,4 +125,7 @@ library Errors { /// @notice Thrown when `msg.sender` is not the contract owner error Unauthorized(); + + /// @notice Thrown when `msg.sender` is not authorized to perform an operation + error OwnableUnauthorizedAccount(address account); } diff --git a/test/utils/Events.sol b/test/utils/Events.sol index c57dce2..10836e6 100644 --- a/test/utils/Events.sol +++ b/test/utils/Events.sol @@ -9,7 +9,7 @@ import { UD60x18 } from "@prb/math/src/UD60x18.sol"; /// @notice Abstract contract to store all the events emitted in the tested contracts abstract contract Events { /*////////////////////////////////////////////////////////////////////////// - MODULE-KEEPER + DOCK-REGISTRY //////////////////////////////////////////////////////////////////////////*/ /// @notice Emitted when a new {Container} contract gets deployed @@ -37,6 +37,12 @@ abstract contract Events { /// @param newModuleKeeper The new address of the {ModuleKeeper} event ModuleKeeperUpdated(ModuleKeeper newModuleKeeper); + /// @dev Emitted when the contract has been initialized or reinitialized + event Initialized(uint64 version); + + /// @dev Emitted when the implementation is upgraded + event Upgraded(address indexed implementation); + /*////////////////////////////////////////////////////////////////////////// CONTAINER //////////////////////////////////////////////////////////////////////////*/