Skip to content
Open
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
25 changes: 11 additions & 14 deletions Immutable/test/Immutable.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@ contract ContractImmutableTest is Test {
function setUp() public {}

function testContractImmutable() external {
uint256 startGas = gasleft();
contractImmutable = new ContractImmutable(10);
uint256 gasUsed = startGas - gasleft();

assertEq(contractImmutable.value(), 10, "expected value to be 10");

if (gasUsed < 90000) assertFalse(false);
else assertFalse(true);
bytes32 slot0 = vm.load(address(contractImmutable), bytes32(uint256(0)));
// since `value` is immutable, it won't be in storage
assertEq(slot0, bytes32(0));
assertEq(contractImmutable.value(), 10);
}

function testContractImmutable2() external {
uint256 startGas = gasleft();
contractImmutable = new ContractImmutable(550);
uint256 gasUsed = startGas - gasleft();

assertEq(contractImmutable.value(), 550, "expected value to be 550");
bytes32 slot0 = vm.load(address(contractImmutable), bytes32(uint256(0)));
// since `value` is immutable, it won't be in storage
assertEq(slot0, bytes32(0));
assertEq(contractImmutable.value(), 550);
}

if (gasUsed < 90000) assertFalse(false);
else assertFalse(true);

}
}