My implementation is UUPS compatible, with the upgrade check being:
function _authorizeUpgrade(
address newImplementation
) internal override onlyRole(DEFAULT_ADMIN_ROLE) {}
Inside my foundry test, I have the setup and test case written:
function setUp() public {
address deployedAddress = Upgrades.deployUUPSProxy(
"PushLocker.sol",
abi.encodeCall(PushLocker.initialize, (admin))
);
locker = PushLocker(deployedAddress);
vm.deal(user, 100 ether);
vm.deal(funder, 100 ether);
}
//Test if upgrading works fine.
function test_Upgrade() public {
vm.prank(admin);// THIS DOESN'T WORK
Upgrades.upgradeProxy(address(locker), "PushLockerV2.sol", "");
lockerV2 = PushLockerV2(address(locker));
vm.prank(admin);
bool res = lockerV2.recoverToken(12);
assertTrue(res);
}
The problem is, when I use vm.prank(admin)
it doesn't really change the msg.sender, and this leads to the error:
[FAIL: AccessControlUnauthorizedAccount(0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496, 0x0000000000000000000000000000000000000000000000000000000000000000)] test_Upgrade() (gas: 18272739)
There's no problem while running the deployment scripts. In scripts the msg.sender is the wallet I specify, but this doesn't seem to be the case inside the test file.
What is the way to specify msg.sender
when deploying/upgrading proxies using OZ upgrades?