Skip to content

Commit ce5324e

Browse files
committedFeb 21, 2024
evm: add test for frontrunning Manager initialize
1 parent 5f5b3fa commit ce5324e

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed
 

‎evm/test/Upgrades.t.sol

+13-16
Original file line numberDiff line numberDiff line change
@@ -672,23 +672,20 @@ contract TestInitialize is Test {
672672
managerChain1.initialize();
673673
}
674674

675-
// TODO - Keep or remove depending on frontrunning discussion for deployment
676-
// function test_frontrunInitialize() public{
677-
// string memory url = "https://ethereum-goerli.publicnode.com";
678-
// vm.createSelectFork(url);
679-
680-
// vm.chainId(chainId1);
681-
// DummyToken t1 = new DummyToken();
682-
// ManagerStandalone implementation =
683-
// new ManagerStandalone(address(t1), Manager.Mode.LOCKING, chainId1, 1 days);
684-
685-
// managerChain1 = ManagerStandalone(address(new ERC1967Proxy(address(implementation), "")));
675+
function test_cannotFrontrunInitialize() public{
676+
string memory url = "https://ethereum-goerli.publicnode.com";
677+
vm.createSelectFork(url);
686678

687-
// vm.prank(userA);
679+
vm.chainId(chainId1);
680+
DummyToken t1 = new DummyToken();
681+
ManagerStandalone implementation =
682+
new ManagerStandalone(address(t1), Manager.Mode.LOCKING, chainId1, 1 days);
688683

689-
// // Frontrun of initialization occurs HERE
690-
// managerChain1.initialize();
684+
managerChain1 = ManagerStandalone(address(new ERC1967Proxy(address(implementation), "")));
691685

692-
// require(address(this) == managerChain1.owner(), "Unexpected owner");
693-
// }
686+
// Attempt to initialize the contract from a non-deployer account.
687+
vm.prank(userA);
688+
vm.expectRevert(abi.encodeWithSignature("UnexpectedOwner(address,address)", address(this), userA));
689+
managerChain1.initialize();
690+
}
694691
}

0 commit comments

Comments
 (0)