Skip to content

Commit f962373

Browse files
ernestognwcairoeth
andauthored
Update forge and change visibility in fuzz tests (#5103)
Co-authored-by: cairo <[email protected]>
1 parent bcdfa84 commit f962373

File tree

16 files changed

+74
-70
lines changed

16 files changed

+74
-70
lines changed

scripts/generate/templates/Checkpoints.t.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function _prepareKeys(${opts.keyTypeName}[] memory keys, ${opts.keyTypeName} max
3636
}
3737
}
3838
39-
function _assertLatestCheckpoint(bool exist, ${opts.keyTypeName} key, ${opts.valueTypeName} value) internal {
39+
function _assertLatestCheckpoint(bool exist, ${opts.keyTypeName} key, ${opts.valueTypeName} value) internal view {
4040
(bool _exist, ${opts.keyTypeName} _key, ${opts.valueTypeName} _value) = _ckpts.latestCheckpoint();
4141
assertEq(_exist, exist);
4242
assertEq(_key, key);

scripts/generate/templates/SlotDerivation.t.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function _assertDeriveArray(uint256 length, uint256 offset) public {
4545
const mapping = ({ type, name }) => `\
4646
mapping(${type} => bytes) private _${type}Mapping;
4747
48-
function testSymbolicDeriveMapping${name}(${type} key) public {
48+
function testSymbolicDeriveMapping${name}(${type} key) public view {
4949
bytes32 baseSlot;
5050
assembly {
5151
baseSlot := _${type}Mapping.slot
@@ -76,15 +76,15 @@ function testSymbolicDeriveMapping${name}Dirty(bytes32 dirtyKey) public {
7676
const boundedMapping = ({ type, name }) => `\
7777
mapping(${type} => bytes) private _${type}Mapping;
7878
79-
function testDeriveMapping${name}(${type} memory key) public {
79+
function testDeriveMapping${name}(${type} memory key) public view {
8080
_assertDeriveMapping${name}(key);
8181
}
8282
83-
function symbolicDeriveMapping${name}() public {
83+
function symbolicDeriveMapping${name}() public view {
8484
_assertDeriveMapping${name}(svm.create${name}(256, "DeriveMapping${name}Input"));
8585
}
8686
87-
function _assertDeriveMapping${name}(${type} memory key) internal {
87+
function _assertDeriveMapping${name}(${type} memory key) internal view {
8888
bytes32 baseSlot;
8989
assembly {
9090
baseSlot := _${type}Mapping.slot

test/governance/Governor.t.sol

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import {Governor} from "@openzeppelin/contracts/governance/Governor.sol";
99
contract GovernorInternalTest is Test, Governor {
1010
constructor() Governor("") {}
1111

12-
function testValidDescriptionForProposer(string memory description, address proposer, bool includeProposer) public {
12+
function testValidDescriptionForProposer(
13+
string memory description,
14+
address proposer,
15+
bool includeProposer
16+
) public view {
1317
if (includeProposer) {
1418
description = string.concat(description, "#proposer=", Strings.toHexString(proposer));
1519
}
@@ -20,7 +24,7 @@ contract GovernorInternalTest is Test, Governor {
2024
string memory description,
2125
address commitProposer,
2226
address actualProposer
23-
) public {
27+
) public view {
2428
vm.assume(commitProposer != actualProposer);
2529
description = string.concat(description, "#proposer=", Strings.toHexString(commitProposer));
2630
assertFalse(_isValidDescriptionForProposer(actualProposer, description));

test/proxy/Clones.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ contract ClonesTest is Test {
1010
return 42;
1111
}
1212

13-
function testSymbolicPredictDeterministicAddressSpillage(address implementation, bytes32 salt) public {
13+
function testSymbolicPredictDeterministicAddressSpillage(address implementation, bytes32 salt) public view {
1414
address predicted = Clones.predictDeterministicAddress(implementation, salt);
1515
bytes32 spillage;
1616
assembly ("memory-safe") {
@@ -23,7 +23,7 @@ contract ClonesTest is Test {
2323
address implementation,
2424
bytes32 salt,
2525
bytes memory args
26-
) public {
26+
) public view {
2727
vm.assume(args.length < 0xbfd3);
2828

2929
address predicted = Clones.predictDeterministicAddressWithImmutableArgs(implementation, args, salt);
@@ -59,7 +59,7 @@ contract ClonesTest is Test {
5959
assertEq(ClonesTest(cloneDirty).getNumber(), this.getNumber());
6060
}
6161

62-
function testPredictDeterministicAddressDirty(bytes32 salt) external {
62+
function testPredictDeterministicAddressDirty(bytes32 salt) external view {
6363
address predictClean = Clones.predictDeterministicAddress(address(this), salt);
6464
address predictDirty = Clones.predictDeterministicAddress(_dirty(address(this)), salt);
6565

test/utils/Arrays.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import {SymTest} from "halmos-cheatcodes/SymTest.sol";
77
import {Arrays} from "@openzeppelin/contracts/utils/Arrays.sol";
88

99
contract ArraysTest is Test, SymTest {
10-
function testSort(uint256[] memory values) public {
10+
function testSort(uint256[] memory values) public pure {
1111
Arrays.sort(values);
1212
_assertSort(values);
1313
}
1414

15-
function symbolicSort() public {
15+
function symbolicSort() public pure {
1616
uint256[] memory values = new uint256[](3);
1717
for (uint256 i = 0; i < 3; i++) {
1818
values[i] = svm.createUint256("arrayElement");
@@ -23,7 +23,7 @@ contract ArraysTest is Test, SymTest {
2323

2424
/// Asserts
2525

26-
function _assertSort(uint256[] memory values) internal {
26+
function _assertSort(uint256[] memory values) internal pure {
2727
for (uint256 i = 1; i < values.length; ++i) {
2828
assertLe(values[i - 1], values[i]);
2929
}

test/utils/Base64.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import {Test} from "forge-std/Test.sol";
66
import {Base64} from "@openzeppelin/contracts/utils/Base64.sol";
77

88
contract Base64Test is Test {
9-
function testEncode(bytes memory input) external {
9+
function testEncode(bytes memory input) external pure {
1010
assertEq(Base64.encode(input), vm.toBase64(input));
1111
}
1212

13-
function testEncodeURL(bytes memory input) external {
13+
function testEncodeURL(bytes memory input) external pure {
1414
assertEq(Base64.encodeURL(input), _removePadding(vm.toBase64URL(input)));
1515
}
1616

test/utils/Create2.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Test} from "forge-std/Test.sol";
66
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
77

88
contract Create2Test is Test {
9-
function testSymbolicComputeAddressSpillage(bytes32 salt, bytes32 bytecodeHash, address deployer) public {
9+
function testSymbolicComputeAddressSpillage(bytes32 salt, bytes32 bytecodeHash, address deployer) public pure {
1010
address predicted = Create2.computeAddress(salt, bytecodeHash, deployer);
1111
bytes32 spillage;
1212
assembly ("memory-safe") {

test/utils/ShortStrings.t.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import {ShortStrings, ShortString} from "@openzeppelin/contracts/utils/ShortStri
1010
contract ShortStringsTest is Test, SymTest {
1111
string _fallback;
1212

13-
function testRoundtripShort(string memory input) external {
13+
function testRoundtripShort(string memory input) external pure {
1414
vm.assume(_isShort(input));
1515
_assertRoundtripShort(input);
1616
}
1717

18-
function symbolicRoundtripShort() external {
18+
function symbolicRoundtripShort() external pure {
1919
string memory input = svm.createString(31, "RoundtripShortInput");
2020
_assertRoundtripShort(input);
2121
}
@@ -41,12 +41,12 @@ contract ShortStringsTest is Test, SymTest {
4141
_assertRevertLong(input);
4242
}
4343

44-
function testLengthShort(string memory input) external {
44+
function testLengthShort(string memory input) external pure {
4545
vm.assume(_isShort(input));
4646
_assertLengthShort(input);
4747
}
4848

49-
function symbolicLengthShort() external {
49+
function symbolicLengthShort() external pure {
5050
string memory input = svm.createString(31, "LengthShortInput");
5151
_assertLengthShort(input);
5252
}
@@ -66,7 +66,7 @@ contract ShortStringsTest is Test, SymTest {
6666

6767
/// Assertions
6868

69-
function _assertRoundtripShort(string memory input) internal {
69+
function _assertRoundtripShort(string memory input) internal pure {
7070
ShortString short = ShortStrings.toShortString(input);
7171
string memory output = ShortStrings.toString(short);
7272
assertEq(input, output);
@@ -84,7 +84,7 @@ contract ShortStringsTest is Test, SymTest {
8484
this.toShortString(input);
8585
}
8686

87-
function _assertLengthShort(string memory input) internal {
87+
function _assertLengthShort(string memory input) internal pure {
8888
ShortString short = ShortStrings.toShortString(input);
8989
uint256 shortLength = ShortStrings.byteLength(short);
9090
uint256 inputLength = bytes(input).length;

test/utils/SlotDerivation.t.sol

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ contract SlotDerivationTest is Test, SymTest {
4242

4343
mapping(address => bytes) private _addressMapping;
4444

45-
function testSymbolicDeriveMappingAddress(address key) public {
45+
function testSymbolicDeriveMappingAddress(address key) public view {
4646
bytes32 baseSlot;
4747
assembly {
4848
baseSlot := _addressMapping.slot
@@ -59,7 +59,7 @@ contract SlotDerivationTest is Test, SymTest {
5959

6060
mapping(bool => bytes) private _boolMapping;
6161

62-
function testSymbolicDeriveMappingBoolean(bool key) public {
62+
function testSymbolicDeriveMappingBoolean(bool key) public view {
6363
bytes32 baseSlot;
6464
assembly {
6565
baseSlot := _boolMapping.slot
@@ -76,7 +76,7 @@ contract SlotDerivationTest is Test, SymTest {
7676

7777
mapping(bytes32 => bytes) private _bytes32Mapping;
7878

79-
function testSymbolicDeriveMappingBytes32(bytes32 key) public {
79+
function testSymbolicDeriveMappingBytes32(bytes32 key) public view {
8080
bytes32 baseSlot;
8181
assembly {
8282
baseSlot := _bytes32Mapping.slot
@@ -93,7 +93,7 @@ contract SlotDerivationTest is Test, SymTest {
9393

9494
mapping(bytes4 => bytes) private _bytes4Mapping;
9595

96-
function testSymbolicDeriveMappingBytes4(bytes4 key) public {
96+
function testSymbolicDeriveMappingBytes4(bytes4 key) public view {
9797
bytes32 baseSlot;
9898
assembly {
9999
baseSlot := _bytes4Mapping.slot
@@ -110,7 +110,7 @@ contract SlotDerivationTest is Test, SymTest {
110110

111111
mapping(uint256 => bytes) private _uint256Mapping;
112112

113-
function testSymbolicDeriveMappingUint256(uint256 key) public {
113+
function testSymbolicDeriveMappingUint256(uint256 key) public view {
114114
bytes32 baseSlot;
115115
assembly {
116116
baseSlot := _uint256Mapping.slot
@@ -127,7 +127,7 @@ contract SlotDerivationTest is Test, SymTest {
127127

128128
mapping(uint32 => bytes) private _uint32Mapping;
129129

130-
function testSymbolicDeriveMappingUint32(uint32 key) public {
130+
function testSymbolicDeriveMappingUint32(uint32 key) public view {
131131
bytes32 baseSlot;
132132
assembly {
133133
baseSlot := _uint32Mapping.slot
@@ -144,7 +144,7 @@ contract SlotDerivationTest is Test, SymTest {
144144

145145
mapping(int256 => bytes) private _int256Mapping;
146146

147-
function testSymbolicDeriveMappingInt256(int256 key) public {
147+
function testSymbolicDeriveMappingInt256(int256 key) public view {
148148
bytes32 baseSlot;
149149
assembly {
150150
baseSlot := _int256Mapping.slot
@@ -161,7 +161,7 @@ contract SlotDerivationTest is Test, SymTest {
161161

162162
mapping(int32 => bytes) private _int32Mapping;
163163

164-
function testSymbolicDeriveMappingInt32(int32 key) public {
164+
function testSymbolicDeriveMappingInt32(int32 key) public view {
165165
bytes32 baseSlot;
166166
assembly {
167167
baseSlot := _int32Mapping.slot
@@ -178,15 +178,15 @@ contract SlotDerivationTest is Test, SymTest {
178178

179179
mapping(string => bytes) private _stringMapping;
180180

181-
function testDeriveMappingString(string memory key) public {
181+
function testDeriveMappingString(string memory key) public view {
182182
_assertDeriveMappingString(key);
183183
}
184184

185-
function symbolicDeriveMappingString() public {
185+
function symbolicDeriveMappingString() public view {
186186
_assertDeriveMappingString(svm.createString(256, "DeriveMappingStringInput"));
187187
}
188188

189-
function _assertDeriveMappingString(string memory key) internal {
189+
function _assertDeriveMappingString(string memory key) internal view {
190190
bytes32 baseSlot;
191191
assembly {
192192
baseSlot := _stringMapping.slot
@@ -203,15 +203,15 @@ contract SlotDerivationTest is Test, SymTest {
203203

204204
mapping(bytes => bytes) private _bytesMapping;
205205

206-
function testDeriveMappingBytes(bytes memory key) public {
206+
function testDeriveMappingBytes(bytes memory key) public view {
207207
_assertDeriveMappingBytes(key);
208208
}
209209

210-
function symbolicDeriveMappingBytes() public {
210+
function symbolicDeriveMappingBytes() public view {
211211
_assertDeriveMappingBytes(svm.createBytes(256, "DeriveMappingBytesInput"));
212212
}
213213

214-
function _assertDeriveMappingBytes(bytes memory key) internal {
214+
function _assertDeriveMappingBytes(bytes memory key) internal view {
215215
bytes32 baseSlot;
216216
assembly {
217217
baseSlot := _bytesMapping.slot

0 commit comments

Comments
 (0)