Skip to content

Commit

Permalink
Repro for 9115
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy committed Nov 8, 2024
1 parent 414e8c1 commit 9d75fc2
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/GasReport.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {UnsafeUpgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";

import "forge-std/Test.sol";

contract CheapDeposit is Initializable, UUPSUpgradeable {
uint256 public amount;

function initialize(uint256 _amount) public initializer {
amount = _amount;
}

function _authorizeUpgrade(address newImplementation) internal override {}

function deposit(uint256 amount) external {
amount = amount * 2;
}
}

contract ExpensiveDeposit is Initializable, UUPSUpgradeable {
uint256 public amount;

function initialize(uint256 _amount) public initializer {
amount = _amount;
}

function _authorizeUpgrade(address newImplementation) internal override {}

function deposit(uint256 amount) external {
amount = amount * 10;
}
}

contract GasReportTest is Test {
function test_gas_report() public {
CheapDeposit cheap = CheapDeposit(
UnsafeUpgrades.deployUUPSProxy(
address(new CheapDeposit()),
abi.encodeCall(CheapDeposit.initialize, (600_000))
)
);
ExpensiveDeposit expensive = ExpensiveDeposit(
UnsafeUpgrades.deployUUPSProxy(
address(new ExpensiveDeposit()),
abi.encodeCall(ExpensiveDeposit.initialize, (600_000))
)
);
cheap.deposit(1);
expensive.deposit(1);
}
}

0 comments on commit 9d75fc2

Please sign in to comment.