|
1 | 1 | // SPDX-License-Identifier: Apache-2.0 OR MIT |
2 | 2 | pragma solidity ^0.8.36; |
3 | 3 |
|
4 | | -import {Example} from "./Example.sol"; |
5 | 4 | import {Test} from "forge-std/Test.sol"; |
6 | 5 |
|
7 | | -contract ConstructorProbe { |
8 | | - address public immutable deployedAt; |
9 | | - address public immutable constructorCaller; |
10 | | - uint256 public immutable constructorValue; |
11 | | - uint256 public storedValue; |
12 | | - |
13 | | - constructor(uint256 value) payable { |
14 | | - deployedAt = address(this); |
15 | | - constructorCaller = msg.sender; |
16 | | - constructorValue = msg.value; |
17 | | - storedValue = value; |
18 | | - } |
19 | | -} |
20 | | - |
21 | | -contract RevertingConstructor { |
22 | | - error ExpectedRevert(uint256 value); |
23 | | - |
24 | | - constructor() { |
25 | | - revert ExpectedRevert(42); |
26 | | - } |
27 | | -} |
| 6 | +import {ConstructorProbe} from "./ConstructorProbe.sol"; |
| 7 | +import {Example} from "./Example.sol"; |
| 8 | +import {RevertingConstructor} from "./RevertingConstructor.sol"; |
28 | 9 |
|
29 | 10 | contract InitTest is Test { |
30 | 11 | bytes constant INIT_CODE = hex"385f5f5f335afa5f5f5f5f5f515af43d5f5f3e16601a573d5ffd5b3d5ff30000"; |
@@ -57,13 +38,13 @@ contract InitTest is Test { |
57 | 38 |
|
58 | 39 | (bool success, bytes memory returned) = init.call{value: 7}(""); |
59 | 40 | assertTrue(success); |
60 | | - assertGt(returned.length, 0); |
| 41 | + assertEq(returned.length, vm.getDeployedCode("ConstructorProbe").length); |
61 | 42 |
|
62 | 43 | vm.etch(init, returned); |
63 | 44 | ConstructorProbe probe = ConstructorProbe(init); |
64 | | - assertEq(probe.deployedAt(), init); |
65 | | - assertEq(probe.constructorCaller(), address(this)); |
66 | | - assertEq(probe.constructorValue(), 7); |
| 45 | + assertEq(probe.DEPLOYED_AT(), init); |
| 46 | + assertEq(probe.CALLER(), address(this)); |
| 47 | + assertEq(probe.CALLVALUE(), 7); |
67 | 48 | assertEq(probe.storedValue(), 42); |
68 | 49 | } |
69 | 50 |
|
|
0 commit comments