Skip to content

Commit 704def2

Browse files
committed
successful tests for 1967 upgrades
1 parent dbeccde commit 704def2

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

remappings.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
smart-wallet/=lib/smart-wallet/src/
22
forge-std/=lib/forge-std/src/
3-
openzeppelin-contracts/=lib/openzeppelin-contracts/
3+
openzeppelin-contracts/=lib/openzeppelin-contracts/
4+
solady/=lib/solady/src/

test/EIP7702Proxy/upgradeToAndCall.t.sol

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity ^0.8.23;
44
import {EIP7702ProxyBase} from "../base/EIP7702ProxyBase.sol";
55
import {EIP7702Proxy} from "../../src/EIP7702Proxy.sol";
66
import {CoinbaseSmartWallet} from "../../lib/smart-wallet/src/CoinbaseSmartWallet.sol";
7-
import {UUPSUpgradeable} from "solady/src/utils/UUPSUpgradeable.sol";
7+
import {UUPSUpgradeable} from "solady/utils/UUPSUpgradeable.sol";
88

99
contract UpgradeToAndCallTest is EIP7702ProxyBase {
1010
DummyImplementation newImplementation;
@@ -22,8 +22,8 @@ contract UpgradeToAndCallTest is EIP7702ProxyBase {
2222
newImplementation = new DummyImplementation();
2323
}
2424

25-
function testUpgradeToAndCall() public {
26-
// Only owner should be able to upgrade
25+
function testUpgradeToAndCall_succeedsForOwner() public {
26+
// Wallet owner should be able to upgrade
2727
vm.prank(_newOwner);
2828

2929
CoinbaseSmartWallet(payable(_eoa)).upgradeToAndCall(
@@ -37,6 +37,21 @@ contract UpgradeToAndCallTest is EIP7702ProxyBase {
3737
DummyImplementation(payable(_eoa)).dummy();
3838
}
3939

40+
function testUpgradeToAndCall_succeedsForEOA() public {
41+
// EOA should be able to upgrade
42+
vm.prank(_eoa);
43+
44+
CoinbaseSmartWallet(payable(_eoa)).upgradeToAndCall(
45+
address(newImplementation),
46+
abi.encodeWithSignature("dummy()")
47+
);
48+
49+
// Verify upgrade worked by calling new function
50+
vm.expectEmit(true, true, true, true, _eoa);
51+
emit DummyImplementation.DummyCalled();
52+
DummyImplementation(payable(_eoa)).dummy();
53+
}
54+
4055
function testUpgradeToAndCallRevertsForNonOwner() public {
4156
vm.prank(address(0xBAD));
4257
vm.expectRevert(); // CoinbaseSmartWallet will revert for non-owner

0 commit comments

Comments
 (0)