Skip to content

Conversation

jmakwana01
Copy link

Closes #50

Summary

The current tests for ContractImmutable check immutability indirectly by measuring deployment gas.
Since deployment gas can vary depending on the environment, this may cause the tests to fail even when value is correctly declared as immutable.

Changes

  • Updated the tests to confirm immutability by checking that value does not occupy a storage slot.
  • Used vm.load to verify that slot 0 is empty, while still asserting the correct runtime value.

Benefits

  • Makes the test more reliable and deterministic.
  • Directly verifies immutability in a way that is consistent with how Solidity compiles immutable variables.

Example

bytes32 slot0 = vm.load(address(contractImmutable), bytes32(uint256(0)));
assertEq(slot0, bytes32(0));
assertEq(contractImmutable.value(), 550);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests for ContractImmutable failing due to gas check — suggest immutability check instead

1 participant