From 24a96c597d5a38a13fc887dfda28ff67eb87f1e2 Mon Sep 17 00:00:00 2001 From: Flocqst Date: Wed, 11 Sep 2024 15:29:08 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20test=5FinitializerDisabledAft?= =?UTF-8?q?erDeployment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/Upgrade.t.sol | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/Upgrade.t.sol b/test/Upgrade.t.sol index 4b85997..a683ae6 100644 --- a/test/Upgrade.t.sol +++ b/test/Upgrade.t.sol @@ -1,6 +1,8 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.25; +import {Initializable} from + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {IKSXVault} from "src/interfaces/IKSXVault.sol"; import {Bootstrap, KSXVault} from "test/utils/Bootstrap.sol"; import {MockVaultUpgrade} from "test/utils/mocks/MockVaultUpgrade.sol"; @@ -75,4 +77,18 @@ contract MockUpgrade is UpgradeTest { ksxVault.upgradeToAndCall(address(mockVaultUpgrade), ""); } + function test_initializerDisabledAfterDeployment() public { + // Vault is already initialized in the setUp() + + // Try to initialize again + vm.expectRevert( + abi.encodeWithSelector(Initializable.InvalidInitialization.selector) + ); + + ksxVault.initialize(address(0x00)); + + // Verify that the token address did not change + assertEq(address(ksxVault.asset()), _token); + } + }