Skip to content

Commit

Permalink
Add upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
wshino committed Oct 16, 2024
1 parent 2b8f8a4 commit 0d317d3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/contracts/test/EmailAuth.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -492,4 +492,36 @@ contract EmailAuthTest is StructHelper {
vm.expectRevert("only controller");
emailAuth.setTimestampCheckEnabled(false);
}

function testUpgradeEmailAuth() public {
vm.startPrank(deployer);

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

// Execute upgrade using proxy
// Upgrade implementation through proxy contract
ERC1967Proxy proxy = new ERC1967Proxy(
address(emailAuth),
abi.encodeCall(
emailAuth.initialize,
(deployer, accountSalt, deployer)
)
);
EmailAuth emailAuthProxy = EmailAuth(payable(proxy));
bytes32 beforeAccountSalt = emailAuthProxy.accountSalt();

// Upgrade to new implementation through proxy
emailAuthProxy.upgradeToAndCall(
address(newImplementation),
new bytes(0)
);

bytes32 afterAccountSalt = emailAuthProxy.accountSalt();

// Verify the upgrade
assertEq(beforeAccountSalt, afterAccountSalt);

vm.stopPrank();
}
}

0 comments on commit 0d317d3

Please sign in to comment.