Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add UpgradeToAndCall test #26

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 44 additions & 42 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
AddOwnerAddressTest:testEmitsAddOwner() (gas: 92330)
AddOwnerAddressTest:testIncreasesOwnerIndex() (gas: 90548)
AddOwnerAddressTest:testRevertsIfAlreadyOwner() (gas: 93093)
AddOwnerAddressTest:testRevertsIfCalledByNonOwner() (gas: 11732)
AddOwnerAddressTest:testSetsIsOwner() (gas: 90432)
AddOwnerAddressTest:testSetsOwnerAtIndex() (gas: 98831)
AddOwnerPublicKeyTest:testEmitsAddOwner() (gas: 115377)
AddOwnerPublicKeyTest:testRevertsIfAlreadyOwner() (gas: 116169)
AddOwnerPublicKeyTest:testRevertsIfCalledByNonOwner() (gas: 11656)
AddOwnerPublicKeyTest:testSetsIsOwner() (gas: 113698)
AddOwnerPublicKeyTest:testSetsOwnerAtIndex() (gas: 128444)
CoinbaseSmartWallet1271InputGeneratorTest:testGetReplaySafeHashForDeployedAccount() (gas: 308642)
CoinbaseSmartWallet1271InputGeneratorTest:testGetReplaySafeHashForUndeployedAccount() (gas: 291413)
CoinbaseSmartWalletFactoryTest:testDeployDeterministicPassValues() (gas: 267720)
CoinbaseSmartWalletFactoryTest:test_CreateAccount_ReturnsPredeterminedAddress_WhenAccountAlreadyExists() (gas: 287384)
CoinbaseSmartWalletFactoryTest:test_createAccountDeploysToPredeterminedAddress() (gas: 269071)
CoinbaseSmartWalletFactoryTest:test_createAccountSetsOwnersCorrectly() (gas: 277937)
AddOwnerAddressTest:testEmitsAddOwner() (gas: 92374)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some gas noise here from using the latest forge version

AddOwnerAddressTest:testIncreasesOwnerIndex() (gas: 90614)
AddOwnerAddressTest:testRevertsIfAlreadyOwner() (gas: 93137)
AddOwnerAddressTest:testRevertsIfCalledByNonOwner() (gas: 11754)
AddOwnerAddressTest:testSetsIsOwner() (gas: 90476)
AddOwnerAddressTest:testSetsOwnerAtIndex() (gas: 98897)
AddOwnerPublicKeyTest:testEmitsAddOwner() (gas: 115509)
AddOwnerPublicKeyTest:testFuzzIsOwnerPublicKey(bytes32,bytes32) (runs: 256, μ: 115333, ~: 115333)
AddOwnerPublicKeyTest:testRevertsIfAlreadyOwner() (gas: 116301)
AddOwnerPublicKeyTest:testRevertsIfCalledByNonOwner() (gas: 11744)
AddOwnerPublicKeyTest:testSetsIsOwner() (gas: 113775)
AddOwnerPublicKeyTest:testSetsOwnerAtIndex() (gas: 128543)
CoinbaseSmartWallet1271InputGeneratorTest:testGetReplaySafeHashForDeployedAccount() (gas: 308664)
CoinbaseSmartWallet1271InputGeneratorTest:testGetReplaySafeHashForUndeployedAccount() (gas: 291435)
CoinbaseSmartWalletFactoryTest:testDeployDeterministicPassValues() (gas: 267742)
CoinbaseSmartWalletFactoryTest:test_CreateAccount_ReturnsPredeterminedAddress_WhenAccountAlreadyExists() (gas: 287406)
CoinbaseSmartWalletFactoryTest:test_createAccountDeploysToPredeterminedAddress() (gas: 269093)
CoinbaseSmartWalletFactoryTest:test_createAccountSetsOwnersCorrectly() (gas: 277981)
CoinbaseSmartWalletFactoryTest:test_revertsIfNoOwners() (gas: 29214)
ERC1271Test:test_returnsExpectedDomainHashWhenProxy() (gas: 15384)
MultiOwnableInitializeTest:testRevertsIfLength32ButLargerThanAddress() (gas: 78994)
MultiOwnableInitializeTest:testRevertsIfLength32NotAddress() (gas: 78975)
MultiOwnableInitializeTest:testRevertsIfLengthNot32Or64() (gas: 101278)
RemoveOwnerAtIndexTest:testEmitsRemoveOwner() (gas: 33281)
RemoveOwnerAtIndexTest:testRemovesOwner() (gas: 32647)
RemoveOwnerAtIndexTest:testRemovesOwnerAtIndex() (gas: 27532)
RemoveOwnerAtIndexTest:testRevertsIfCalledByNonOwner() (gas: 11310)
RemoveOwnerAtIndexTest:testRevertsIfNoOwnerAtIndex() (gas: 16626)
TestCanSkipChainIdValidation:test_approvedSelectorsReturnTrue() (gas: 15889)
TestCanSkipChainIdValidation:test_otherSelectorsReturnFalse() (gas: 12491)
TestExecuteWithoutChainIdValidation:testExecute() (gas: 424683)
TestExecuteWithoutChainIdValidation:testExecuteBatch() (gas: 729020)
TestExecuteWithoutChainIdValidation:testExecuteBatch(uint256) (runs: 256, μ: 3376320, ~: 3249240)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 48858)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 49093)
ERC1271Test:test_returnsExpectedDomainHashWhenProxy() (gas: 15406)
MultiOwnableInitializeTest:testRevertsIfLength32ButLargerThanAddress() (gas: 78927)
MultiOwnableInitializeTest:testRevertsIfLength32NotAddress() (gas: 78908)
MultiOwnableInitializeTest:testRevertsIfLengthNot32Or64() (gas: 101211)
RemoveOwnerAtIndexTest:testEmitsRemoveOwner() (gas: 33299)
RemoveOwnerAtIndexTest:testRemovesOwner() (gas: 32682)
RemoveOwnerAtIndexTest:testRemovesOwnerAtIndex() (gas: 27567)
RemoveOwnerAtIndexTest:testRevertsIfCalledByNonOwner() (gas: 11332)
RemoveOwnerAtIndexTest:testRevertsIfNoOwnerAtIndex() (gas: 16648)
TestCanSkipChainIdValidation:test_approvedSelectorsReturnTrue() (gas: 15845)
TestCanSkipChainIdValidation:test_otherSelectorsReturnFalse() (gas: 12469)
TestExecuteWithoutChainIdValidation:testExecute() (gas: 424705)
TestExecuteWithoutChainIdValidation:testExecuteBatch() (gas: 729086)
TestExecuteWithoutChainIdValidation:testExecuteBatch(uint256) (runs: 256, μ: 3409748, ~: 3278930)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 49006)
TestExecuteWithoutChainIdValidation:test__codesize() (gas: 49241)
TestExecuteWithoutChainIdValidation:test_canChangeOwnerWithoutChainId() (gas: 287917)
TestExecuteWithoutChainIdValidation:test_cannotCallExec() (gas: 220047)
TestExecuteWithoutChainIdValidation:test_revertsIfCallerNotEntryPoint() (gas: 8620)
TestExecuteWithoutChainIdValidation:test_revertsIfWrongNonceKey() (gas: 62275)
TestExecuteWithoutChainIdValidation:test_revertsWithReservedNonce() (gas: 82302)
TestInitialize:testInitialize() (gas: 21122)
TestInitialize:test_cannotInitImplementation() (gas: 2678562)
TestIsValidSignature:testReturnsInvalidIfPasskeySigButWrongOwnerLength() (gas: 39464)
TestIsValidSignature:testRevertsIfEthereumSignatureButWrongOwnerLength() (gas: 24046)
TestIsValidSignature:testSmartWalletSigner() (gas: 2951388)
TestIsValidSignature:testValidateSignatureWithEOASigner() (gas: 24917)
TestIsValidSignature:testValidateSignatureWithEOASignerFailsWithWrongSigner() (gas: 23847)
TestIsValidSignature:testValidateSignatureWithPasskeySigner() (gas: 421251)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsBadOwnerIndex() (gas: 34964)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsWithWrongBadSignature() (gas: 428717)
TestInitialize:test_cannotInitImplementation() (gas: 2708253)
TestIsValidSignature:testReturnsInvalidIfPasskeySigButWrongOwnerLength() (gas: 39497)
TestIsValidSignature:testRevertsIfEthereumSignatureButWrongOwnerLength() (gas: 24068)
TestIsValidSignature:testSmartWalletSigner() (gas: 2981137)
TestIsValidSignature:testValidateSignatureWithEOASigner() (gas: 24950)
TestIsValidSignature:testValidateSignatureWithEOASignerFailsWithWrongSigner() (gas: 23880)
TestIsValidSignature:testValidateSignatureWithPasskeySigner() (gas: 421284)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsBadOwnerIndex() (gas: 34986)
TestIsValidSignature:testValidateSignatureWithPasskeySignerFailsWithWrongBadSignature() (gas: 428750)
TestUpgradeToAndCall:testUpgradeToAndCall() (gas: 23839)
TestValidateUserOp:testValidateUserOp() (gas: 447113)
31 changes: 31 additions & 0 deletions test/CoinbaseSmartWallet/UpgradeToAndCall.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {CoinbaseSmartWalletFactory} from "../../src/CoinbaseSmartWalletFactory.sol";

import "./SmartWalletTestBase.sol";

contract TestUpgradeToAndCall is SmartWalletTestBase {
address newImplementation = address(new Dummy());

function setUp() public override {
super.setUp();
CoinbaseSmartWalletFactory factory = new CoinbaseSmartWalletFactory(address(new CoinbaseSmartWallet()));
account = factory.createAccount(owners, 1);
vm.startPrank(signer);
}

function testUpgradeToAndCall() public {
account.upgradeToAndCall(newImplementation, abi.encodeWithSignature("dummy()"));
}
}

contract Dummy is UUPSUpgradeable {
event Done();

function dummy() public {
emit Done();
}

function _authorizeUpgrade(address newImplementation) internal override {}
}