diff --git a/lib/forge-std b/lib/forge-std index ae570fec082..07263d193d6 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit ae570fec082bfe1c1f45b0acca4a2b4f84d345ce +Subproject commit 07263d193d621c4b2b0ce8b4d54af58f6957d97d diff --git a/scripts/generate/templates/Checkpoints.t.js b/scripts/generate/templates/Checkpoints.t.js index dd564e59bdd..09942c9f2f8 100644 --- a/scripts/generate/templates/Checkpoints.t.js +++ b/scripts/generate/templates/Checkpoints.t.js @@ -37,7 +37,7 @@ function _prepareKeys(${opts.keyTypeName}[] memory keys, ${opts.keyTypeName} max } } -function _assertLatestCheckpoint(bool exist, ${opts.keyTypeName} key, ${opts.valueTypeName} value) internal { +function _assertLatestCheckpoint(bool exist, ${opts.keyTypeName} key, ${opts.valueTypeName} value) internal view { (bool _exist, ${opts.keyTypeName} _key, ${opts.valueTypeName} _value) = _ckpts.latestCheckpoint(); assertEq(_exist, exist); assertEq(_key, key); diff --git a/scripts/generate/templates/Packing.t.js b/scripts/generate/templates/Packing.t.js index 56e9c0cc7c4..1feec28f5a5 100644 --- a/scripts/generate/templates/Packing.t.js +++ b/scripts/generate/templates/Packing.t.js @@ -11,14 +11,14 @@ import {Packing} from "@openzeppelin/contracts/utils/Packing.sol"; `; const testPack = (left, right) => `\ -function testPack(bytes${left} left, bytes${right} right) external { +function testPack(bytes${left} left, bytes${right} right) external pure { assertEq(left, Packing.pack_${left}_${right}(left, right).extract_${left + right}_${left}(0)); assertEq(right, Packing.pack_${left}_${right}(left, right).extract_${left + right}_${right}(${left})); } `; const testReplace = (outer, inner) => `\ -function testReplace(bytes${outer} container, bytes${inner} newValue, uint8 offset) external { +function testReplace(bytes${outer} container, bytes${inner} newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, ${outer - inner})); bytes${inner} oldValue = container.extract_${outer}_${inner}(offset); diff --git a/scripts/generate/templates/SlotDerivation.t.js b/scripts/generate/templates/SlotDerivation.t.js index f03e1fc2598..824af079a14 100644 --- a/scripts/generate/templates/SlotDerivation.t.js +++ b/scripts/generate/templates/SlotDerivation.t.js @@ -45,7 +45,7 @@ function _assertDeriveArray(uint256 length, uint256 offset) public { const mapping = ({ type, name }) => `\ mapping(${type} => bytes) private _${type}Mapping; -function testSymbolicDeriveMapping${name}(${type} key) public { +function testSymbolicDeriveMapping${name}(${type} key) public view { bytes32 baseSlot; assembly { baseSlot := _${type}Mapping.slot @@ -76,15 +76,15 @@ function testSymbolicDeriveMapping${name}Dirty(bytes32 dirtyKey) public { const boundedMapping = ({ type, name }) => `\ mapping(${type} => bytes) private _${type}Mapping; -function testDeriveMapping${name}(${type} memory key) public { +function testDeriveMapping${name}(${type} memory key) public view { _assertDeriveMapping${name}(key); } -function symbolicDeriveMapping${name}() public { +function symbolicDeriveMapping${name}() public view { _assertDeriveMapping${name}(svm.create${name}(256, "DeriveMapping${name}Input")); } -function _assertDeriveMapping${name}(${type} memory key) internal { +function _assertDeriveMapping${name}(${type} memory key) internal view { bytes32 baseSlot; assembly { baseSlot := _${type}Mapping.slot diff --git a/test/governance/Governor.t.sol b/test/governance/Governor.t.sol index 958461abb95..66b684d26e4 100644 --- a/test/governance/Governor.t.sol +++ b/test/governance/Governor.t.sol @@ -9,7 +9,11 @@ import {Governor} from "@openzeppelin/contracts/governance/Governor.sol"; contract GovernorInternalTest is Test, Governor { constructor() Governor("") {} - function testValidDescriptionForProposer(string memory description, address proposer, bool includeProposer) public { + function testValidDescriptionForProposer( + string memory description, + address proposer, + bool includeProposer + ) public view { if (includeProposer) { description = string.concat(description, "#proposer=", Strings.toHexString(proposer)); } @@ -20,7 +24,7 @@ contract GovernorInternalTest is Test, Governor { string memory description, address commitProposer, address actualProposer - ) public { + ) public view { vm.assume(commitProposer != actualProposer); description = string.concat(description, "#proposer=", Strings.toHexString(commitProposer)); assertFalse(_isValidDescriptionForProposer(actualProposer, description)); diff --git a/test/proxy/Clones.t.sol b/test/proxy/Clones.t.sol index e589ba90678..19c899c3e53 100644 --- a/test/proxy/Clones.t.sol +++ b/test/proxy/Clones.t.sol @@ -10,7 +10,7 @@ contract ClonesTest is Test { return 42; } - function testSymbolicPredictDeterministicAddressSpillage(address implementation, bytes32 salt) public { + function testSymbolicPredictDeterministicAddressSpillage(address implementation, bytes32 salt) public view { address predicted = Clones.predictDeterministicAddress(implementation, salt); bytes32 spillage; assembly ("memory-safe") { @@ -59,7 +59,7 @@ contract ClonesTest is Test { assertEq(ClonesTest(cloneDirty).getNumber(), this.getNumber()); } - function testPredictDeterministicAddressDirty(bytes32 salt) external { + function testPredictDeterministicAddressDirty(bytes32 salt) external view { address predictClean = Clones.predictDeterministicAddress(address(this), salt); address predictDirty = Clones.predictDeterministicAddress(_dirty(address(this)), salt); diff --git a/test/utils/Arrays.t.sol b/test/utils/Arrays.t.sol index 09c7b66b6d6..e45d29c919d 100644 --- a/test/utils/Arrays.t.sol +++ b/test/utils/Arrays.t.sol @@ -7,12 +7,12 @@ import {SymTest} from "halmos-cheatcodes/SymTest.sol"; import {Arrays} from "@openzeppelin/contracts/utils/Arrays.sol"; contract ArraysTest is Test, SymTest { - function testSort(uint256[] memory values) public { + function testSort(uint256[] memory values) public pure { Arrays.sort(values); _assertSort(values); } - function symbolicSort() public { + function symbolicSort() public pure { uint256[] memory values = new uint256[](3); for (uint256 i = 0; i < 3; i++) { values[i] = svm.createUint256("arrayElement"); @@ -23,7 +23,7 @@ contract ArraysTest is Test, SymTest { /// Asserts - function _assertSort(uint256[] memory values) internal { + function _assertSort(uint256[] memory values) internal pure { for (uint256 i = 1; i < values.length; ++i) { assertLe(values[i - 1], values[i]); } diff --git a/test/utils/Base64.t.sol b/test/utils/Base64.t.sol index 021ae03af09..b8aa7ac6121 100644 --- a/test/utils/Base64.t.sol +++ b/test/utils/Base64.t.sol @@ -6,11 +6,11 @@ import {Test} from "forge-std/Test.sol"; import {Base64} from "@openzeppelin/contracts/utils/Base64.sol"; contract Base64Test is Test { - function testEncode(bytes memory input) external { + function testEncode(bytes memory input) external pure { assertEq(Base64.encode(input), vm.toBase64(input)); } - function testEncodeURL(bytes memory input) external { + function testEncodeURL(bytes memory input) external pure { assertEq(Base64.encodeURL(input), _removePadding(vm.toBase64URL(input))); } diff --git a/test/utils/Create2.t.sol b/test/utils/Create2.t.sol index 6cc037a3b3b..b73db9f9a25 100644 --- a/test/utils/Create2.t.sol +++ b/test/utils/Create2.t.sol @@ -6,7 +6,7 @@ import {Test} from "forge-std/Test.sol"; import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; contract Create2Test is Test { - function testSymbolicComputeAddressSpillage(bytes32 salt, bytes32 bytecodeHash, address deployer) public { + function testSymbolicComputeAddressSpillage(bytes32 salt, bytes32 bytecodeHash, address deployer) public pure { address predicted = Create2.computeAddress(salt, bytecodeHash, deployer); bytes32 spillage; assembly ("memory-safe") { diff --git a/test/utils/Packing.t.sol b/test/utils/Packing.t.sol index 9531f1bffbb..8f4b03cf60d 100644 --- a/test/utils/Packing.t.sol +++ b/test/utils/Packing.t.sol @@ -9,182 +9,182 @@ import {Packing} from "@openzeppelin/contracts/utils/Packing.sol"; contract PackingTest is Test { using Packing for *; - function testPack(bytes1 left, bytes1 right) external { + function testPack(bytes1 left, bytes1 right) external pure { assertEq(left, Packing.pack_1_1(left, right).extract_2_1(0)); assertEq(right, Packing.pack_1_1(left, right).extract_2_1(1)); } - function testPack(bytes2 left, bytes2 right) external { + function testPack(bytes2 left, bytes2 right) external pure { assertEq(left, Packing.pack_2_2(left, right).extract_4_2(0)); assertEq(right, Packing.pack_2_2(left, right).extract_4_2(2)); } - function testPack(bytes2 left, bytes4 right) external { + function testPack(bytes2 left, bytes4 right) external pure { assertEq(left, Packing.pack_2_4(left, right).extract_6_2(0)); assertEq(right, Packing.pack_2_4(left, right).extract_6_4(2)); } - function testPack(bytes2 left, bytes6 right) external { + function testPack(bytes2 left, bytes6 right) external pure { assertEq(left, Packing.pack_2_6(left, right).extract_8_2(0)); assertEq(right, Packing.pack_2_6(left, right).extract_8_6(2)); } - function testPack(bytes4 left, bytes2 right) external { + function testPack(bytes4 left, bytes2 right) external pure { assertEq(left, Packing.pack_4_2(left, right).extract_6_4(0)); assertEq(right, Packing.pack_4_2(left, right).extract_6_2(4)); } - function testPack(bytes4 left, bytes4 right) external { + function testPack(bytes4 left, bytes4 right) external pure { assertEq(left, Packing.pack_4_4(left, right).extract_8_4(0)); assertEq(right, Packing.pack_4_4(left, right).extract_8_4(4)); } - function testPack(bytes4 left, bytes8 right) external { + function testPack(bytes4 left, bytes8 right) external pure { assertEq(left, Packing.pack_4_8(left, right).extract_12_4(0)); assertEq(right, Packing.pack_4_8(left, right).extract_12_8(4)); } - function testPack(bytes4 left, bytes12 right) external { + function testPack(bytes4 left, bytes12 right) external pure { assertEq(left, Packing.pack_4_12(left, right).extract_16_4(0)); assertEq(right, Packing.pack_4_12(left, right).extract_16_12(4)); } - function testPack(bytes4 left, bytes16 right) external { + function testPack(bytes4 left, bytes16 right) external pure { assertEq(left, Packing.pack_4_16(left, right).extract_20_4(0)); assertEq(right, Packing.pack_4_16(left, right).extract_20_16(4)); } - function testPack(bytes4 left, bytes20 right) external { + function testPack(bytes4 left, bytes20 right) external pure { assertEq(left, Packing.pack_4_20(left, right).extract_24_4(0)); assertEq(right, Packing.pack_4_20(left, right).extract_24_20(4)); } - function testPack(bytes4 left, bytes24 right) external { + function testPack(bytes4 left, bytes24 right) external pure { assertEq(left, Packing.pack_4_24(left, right).extract_28_4(0)); assertEq(right, Packing.pack_4_24(left, right).extract_28_24(4)); } - function testPack(bytes4 left, bytes28 right) external { + function testPack(bytes4 left, bytes28 right) external pure { assertEq(left, Packing.pack_4_28(left, right).extract_32_4(0)); assertEq(right, Packing.pack_4_28(left, right).extract_32_28(4)); } - function testPack(bytes6 left, bytes2 right) external { + function testPack(bytes6 left, bytes2 right) external pure { assertEq(left, Packing.pack_6_2(left, right).extract_8_6(0)); assertEq(right, Packing.pack_6_2(left, right).extract_8_2(6)); } - function testPack(bytes6 left, bytes6 right) external { + function testPack(bytes6 left, bytes6 right) external pure { assertEq(left, Packing.pack_6_6(left, right).extract_12_6(0)); assertEq(right, Packing.pack_6_6(left, right).extract_12_6(6)); } - function testPack(bytes8 left, bytes4 right) external { + function testPack(bytes8 left, bytes4 right) external pure { assertEq(left, Packing.pack_8_4(left, right).extract_12_8(0)); assertEq(right, Packing.pack_8_4(left, right).extract_12_4(8)); } - function testPack(bytes8 left, bytes8 right) external { + function testPack(bytes8 left, bytes8 right) external pure { assertEq(left, Packing.pack_8_8(left, right).extract_16_8(0)); assertEq(right, Packing.pack_8_8(left, right).extract_16_8(8)); } - function testPack(bytes8 left, bytes12 right) external { + function testPack(bytes8 left, bytes12 right) external pure { assertEq(left, Packing.pack_8_12(left, right).extract_20_8(0)); assertEq(right, Packing.pack_8_12(left, right).extract_20_12(8)); } - function testPack(bytes8 left, bytes16 right) external { + function testPack(bytes8 left, bytes16 right) external pure { assertEq(left, Packing.pack_8_16(left, right).extract_24_8(0)); assertEq(right, Packing.pack_8_16(left, right).extract_24_16(8)); } - function testPack(bytes8 left, bytes20 right) external { + function testPack(bytes8 left, bytes20 right) external pure { assertEq(left, Packing.pack_8_20(left, right).extract_28_8(0)); assertEq(right, Packing.pack_8_20(left, right).extract_28_20(8)); } - function testPack(bytes8 left, bytes24 right) external { + function testPack(bytes8 left, bytes24 right) external pure { assertEq(left, Packing.pack_8_24(left, right).extract_32_8(0)); assertEq(right, Packing.pack_8_24(left, right).extract_32_24(8)); } - function testPack(bytes12 left, bytes4 right) external { + function testPack(bytes12 left, bytes4 right) external pure { assertEq(left, Packing.pack_12_4(left, right).extract_16_12(0)); assertEq(right, Packing.pack_12_4(left, right).extract_16_4(12)); } - function testPack(bytes12 left, bytes8 right) external { + function testPack(bytes12 left, bytes8 right) external pure { assertEq(left, Packing.pack_12_8(left, right).extract_20_12(0)); assertEq(right, Packing.pack_12_8(left, right).extract_20_8(12)); } - function testPack(bytes12 left, bytes12 right) external { + function testPack(bytes12 left, bytes12 right) external pure { assertEq(left, Packing.pack_12_12(left, right).extract_24_12(0)); assertEq(right, Packing.pack_12_12(left, right).extract_24_12(12)); } - function testPack(bytes12 left, bytes16 right) external { + function testPack(bytes12 left, bytes16 right) external pure { assertEq(left, Packing.pack_12_16(left, right).extract_28_12(0)); assertEq(right, Packing.pack_12_16(left, right).extract_28_16(12)); } - function testPack(bytes12 left, bytes20 right) external { + function testPack(bytes12 left, bytes20 right) external pure { assertEq(left, Packing.pack_12_20(left, right).extract_32_12(0)); assertEq(right, Packing.pack_12_20(left, right).extract_32_20(12)); } - function testPack(bytes16 left, bytes4 right) external { + function testPack(bytes16 left, bytes4 right) external pure { assertEq(left, Packing.pack_16_4(left, right).extract_20_16(0)); assertEq(right, Packing.pack_16_4(left, right).extract_20_4(16)); } - function testPack(bytes16 left, bytes8 right) external { + function testPack(bytes16 left, bytes8 right) external pure { assertEq(left, Packing.pack_16_8(left, right).extract_24_16(0)); assertEq(right, Packing.pack_16_8(left, right).extract_24_8(16)); } - function testPack(bytes16 left, bytes12 right) external { + function testPack(bytes16 left, bytes12 right) external pure { assertEq(left, Packing.pack_16_12(left, right).extract_28_16(0)); assertEq(right, Packing.pack_16_12(left, right).extract_28_12(16)); } - function testPack(bytes16 left, bytes16 right) external { + function testPack(bytes16 left, bytes16 right) external pure { assertEq(left, Packing.pack_16_16(left, right).extract_32_16(0)); assertEq(right, Packing.pack_16_16(left, right).extract_32_16(16)); } - function testPack(bytes20 left, bytes4 right) external { + function testPack(bytes20 left, bytes4 right) external pure { assertEq(left, Packing.pack_20_4(left, right).extract_24_20(0)); assertEq(right, Packing.pack_20_4(left, right).extract_24_4(20)); } - function testPack(bytes20 left, bytes8 right) external { + function testPack(bytes20 left, bytes8 right) external pure { assertEq(left, Packing.pack_20_8(left, right).extract_28_20(0)); assertEq(right, Packing.pack_20_8(left, right).extract_28_8(20)); } - function testPack(bytes20 left, bytes12 right) external { + function testPack(bytes20 left, bytes12 right) external pure { assertEq(left, Packing.pack_20_12(left, right).extract_32_20(0)); assertEq(right, Packing.pack_20_12(left, right).extract_32_12(20)); } - function testPack(bytes24 left, bytes4 right) external { + function testPack(bytes24 left, bytes4 right) external pure { assertEq(left, Packing.pack_24_4(left, right).extract_28_24(0)); assertEq(right, Packing.pack_24_4(left, right).extract_28_4(24)); } - function testPack(bytes24 left, bytes8 right) external { + function testPack(bytes24 left, bytes8 right) external pure { assertEq(left, Packing.pack_24_8(left, right).extract_32_24(0)); assertEq(right, Packing.pack_24_8(left, right).extract_32_8(24)); } - function testPack(bytes28 left, bytes4 right) external { + function testPack(bytes28 left, bytes4 right) external pure { assertEq(left, Packing.pack_28_4(left, right).extract_32_28(0)); assertEq(right, Packing.pack_28_4(left, right).extract_32_4(28)); } - function testReplace(bytes2 container, bytes1 newValue, uint8 offset) external { + function testReplace(bytes2 container, bytes1 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 1)); bytes1 oldValue = container.extract_2_1(offset); @@ -193,7 +193,7 @@ contract PackingTest is Test { assertEq(container, container.replace_2_1(newValue, offset).replace_2_1(oldValue, offset)); } - function testReplace(bytes4 container, bytes1 newValue, uint8 offset) external { + function testReplace(bytes4 container, bytes1 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 3)); bytes1 oldValue = container.extract_4_1(offset); @@ -202,7 +202,7 @@ contract PackingTest is Test { assertEq(container, container.replace_4_1(newValue, offset).replace_4_1(oldValue, offset)); } - function testReplace(bytes4 container, bytes2 newValue, uint8 offset) external { + function testReplace(bytes4 container, bytes2 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 2)); bytes2 oldValue = container.extract_4_2(offset); @@ -211,7 +211,7 @@ contract PackingTest is Test { assertEq(container, container.replace_4_2(newValue, offset).replace_4_2(oldValue, offset)); } - function testReplace(bytes6 container, bytes1 newValue, uint8 offset) external { + function testReplace(bytes6 container, bytes1 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 5)); bytes1 oldValue = container.extract_6_1(offset); @@ -220,7 +220,7 @@ contract PackingTest is Test { assertEq(container, container.replace_6_1(newValue, offset).replace_6_1(oldValue, offset)); } - function testReplace(bytes6 container, bytes2 newValue, uint8 offset) external { + function testReplace(bytes6 container, bytes2 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 4)); bytes2 oldValue = container.extract_6_2(offset); @@ -229,7 +229,7 @@ contract PackingTest is Test { assertEq(container, container.replace_6_2(newValue, offset).replace_6_2(oldValue, offset)); } - function testReplace(bytes6 container, bytes4 newValue, uint8 offset) external { + function testReplace(bytes6 container, bytes4 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 2)); bytes4 oldValue = container.extract_6_4(offset); @@ -238,7 +238,7 @@ contract PackingTest is Test { assertEq(container, container.replace_6_4(newValue, offset).replace_6_4(oldValue, offset)); } - function testReplace(bytes8 container, bytes1 newValue, uint8 offset) external { + function testReplace(bytes8 container, bytes1 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 7)); bytes1 oldValue = container.extract_8_1(offset); @@ -247,7 +247,7 @@ contract PackingTest is Test { assertEq(container, container.replace_8_1(newValue, offset).replace_8_1(oldValue, offset)); } - function testReplace(bytes8 container, bytes2 newValue, uint8 offset) external { + function testReplace(bytes8 container, bytes2 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 6)); bytes2 oldValue = container.extract_8_2(offset); @@ -256,7 +256,7 @@ contract PackingTest is Test { assertEq(container, container.replace_8_2(newValue, offset).replace_8_2(oldValue, offset)); } - function testReplace(bytes8 container, bytes4 newValue, uint8 offset) external { + function testReplace(bytes8 container, bytes4 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 4)); bytes4 oldValue = container.extract_8_4(offset); @@ -265,7 +265,7 @@ contract PackingTest is Test { assertEq(container, container.replace_8_4(newValue, offset).replace_8_4(oldValue, offset)); } - function testReplace(bytes8 container, bytes6 newValue, uint8 offset) external { + function testReplace(bytes8 container, bytes6 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 2)); bytes6 oldValue = container.extract_8_6(offset); @@ -274,7 +274,7 @@ contract PackingTest is Test { assertEq(container, container.replace_8_6(newValue, offset).replace_8_6(oldValue, offset)); } - function testReplace(bytes12 container, bytes1 newValue, uint8 offset) external { + function testReplace(bytes12 container, bytes1 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 11)); bytes1 oldValue = container.extract_12_1(offset); @@ -283,7 +283,7 @@ contract PackingTest is Test { assertEq(container, container.replace_12_1(newValue, offset).replace_12_1(oldValue, offset)); } - function testReplace(bytes12 container, bytes2 newValue, uint8 offset) external { + function testReplace(bytes12 container, bytes2 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 10)); bytes2 oldValue = container.extract_12_2(offset); @@ -292,7 +292,7 @@ contract PackingTest is Test { assertEq(container, container.replace_12_2(newValue, offset).replace_12_2(oldValue, offset)); } - function testReplace(bytes12 container, bytes4 newValue, uint8 offset) external { + function testReplace(bytes12 container, bytes4 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 8)); bytes4 oldValue = container.extract_12_4(offset); @@ -301,7 +301,7 @@ contract PackingTest is Test { assertEq(container, container.replace_12_4(newValue, offset).replace_12_4(oldValue, offset)); } - function testReplace(bytes12 container, bytes6 newValue, uint8 offset) external { + function testReplace(bytes12 container, bytes6 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 6)); bytes6 oldValue = container.extract_12_6(offset); @@ -310,7 +310,7 @@ contract PackingTest is Test { assertEq(container, container.replace_12_6(newValue, offset).replace_12_6(oldValue, offset)); } - function testReplace(bytes12 container, bytes8 newValue, uint8 offset) external { + function testReplace(bytes12 container, bytes8 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 4)); bytes8 oldValue = container.extract_12_8(offset); @@ -319,7 +319,7 @@ contract PackingTest is Test { assertEq(container, container.replace_12_8(newValue, offset).replace_12_8(oldValue, offset)); } - function testReplace(bytes16 container, bytes1 newValue, uint8 offset) external { + function testReplace(bytes16 container, bytes1 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 15)); bytes1 oldValue = container.extract_16_1(offset); @@ -328,7 +328,7 @@ contract PackingTest is Test { assertEq(container, container.replace_16_1(newValue, offset).replace_16_1(oldValue, offset)); } - function testReplace(bytes16 container, bytes2 newValue, uint8 offset) external { + function testReplace(bytes16 container, bytes2 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 14)); bytes2 oldValue = container.extract_16_2(offset); @@ -337,7 +337,7 @@ contract PackingTest is Test { assertEq(container, container.replace_16_2(newValue, offset).replace_16_2(oldValue, offset)); } - function testReplace(bytes16 container, bytes4 newValue, uint8 offset) external { + function testReplace(bytes16 container, bytes4 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 12)); bytes4 oldValue = container.extract_16_4(offset); @@ -346,7 +346,7 @@ contract PackingTest is Test { assertEq(container, container.replace_16_4(newValue, offset).replace_16_4(oldValue, offset)); } - function testReplace(bytes16 container, bytes6 newValue, uint8 offset) external { + function testReplace(bytes16 container, bytes6 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 10)); bytes6 oldValue = container.extract_16_6(offset); @@ -355,7 +355,7 @@ contract PackingTest is Test { assertEq(container, container.replace_16_6(newValue, offset).replace_16_6(oldValue, offset)); } - function testReplace(bytes16 container, bytes8 newValue, uint8 offset) external { + function testReplace(bytes16 container, bytes8 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 8)); bytes8 oldValue = container.extract_16_8(offset); @@ -364,7 +364,7 @@ contract PackingTest is Test { assertEq(container, container.replace_16_8(newValue, offset).replace_16_8(oldValue, offset)); } - function testReplace(bytes16 container, bytes12 newValue, uint8 offset) external { + function testReplace(bytes16 container, bytes12 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 4)); bytes12 oldValue = container.extract_16_12(offset); @@ -373,7 +373,7 @@ contract PackingTest is Test { assertEq(container, container.replace_16_12(newValue, offset).replace_16_12(oldValue, offset)); } - function testReplace(bytes20 container, bytes1 newValue, uint8 offset) external { + function testReplace(bytes20 container, bytes1 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 19)); bytes1 oldValue = container.extract_20_1(offset); @@ -382,7 +382,7 @@ contract PackingTest is Test { assertEq(container, container.replace_20_1(newValue, offset).replace_20_1(oldValue, offset)); } - function testReplace(bytes20 container, bytes2 newValue, uint8 offset) external { + function testReplace(bytes20 container, bytes2 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 18)); bytes2 oldValue = container.extract_20_2(offset); @@ -391,7 +391,7 @@ contract PackingTest is Test { assertEq(container, container.replace_20_2(newValue, offset).replace_20_2(oldValue, offset)); } - function testReplace(bytes20 container, bytes4 newValue, uint8 offset) external { + function testReplace(bytes20 container, bytes4 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 16)); bytes4 oldValue = container.extract_20_4(offset); @@ -400,7 +400,7 @@ contract PackingTest is Test { assertEq(container, container.replace_20_4(newValue, offset).replace_20_4(oldValue, offset)); } - function testReplace(bytes20 container, bytes6 newValue, uint8 offset) external { + function testReplace(bytes20 container, bytes6 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 14)); bytes6 oldValue = container.extract_20_6(offset); @@ -409,7 +409,7 @@ contract PackingTest is Test { assertEq(container, container.replace_20_6(newValue, offset).replace_20_6(oldValue, offset)); } - function testReplace(bytes20 container, bytes8 newValue, uint8 offset) external { + function testReplace(bytes20 container, bytes8 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 12)); bytes8 oldValue = container.extract_20_8(offset); @@ -418,7 +418,7 @@ contract PackingTest is Test { assertEq(container, container.replace_20_8(newValue, offset).replace_20_8(oldValue, offset)); } - function testReplace(bytes20 container, bytes12 newValue, uint8 offset) external { + function testReplace(bytes20 container, bytes12 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 8)); bytes12 oldValue = container.extract_20_12(offset); @@ -427,7 +427,7 @@ contract PackingTest is Test { assertEq(container, container.replace_20_12(newValue, offset).replace_20_12(oldValue, offset)); } - function testReplace(bytes20 container, bytes16 newValue, uint8 offset) external { + function testReplace(bytes20 container, bytes16 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 4)); bytes16 oldValue = container.extract_20_16(offset); @@ -436,7 +436,7 @@ contract PackingTest is Test { assertEq(container, container.replace_20_16(newValue, offset).replace_20_16(oldValue, offset)); } - function testReplace(bytes24 container, bytes1 newValue, uint8 offset) external { + function testReplace(bytes24 container, bytes1 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 23)); bytes1 oldValue = container.extract_24_1(offset); @@ -445,7 +445,7 @@ contract PackingTest is Test { assertEq(container, container.replace_24_1(newValue, offset).replace_24_1(oldValue, offset)); } - function testReplace(bytes24 container, bytes2 newValue, uint8 offset) external { + function testReplace(bytes24 container, bytes2 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 22)); bytes2 oldValue = container.extract_24_2(offset); @@ -454,7 +454,7 @@ contract PackingTest is Test { assertEq(container, container.replace_24_2(newValue, offset).replace_24_2(oldValue, offset)); } - function testReplace(bytes24 container, bytes4 newValue, uint8 offset) external { + function testReplace(bytes24 container, bytes4 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 20)); bytes4 oldValue = container.extract_24_4(offset); @@ -463,7 +463,7 @@ contract PackingTest is Test { assertEq(container, container.replace_24_4(newValue, offset).replace_24_4(oldValue, offset)); } - function testReplace(bytes24 container, bytes6 newValue, uint8 offset) external { + function testReplace(bytes24 container, bytes6 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 18)); bytes6 oldValue = container.extract_24_6(offset); @@ -472,7 +472,7 @@ contract PackingTest is Test { assertEq(container, container.replace_24_6(newValue, offset).replace_24_6(oldValue, offset)); } - function testReplace(bytes24 container, bytes8 newValue, uint8 offset) external { + function testReplace(bytes24 container, bytes8 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 16)); bytes8 oldValue = container.extract_24_8(offset); @@ -481,7 +481,7 @@ contract PackingTest is Test { assertEq(container, container.replace_24_8(newValue, offset).replace_24_8(oldValue, offset)); } - function testReplace(bytes24 container, bytes12 newValue, uint8 offset) external { + function testReplace(bytes24 container, bytes12 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 12)); bytes12 oldValue = container.extract_24_12(offset); @@ -490,7 +490,7 @@ contract PackingTest is Test { assertEq(container, container.replace_24_12(newValue, offset).replace_24_12(oldValue, offset)); } - function testReplace(bytes24 container, bytes16 newValue, uint8 offset) external { + function testReplace(bytes24 container, bytes16 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 8)); bytes16 oldValue = container.extract_24_16(offset); @@ -499,7 +499,7 @@ contract PackingTest is Test { assertEq(container, container.replace_24_16(newValue, offset).replace_24_16(oldValue, offset)); } - function testReplace(bytes24 container, bytes20 newValue, uint8 offset) external { + function testReplace(bytes24 container, bytes20 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 4)); bytes20 oldValue = container.extract_24_20(offset); @@ -508,7 +508,7 @@ contract PackingTest is Test { assertEq(container, container.replace_24_20(newValue, offset).replace_24_20(oldValue, offset)); } - function testReplace(bytes28 container, bytes1 newValue, uint8 offset) external { + function testReplace(bytes28 container, bytes1 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 27)); bytes1 oldValue = container.extract_28_1(offset); @@ -517,7 +517,7 @@ contract PackingTest is Test { assertEq(container, container.replace_28_1(newValue, offset).replace_28_1(oldValue, offset)); } - function testReplace(bytes28 container, bytes2 newValue, uint8 offset) external { + function testReplace(bytes28 container, bytes2 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 26)); bytes2 oldValue = container.extract_28_2(offset); @@ -526,7 +526,7 @@ contract PackingTest is Test { assertEq(container, container.replace_28_2(newValue, offset).replace_28_2(oldValue, offset)); } - function testReplace(bytes28 container, bytes4 newValue, uint8 offset) external { + function testReplace(bytes28 container, bytes4 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 24)); bytes4 oldValue = container.extract_28_4(offset); @@ -535,7 +535,7 @@ contract PackingTest is Test { assertEq(container, container.replace_28_4(newValue, offset).replace_28_4(oldValue, offset)); } - function testReplace(bytes28 container, bytes6 newValue, uint8 offset) external { + function testReplace(bytes28 container, bytes6 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 22)); bytes6 oldValue = container.extract_28_6(offset); @@ -544,7 +544,7 @@ contract PackingTest is Test { assertEq(container, container.replace_28_6(newValue, offset).replace_28_6(oldValue, offset)); } - function testReplace(bytes28 container, bytes8 newValue, uint8 offset) external { + function testReplace(bytes28 container, bytes8 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 20)); bytes8 oldValue = container.extract_28_8(offset); @@ -553,7 +553,7 @@ contract PackingTest is Test { assertEq(container, container.replace_28_8(newValue, offset).replace_28_8(oldValue, offset)); } - function testReplace(bytes28 container, bytes12 newValue, uint8 offset) external { + function testReplace(bytes28 container, bytes12 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 16)); bytes12 oldValue = container.extract_28_12(offset); @@ -562,7 +562,7 @@ contract PackingTest is Test { assertEq(container, container.replace_28_12(newValue, offset).replace_28_12(oldValue, offset)); } - function testReplace(bytes28 container, bytes16 newValue, uint8 offset) external { + function testReplace(bytes28 container, bytes16 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 12)); bytes16 oldValue = container.extract_28_16(offset); @@ -571,7 +571,7 @@ contract PackingTest is Test { assertEq(container, container.replace_28_16(newValue, offset).replace_28_16(oldValue, offset)); } - function testReplace(bytes28 container, bytes20 newValue, uint8 offset) external { + function testReplace(bytes28 container, bytes20 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 8)); bytes20 oldValue = container.extract_28_20(offset); @@ -580,7 +580,7 @@ contract PackingTest is Test { assertEq(container, container.replace_28_20(newValue, offset).replace_28_20(oldValue, offset)); } - function testReplace(bytes28 container, bytes24 newValue, uint8 offset) external { + function testReplace(bytes28 container, bytes24 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 4)); bytes24 oldValue = container.extract_28_24(offset); @@ -589,7 +589,7 @@ contract PackingTest is Test { assertEq(container, container.replace_28_24(newValue, offset).replace_28_24(oldValue, offset)); } - function testReplace(bytes32 container, bytes1 newValue, uint8 offset) external { + function testReplace(bytes32 container, bytes1 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 31)); bytes1 oldValue = container.extract_32_1(offset); @@ -598,7 +598,7 @@ contract PackingTest is Test { assertEq(container, container.replace_32_1(newValue, offset).replace_32_1(oldValue, offset)); } - function testReplace(bytes32 container, bytes2 newValue, uint8 offset) external { + function testReplace(bytes32 container, bytes2 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 30)); bytes2 oldValue = container.extract_32_2(offset); @@ -607,7 +607,7 @@ contract PackingTest is Test { assertEq(container, container.replace_32_2(newValue, offset).replace_32_2(oldValue, offset)); } - function testReplace(bytes32 container, bytes4 newValue, uint8 offset) external { + function testReplace(bytes32 container, bytes4 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 28)); bytes4 oldValue = container.extract_32_4(offset); @@ -616,7 +616,7 @@ contract PackingTest is Test { assertEq(container, container.replace_32_4(newValue, offset).replace_32_4(oldValue, offset)); } - function testReplace(bytes32 container, bytes6 newValue, uint8 offset) external { + function testReplace(bytes32 container, bytes6 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 26)); bytes6 oldValue = container.extract_32_6(offset); @@ -625,7 +625,7 @@ contract PackingTest is Test { assertEq(container, container.replace_32_6(newValue, offset).replace_32_6(oldValue, offset)); } - function testReplace(bytes32 container, bytes8 newValue, uint8 offset) external { + function testReplace(bytes32 container, bytes8 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 24)); bytes8 oldValue = container.extract_32_8(offset); @@ -634,7 +634,7 @@ contract PackingTest is Test { assertEq(container, container.replace_32_8(newValue, offset).replace_32_8(oldValue, offset)); } - function testReplace(bytes32 container, bytes12 newValue, uint8 offset) external { + function testReplace(bytes32 container, bytes12 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 20)); bytes12 oldValue = container.extract_32_12(offset); @@ -643,7 +643,7 @@ contract PackingTest is Test { assertEq(container, container.replace_32_12(newValue, offset).replace_32_12(oldValue, offset)); } - function testReplace(bytes32 container, bytes16 newValue, uint8 offset) external { + function testReplace(bytes32 container, bytes16 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 16)); bytes16 oldValue = container.extract_32_16(offset); @@ -652,7 +652,7 @@ contract PackingTest is Test { assertEq(container, container.replace_32_16(newValue, offset).replace_32_16(oldValue, offset)); } - function testReplace(bytes32 container, bytes20 newValue, uint8 offset) external { + function testReplace(bytes32 container, bytes20 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 12)); bytes20 oldValue = container.extract_32_20(offset); @@ -661,7 +661,7 @@ contract PackingTest is Test { assertEq(container, container.replace_32_20(newValue, offset).replace_32_20(oldValue, offset)); } - function testReplace(bytes32 container, bytes24 newValue, uint8 offset) external { + function testReplace(bytes32 container, bytes24 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 8)); bytes24 oldValue = container.extract_32_24(offset); @@ -670,7 +670,7 @@ contract PackingTest is Test { assertEq(container, container.replace_32_24(newValue, offset).replace_32_24(oldValue, offset)); } - function testReplace(bytes32 container, bytes28 newValue, uint8 offset) external { + function testReplace(bytes32 container, bytes28 newValue, uint8 offset) external pure { offset = uint8(bound(offset, 0, 4)); bytes28 oldValue = container.extract_32_28(offset); diff --git a/test/utils/ShortStrings.t.sol b/test/utils/ShortStrings.t.sol index 4aeafd721a8..80313bf7cd1 100644 --- a/test/utils/ShortStrings.t.sol +++ b/test/utils/ShortStrings.t.sol @@ -10,12 +10,12 @@ import {ShortStrings, ShortString} from "@openzeppelin/contracts/utils/ShortStri contract ShortStringsTest is Test, SymTest { string _fallback; - function testRoundtripShort(string memory input) external { + function testRoundtripShort(string memory input) external pure { vm.assume(_isShort(input)); _assertRoundtripShort(input); } - function symbolicRoundtripShort() external { + function symbolicRoundtripShort() external pure { string memory input = svm.createString(31, "RoundtripShortInput"); _assertRoundtripShort(input); } @@ -41,12 +41,12 @@ contract ShortStringsTest is Test, SymTest { _assertRevertLong(input); } - function testLengthShort(string memory input) external { + function testLengthShort(string memory input) external pure { vm.assume(_isShort(input)); _assertLengthShort(input); } - function symbolicLengthShort() external { + function symbolicLengthShort() external pure { string memory input = svm.createString(31, "LengthShortInput"); _assertLengthShort(input); } @@ -66,7 +66,7 @@ contract ShortStringsTest is Test, SymTest { /// Assertions - function _assertRoundtripShort(string memory input) internal { + function _assertRoundtripShort(string memory input) internal pure { ShortString short = ShortStrings.toShortString(input); string memory output = ShortStrings.toString(short); assertEq(input, output); @@ -84,7 +84,7 @@ contract ShortStringsTest is Test, SymTest { this.toShortString(input); } - function _assertLengthShort(string memory input) internal { + function _assertLengthShort(string memory input) internal pure { ShortString short = ShortStrings.toShortString(input); uint256 shortLength = ShortStrings.byteLength(short); uint256 inputLength = bytes(input).length; diff --git a/test/utils/SlotDerivation.t.sol b/test/utils/SlotDerivation.t.sol index 4021f0f8796..a0846e33212 100644 --- a/test/utils/SlotDerivation.t.sol +++ b/test/utils/SlotDerivation.t.sol @@ -42,7 +42,7 @@ contract SlotDerivationTest is Test, SymTest { mapping(address => bytes) private _addressMapping; - function testSymbolicDeriveMappingAddress(address key) public { + function testSymbolicDeriveMappingAddress(address key) public view { bytes32 baseSlot; assembly { baseSlot := _addressMapping.slot @@ -59,7 +59,7 @@ contract SlotDerivationTest is Test, SymTest { mapping(bool => bytes) private _boolMapping; - function testSymbolicDeriveMappingBoolean(bool key) public { + function testSymbolicDeriveMappingBoolean(bool key) public view { bytes32 baseSlot; assembly { baseSlot := _boolMapping.slot @@ -76,7 +76,7 @@ contract SlotDerivationTest is Test, SymTest { mapping(bytes32 => bytes) private _bytes32Mapping; - function testSymbolicDeriveMappingBytes32(bytes32 key) public { + function testSymbolicDeriveMappingBytes32(bytes32 key) public view { bytes32 baseSlot; assembly { baseSlot := _bytes32Mapping.slot @@ -93,7 +93,7 @@ contract SlotDerivationTest is Test, SymTest { mapping(bytes4 => bytes) private _bytes4Mapping; - function testSymbolicDeriveMappingBytes4(bytes4 key) public { + function testSymbolicDeriveMappingBytes4(bytes4 key) public view { bytes32 baseSlot; assembly { baseSlot := _bytes4Mapping.slot @@ -110,7 +110,7 @@ contract SlotDerivationTest is Test, SymTest { mapping(uint256 => bytes) private _uint256Mapping; - function testSymbolicDeriveMappingUint256(uint256 key) public { + function testSymbolicDeriveMappingUint256(uint256 key) public view { bytes32 baseSlot; assembly { baseSlot := _uint256Mapping.slot @@ -127,7 +127,7 @@ contract SlotDerivationTest is Test, SymTest { mapping(uint32 => bytes) private _uint32Mapping; - function testSymbolicDeriveMappingUint32(uint32 key) public { + function testSymbolicDeriveMappingUint32(uint32 key) public view { bytes32 baseSlot; assembly { baseSlot := _uint32Mapping.slot @@ -144,7 +144,7 @@ contract SlotDerivationTest is Test, SymTest { mapping(int256 => bytes) private _int256Mapping; - function testSymbolicDeriveMappingInt256(int256 key) public { + function testSymbolicDeriveMappingInt256(int256 key) public view { bytes32 baseSlot; assembly { baseSlot := _int256Mapping.slot @@ -161,7 +161,7 @@ contract SlotDerivationTest is Test, SymTest { mapping(int32 => bytes) private _int32Mapping; - function testSymbolicDeriveMappingInt32(int32 key) public { + function testSymbolicDeriveMappingInt32(int32 key) public view { bytes32 baseSlot; assembly { baseSlot := _int32Mapping.slot @@ -178,15 +178,15 @@ contract SlotDerivationTest is Test, SymTest { mapping(string => bytes) private _stringMapping; - function testDeriveMappingString(string memory key) public { + function testDeriveMappingString(string memory key) public view { _assertDeriveMappingString(key); } - function symbolicDeriveMappingString() public { + function symbolicDeriveMappingString() public view { _assertDeriveMappingString(svm.createString(256, "DeriveMappingStringInput")); } - function _assertDeriveMappingString(string memory key) internal { + function _assertDeriveMappingString(string memory key) internal view { bytes32 baseSlot; assembly { baseSlot := _stringMapping.slot @@ -203,15 +203,15 @@ contract SlotDerivationTest is Test, SymTest { mapping(bytes => bytes) private _bytesMapping; - function testDeriveMappingBytes(bytes memory key) public { + function testDeriveMappingBytes(bytes memory key) public view { _assertDeriveMappingBytes(key); } - function symbolicDeriveMappingBytes() public { + function symbolicDeriveMappingBytes() public view { _assertDeriveMappingBytes(svm.createBytes(256, "DeriveMappingBytesInput")); } - function _assertDeriveMappingBytes(bytes memory key) internal { + function _assertDeriveMappingBytes(bytes memory key) internal view { bytes32 baseSlot; assembly { baseSlot := _bytesMapping.slot diff --git a/test/utils/math/Math.t.sol b/test/utils/math/Math.t.sol index 3d4932eea7a..6c122d66c3f 100644 --- a/test/utils/math/Math.t.sol +++ b/test/utils/math/Math.t.sol @@ -7,18 +7,18 @@ import {Test, stdError} from "forge-std/Test.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; contract MathTest is Test { - function testSymbolicTernary(bool f, uint256 a, uint256 b) public { + function testSymbolicTernary(bool f, uint256 a, uint256 b) public pure { assertEq(Math.ternary(f, a, b), f ? a : b); } // MIN & MAX - function testSymbolicMinMax(uint256 a, uint256 b) public { + function testSymbolicMinMax(uint256 a, uint256 b) public pure { assertEq(Math.min(a, b), a < b ? a : b); assertEq(Math.max(a, b), a > b ? a : b); } // CEILDIV - function testCeilDiv(uint256 a, uint256 b) public { + function testCeilDiv(uint256 a, uint256 b) public pure { vm.assume(b > 0); uint256 result = Math.ceilDiv(a, b); @@ -35,7 +35,7 @@ contract MathTest is Test { } // SQRT - function testSqrt(uint256 input, uint8 r) public { + function testSqrt(uint256 input, uint8 r) public pure { Math.Rounding rounding = _asRounding(r); uint256 result = Math.sqrt(input, rounding); @@ -66,31 +66,31 @@ contract MathTest is Test { } // INV - function testInvMod(uint256 value, uint256 p) public { + function testInvMod(uint256 value, uint256 p) public pure { _testInvMod(value, p, true); } - function testInvMod2(uint256 seed) public { + function testInvMod2(uint256 seed) public pure { uint256 p = 2; // prime _testInvMod(bound(seed, 1, p - 1), p, false); } - function testInvMod17(uint256 seed) public { + function testInvMod17(uint256 seed) public pure { uint256 p = 17; // prime _testInvMod(bound(seed, 1, p - 1), p, false); } - function testInvMod65537(uint256 seed) public { + function testInvMod65537(uint256 seed) public pure { uint256 p = 65537; // prime _testInvMod(bound(seed, 1, p - 1), p, false); } - function testInvModP256(uint256 seed) public { + function testInvModP256(uint256 seed) public pure { uint256 p = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff; // prime _testInvMod(bound(seed, 1, p - 1), p, false); } - function _testInvMod(uint256 value, uint256 p, bool allowZero) private { + function _testInvMod(uint256 value, uint256 p, bool allowZero) private pure { uint256 inverse = Math.invMod(value, p); if (inverse != 0) { assertEq(mulmod(value, inverse, p), 1); @@ -101,7 +101,7 @@ contract MathTest is Test { } // LOG2 - function testLog2(uint256 input, uint8 r) public { + function testLog2(uint256 input, uint8 r) public pure { Math.Rounding rounding = _asRounding(r); uint256 result = Math.log2(input, rounding); @@ -128,7 +128,7 @@ contract MathTest is Test { } // LOG10 - function testLog10(uint256 input, uint8 r) public { + function testLog10(uint256 input, uint8 r) public pure { Math.Rounding rounding = _asRounding(r); uint256 result = Math.log10(input, rounding); @@ -155,7 +155,7 @@ contract MathTest is Test { } // LOG256 - function testLog256(uint256 input, uint8 r) public { + function testLog256(uint256 input, uint8 r) public pure { Math.Rounding rounding = _asRounding(r); uint256 result = Math.log256(input, rounding); @@ -182,7 +182,7 @@ contract MathTest is Test { } // MULDIV - function testMulDiv(uint256 x, uint256 y, uint256 d) public { + function testMulDiv(uint256 x, uint256 y, uint256 d) public pure { // Full precision for x * y (uint256 xyHi, uint256 xyLo) = _mulHighLow(x, y); @@ -225,7 +225,7 @@ contract MathTest is Test { assertEq(result, _nativeModExp(b, e, m)); } - function testTryModExp(uint256 b, uint256 e, uint256 m) public { + function testTryModExp(uint256 b, uint256 e, uint256 m) public view { (bool success, uint256 result) = Math.tryModExp(b, e, m); assertEq(success, m != 0); if (success) { @@ -247,7 +247,7 @@ contract MathTest is Test { assertEq(res, _nativeModExp(b, e, m)); } - function testTryModExpMemory(uint256 b, uint256 e, uint256 m) public { + function testTryModExpMemory(uint256 b, uint256 e, uint256 m) public view { (bool success, bytes memory result) = Math.tryModExp( abi.encodePacked(b), abi.encodePacked(e), diff --git a/test/utils/math/SignedMath.t.sol b/test/utils/math/SignedMath.t.sol index bbad109b71e..98a40a13998 100644 --- a/test/utils/math/SignedMath.t.sol +++ b/test/utils/math/SignedMath.t.sol @@ -8,18 +8,18 @@ import {Math} from "../../../contracts/utils/math/Math.sol"; import {SignedMath} from "../../../contracts/utils/math/SignedMath.sol"; contract SignedMathTest is Test { - function testSymbolicTernary(bool f, int256 a, int256 b) public { + function testSymbolicTernary(bool f, int256 a, int256 b) public pure { assertEq(SignedMath.ternary(f, a, b), f ? a : b); } // MIN & MAX - function testSymbolicMinMax(int256 a, int256 b) public { + function testSymbolicMinMax(int256 a, int256 b) public pure { assertEq(SignedMath.min(a, b), a < b ? a : b); assertEq(SignedMath.max(a, b), a > b ? a : b); } // MIN - function testSymbolicMin(int256 a, int256 b) public { + function testSymbolicMin(int256 a, int256 b) public pure { int256 result = SignedMath.min(a, b); assertLe(result, a); @@ -28,7 +28,7 @@ contract SignedMathTest is Test { } // MAX - function testSymbolicMax(int256 a, int256 b) public { + function testSymbolicMax(int256 a, int256 b) public pure { int256 result = SignedMath.max(a, b); assertGe(result, a); @@ -38,7 +38,7 @@ contract SignedMathTest is Test { // AVERAGE // 1. simple test, not full int256 range - function testAverage1(int256 a, int256 b) public { + function testAverage1(int256 a, int256 b) public pure { a = bound(a, type(int256).min / 2, type(int256).max / 2); b = bound(b, type(int256).min / 2, type(int256).max / 2); @@ -48,7 +48,7 @@ contract SignedMathTest is Test { } // 2. more complex test, full int256 range - function testAverage2(int256 a, int256 b) public { + function testAverage2(int256 a, int256 b) public pure { (int256 result, int256 min, int256 max) = ( SignedMath.average(a, b), SignedMath.min(a, b), @@ -69,7 +69,7 @@ contract SignedMathTest is Test { } // ABS - function testSymbolicAbs(int256 a) public { + function testSymbolicAbs(int256 a) public pure { uint256 result = SignedMath.abs(a); unchecked { diff --git a/test/utils/structs/Checkpoints.t.sol b/test/utils/structs/Checkpoints.t.sol index 1f4b344c57f..548a9d47c5c 100644 --- a/test/utils/structs/Checkpoints.t.sol +++ b/test/utils/structs/Checkpoints.t.sol @@ -30,7 +30,7 @@ contract CheckpointsTrace224Test is Test { } } - function _assertLatestCheckpoint(bool exist, uint32 key, uint224 value) internal { + function _assertLatestCheckpoint(bool exist, uint32 key, uint224 value) internal view { (bool _exist, uint32 _key, uint224 _value) = _ckpts.latestCheckpoint(); assertEq(_exist, exist); assertEq(_key, key); @@ -138,7 +138,7 @@ contract CheckpointsTrace208Test is Test { } } - function _assertLatestCheckpoint(bool exist, uint48 key, uint208 value) internal { + function _assertLatestCheckpoint(bool exist, uint48 key, uint208 value) internal view { (bool _exist, uint48 _key, uint208 _value) = _ckpts.latestCheckpoint(); assertEq(_exist, exist); assertEq(_key, key); @@ -246,7 +246,7 @@ contract CheckpointsTrace160Test is Test { } } - function _assertLatestCheckpoint(bool exist, uint96 key, uint160 value) internal { + function _assertLatestCheckpoint(bool exist, uint96 key, uint160 value) internal view { (bool _exist, uint96 _key, uint160 _value) = _ckpts.latestCheckpoint(); assertEq(_exist, exist); assertEq(_key, key);