Skip to content

Commit

Permalink
Explicit checking of implementation slot
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenGround0 committed Jan 13, 2025
1 parent f28928b commit f487ecf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/ERC1967Proxy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,22 @@ contract ERC1967ProxyTest is Test {
assertEq(proxy.owner(), owner);
}

function assertImplementationEquals(address checkImpl) public view {
bytes32 implementationSlot = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
assertEq(address(uint160(uint256(vm.load(address(proxy), implementationSlot)))), address(checkImpl));
}

function testUpgradeImplementation() public {
assertImplementationEquals(address(implementation));

// Deploy new implementation
PDPVerifier newImplementation = new PDPVerifier();

// Upgrade proxy to new implementation
proxy.upgradeToAndCall(address(newImplementation), "");

// Verify upgrade was successful
assertImplementationEquals(address(newImplementation));
assertEq(proxy.getChallengeFinality(), 150); // State is preserved
assertEq(proxy.owner(), owner); // Owner is preserved
}
Expand Down Expand Up @@ -89,4 +97,4 @@ contract ERC1967ProxyTest is Test {
// Verify owner unchanged
assertEq(proxy.owner(), owner);
}
}
}

0 comments on commit f487ecf

Please sign in to comment.