Commit 38d20ba5 authored by Maurelian's avatar Maurelian

ctb: Fix Proxy and ProxyAdmin test function names

parent 4270589b
...@@ -47,7 +47,7 @@ contract Proxy_Test is Test { ...@@ -47,7 +47,7 @@ contract Proxy_Test is Test {
proxy.upgradeTo(address(simpleStorage)); proxy.upgradeTo(address(simpleStorage));
} }
function test_implementationKey() external { function test_implementationKey_succeeds() external {
// The hardcoded implementation key should be correct // The hardcoded implementation key should be correct
vm.prank(alice); vm.prank(alice);
proxy.upgradeTo(address(6)); proxy.upgradeTo(address(6));
...@@ -60,7 +60,7 @@ contract Proxy_Test is Test { ...@@ -60,7 +60,7 @@ contract Proxy_Test is Test {
assertEq(impl, address(6)); assertEq(impl, address(6));
} }
function test_ownerKey() external { function test_ownerKey_succeeds() external {
// The hardcoded owner key should be correct // The hardcoded owner key should be correct
vm.prank(alice); vm.prank(alice);
proxy.changeAdmin(address(6)); proxy.changeAdmin(address(6));
...@@ -73,7 +73,7 @@ contract Proxy_Test is Test { ...@@ -73,7 +73,7 @@ contract Proxy_Test is Test {
assertEq(owner, address(6)); assertEq(owner, address(6));
} }
function test_implementationProxyCallIfNotAdmin() external { function test_proxyCallToImp_notAdmin_succeeds() external {
// The implementation does not have a `upgradeTo` // The implementation does not have a `upgradeTo`
// method, calling `upgradeTo` not as the owner // method, calling `upgradeTo` not as the owner
// should revert. // should revert.
...@@ -93,7 +93,7 @@ contract Proxy_Test is Test { ...@@ -93,7 +93,7 @@ contract Proxy_Test is Test {
assertEq(impl, address(64)); assertEq(impl, address(64));
} }
function test_ownerProxyCallIfNotAdmin() external { function test_ownerProxyCall_notAdmin_succeeds() external {
// Calling `changeAdmin` not as the owner should revert // Calling `changeAdmin` not as the owner should revert
// as the implementation does not have a `changeAdmin` method. // as the implementation does not have a `changeAdmin` method.
vm.expectRevert(); vm.expectRevert();
...@@ -118,7 +118,7 @@ contract Proxy_Test is Test { ...@@ -118,7 +118,7 @@ contract Proxy_Test is Test {
assertEq(owner, address(1)); assertEq(owner, address(1));
} }
function test_itDelegatesToTheImplementation() external { function test_delegatesToImpl_succeeds() external {
// Call the storage setter on the proxy // Call the storage setter on the proxy
SimpleStorage(address(proxy)).set(1, 1); SimpleStorage(address(proxy)).set(1, 1);
...@@ -140,7 +140,7 @@ contract Proxy_Test is Test { ...@@ -140,7 +140,7 @@ contract Proxy_Test is Test {
} }
} }
function test_upgradeToAndCall() external { function test_upgradeToAndCall_succeeds() external {
{ {
// There should be nothing in the current proxy storage // There should be nothing in the current proxy storage
uint256 expect = SimpleStorage(address(proxy)).get(1); uint256 expect = SimpleStorage(address(proxy)).get(1);
...@@ -165,7 +165,7 @@ contract Proxy_Test is Test { ...@@ -165,7 +165,7 @@ contract Proxy_Test is Test {
assertEq(result, 1); assertEq(result, 1);
} }
function test_revertUpgradeToAndCall() external { function test_upgradeToAndCall_functionDoesNotExist_reverts() external {
// Get the current implementation address // Get the current implementation address
vm.prank(alice); vm.prank(alice);
address impl = proxy.implementation(); address impl = proxy.implementation();
...@@ -197,7 +197,7 @@ contract Proxy_Test is Test { ...@@ -197,7 +197,7 @@ contract Proxy_Test is Test {
); );
} }
function test_payableUpgradeToAndCall() external { function test_upgradeToAndCall_isPayable_succeeds() external {
// Give alice some funds // Give alice some funds
vm.deal(alice, 1 ether); vm.deal(alice, 1 ether);
// Set the implementation and call and send // Set the implementation and call and send
...@@ -217,7 +217,7 @@ contract Proxy_Test is Test { ...@@ -217,7 +217,7 @@ contract Proxy_Test is Test {
assertEq(address(proxy).balance, 1 ether); assertEq(address(proxy).balance, 1 ether);
} }
function test_clashingFunctionSignatures() external { function test_upgradeTo_clashingFunctionSignatures_succeeds() external {
// Clasher has a clashing function with the proxy. // Clasher has a clashing function with the proxy.
Clasher clasher = new Clasher(); Clasher clasher = new Clasher();
...@@ -253,13 +253,13 @@ contract Proxy_Test is Test { ...@@ -253,13 +253,13 @@ contract Proxy_Test is Test {
// Allow for `eth_call` to call proxy methods // Allow for `eth_call` to call proxy methods
// by setting "from" to `address(0)`. // by setting "from" to `address(0)`.
function test_zeroAddressCaller() external { function test_implementation_zeroAddressCaller_succeeds() external {
vm.prank(address(0)); vm.prank(address(0));
address impl = proxy.implementation(); address impl = proxy.implementation();
assertEq(impl, address(simpleStorage)); assertEq(impl, address(simpleStorage));
} }
function test_implementationZeroAddress() external { function test_implementation_isZeroAddress_reverts() external {
// Set `address(0)` as the implementation. // Set `address(0)` as the implementation.
vm.prank(alice); vm.prank(alice);
proxy.upgradeTo(address(0)); proxy.upgradeTo(address(0));
......
...@@ -59,32 +59,32 @@ contract ProxyAdmin_Test is Test { ...@@ -59,32 +59,32 @@ contract ProxyAdmin_Test is Test {
implementation = new SimpleStorage(); implementation = new SimpleStorage();
} }
function test_setImplementationName() external { function test_setImplementationName_succeeds() external {
vm.prank(alice); vm.prank(alice);
admin.setImplementationName(address(1), "foo"); admin.setImplementationName(address(1), "foo");
assertEq(admin.implementationName(address(1)), "foo"); assertEq(admin.implementationName(address(1)), "foo");
} }
function test_onlyOwnerSetAddressManager() external { function test_setAddressManager_notOwner_reverts() external {
vm.expectRevert("Ownable: caller is not the owner"); vm.expectRevert("Ownable: caller is not the owner");
admin.setAddressManager(AddressManager((address(0)))); admin.setAddressManager(AddressManager((address(0))));
} }
function test_onlyOwnerSetImplementationName() external { function test_setImplementationName_notOwner_reverts() external {
vm.expectRevert("Ownable: caller is not the owner"); vm.expectRevert("Ownable: caller is not the owner");
admin.setImplementationName(address(0), "foo"); admin.setImplementationName(address(0), "foo");
} }
function test_onlyOwnerSetProxyType() external { function test_setProxyType_notOwner_reverts() external {
vm.expectRevert("Ownable: caller is not the owner"); vm.expectRevert("Ownable: caller is not the owner");
admin.setProxyType(address(0), ProxyAdmin.ProxyType.CHUGSPLASH); admin.setProxyType(address(0), ProxyAdmin.ProxyType.CHUGSPLASH);
} }
function test_owner() external { function test_owner_succeeds() external {
assertEq(admin.owner(), alice); assertEq(admin.owner(), alice);
} }
function test_proxyType() external { function test_proxyType_succeeds() external {
assertEq(uint256(admin.proxyType(address(proxy))), uint256(ProxyAdmin.ProxyType.ERC1967)); assertEq(uint256(admin.proxyType(address(proxy))), uint256(ProxyAdmin.ProxyType.ERC1967));
assertEq( assertEq(
uint256(admin.proxyType(address(chugsplash))), uint256(admin.proxyType(address(chugsplash))),
...@@ -96,15 +96,15 @@ contract ProxyAdmin_Test is Test { ...@@ -96,15 +96,15 @@ contract ProxyAdmin_Test is Test {
); );
} }
function test_erc1967GetProxyImplementation() external { function test_erc1967GetProxyImplementation_succeeds() external {
getProxyImplementation(payable(proxy)); getProxyImplementation(payable(proxy));
} }
function test_chugsplashGetProxyImplementation() external { function test_chugsplashGetProxyImplementation_succeeds() external {
getProxyImplementation(payable(chugsplash)); getProxyImplementation(payable(chugsplash));
} }
function test_delegateResolvedGetProxyImplementation() external { function test_delegateResolvedGetProxyImplementation_succeeds() external {
getProxyImplementation(payable(resolved)); getProxyImplementation(payable(resolved));
} }
...@@ -123,15 +123,15 @@ contract ProxyAdmin_Test is Test { ...@@ -123,15 +123,15 @@ contract ProxyAdmin_Test is Test {
} }
} }
function test_erc1967GetProxyAdmin() external { function test_erc1967GetProxyAdmin_succeeds() external {
getProxyAdmin(payable(proxy)); getProxyAdmin(payable(proxy));
} }
function test_chugsplashGetProxyAdmin() external { function test_chugsplashGetProxyAdmin_succeeds() external {
getProxyAdmin(payable(chugsplash)); getProxyAdmin(payable(chugsplash));
} }
function test_delegateResolvedGetProxyAdmin() external { function test_delegateResolvedGetProxyAdmin_succeeds() external {
getProxyAdmin(payable(resolved)); getProxyAdmin(payable(resolved));
} }
...@@ -140,15 +140,15 @@ contract ProxyAdmin_Test is Test { ...@@ -140,15 +140,15 @@ contract ProxyAdmin_Test is Test {
assertEq(owner, address(admin)); assertEq(owner, address(admin));
} }
function test_erc1967ChangeProxyAdmin() external { function test_erc1967ChangeProxyAdmin_succeeds() external {
changeProxyAdmin(payable(proxy)); changeProxyAdmin(payable(proxy));
} }
function test_chugsplashChangeProxyAdmin() external { function test_chugsplashChangeProxyAdmin_succeeds() external {
changeProxyAdmin(payable(chugsplash)); changeProxyAdmin(payable(chugsplash));
} }
function test_delegateResolvedChangeProxyAdmin() external { function test_delegateResolvedChangeProxyAdmin_succeeds() external {
changeProxyAdmin(payable(resolved)); changeProxyAdmin(payable(resolved));
} }
...@@ -188,15 +188,15 @@ contract ProxyAdmin_Test is Test { ...@@ -188,15 +188,15 @@ contract ProxyAdmin_Test is Test {
} }
} }
function test_erc1967Upgrade() external { function test_erc1967Upgrade_succeeds() external {
upgrade(payable(proxy)); upgrade(payable(proxy));
} }
function test_chugsplashUpgrade() external { function test_chugsplashUpgrade_succeeds() external {
upgrade(payable(chugsplash)); upgrade(payable(chugsplash));
} }
function test_delegateResolvedUpgrade() external { function test_delegateResolvedUpgrade_succeeds() external {
upgrade(payable(resolved)); upgrade(payable(resolved));
} }
...@@ -208,15 +208,15 @@ contract ProxyAdmin_Test is Test { ...@@ -208,15 +208,15 @@ contract ProxyAdmin_Test is Test {
assertEq(impl, address(implementation)); assertEq(impl, address(implementation));
} }
function test_erc1967UpgradeAndCall() external { function test_erc1967UpgradeAndCall_succeeds() external {
upgradeAndCall(payable(proxy)); upgradeAndCall(payable(proxy));
} }
function test_chugsplashUpgradeAndCall() external { function test_chugsplashUpgradeAndCall_succeeds() external {
upgradeAndCall(payable(chugsplash)); upgradeAndCall(payable(chugsplash));
} }
function test_delegateResolvedUpgradeAndCall() external { function test_delegateResolvedUpgradeAndCall_succeeds() external {
upgradeAndCall(payable(resolved)); upgradeAndCall(payable(resolved));
} }
...@@ -235,7 +235,7 @@ contract ProxyAdmin_Test is Test { ...@@ -235,7 +235,7 @@ contract ProxyAdmin_Test is Test {
assertEq(got, 1); assertEq(got, 1);
} }
function test_onlyOwner() external { function test_onlyOwner_notOwner_reverts() external {
vm.expectRevert("Ownable: caller is not the owner"); vm.expectRevert("Ownable: caller is not the owner");
admin.changeProxyAdmin(payable(proxy), address(0)); admin.changeProxyAdmin(payable(proxy), address(0));
...@@ -246,7 +246,7 @@ contract ProxyAdmin_Test is Test { ...@@ -246,7 +246,7 @@ contract ProxyAdmin_Test is Test {
admin.upgradeAndCall(payable(proxy), address(implementation), hex""); admin.upgradeAndCall(payable(proxy), address(implementation), hex"");
} }
function test_isUpgrading() external { function test_isUpgrading_succeeds() external {
assertEq(false, admin.isUpgrading()); assertEq(false, admin.isUpgrading());
vm.prank(alice); vm.prank(alice);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment