Skip to content

Commit

Permalink
Test with no initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Oct 26, 2023
1 parent b2955c8 commit 4549110
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/Upgrades.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {MyToken} from "./contracts/MyToken.sol";
import {MyTokenV2} from "./contracts/MyTokenV2.sol";
import {MyTokenProxiable} from "./contracts/MyTokenProxiable.sol";
import {MyTokenProxiableV2} from "./contracts/MyTokenProxiableV2.sol";
import {WithConstructor} from "./contracts/WithConstructor.sol";
import {WithConstructor, NoInitializer} from "./contracts/WithConstructor.sol";

contract UpgradesTest is Test {
address constant CHEATCODE_ADDRESS = 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D;
Expand Down Expand Up @@ -226,6 +226,13 @@ contract UpgradesTest is Test {
assertEq(WithConstructor(proxy).a(), 123);
assertEq(WithConstructor(proxy).b(), 456);
}

function testNoInitializer() public {
Options memory opts;
opts.constructorData = abi.encode(123);
address proxy = Upgrades.deployTransparentProxy("WithConstructor.sol:NoInitializer", msg.sender, "", opts);
assertEq(WithConstructor(proxy).a(), 123);
}
}

contract Validator {
Expand Down
10 changes: 10 additions & 0 deletions test/contracts/WithConstructor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ contract WithConstructor {
b = _b;
}
}

contract NoInitializer {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
uint256 public immutable a;

/// @custom:oz-upgrades-unsafe-allow constructor
constructor(uint256 _a) {
a = _a;
}
}

0 comments on commit 4549110

Please sign in to comment.