Skip to content

Commit bd66711

Browse files
chore(testdata): fix solidity warnings: shadowing of builtin symbol and unhandled low-level calls (#12189)
* fix shadowed variables, shadowed globals, unhandled results * clean up * re-apply 2519 * Fix testdata --------- Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> Co-authored-by: grandizzy <grandizzy.the.egg@gmail.com>
1 parent 4d1df57 commit bd66711

File tree

11 files changed

+27
-20
lines changed

11 files changed

+27
-20
lines changed

crates/forge/tests/fixtures/ExpectEmitFailures.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ contract Emitter {
109109
/// Emulates `Emitter` in #760
110110
contract LowLevelCaller {
111111
function f() external {
112-
address(this).call(abi.encodeWithSignature("g()"));
112+
(bool success,) = address(this).call(abi.encodeWithSignature("g()"));
113+
require(success, "call failed");
113114
}
114115

115116
function g() public {}

testdata/default/cheats/Broadcast.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ contract Test is ForgeTest {
2121
return b;
2222
}
2323

24-
function inc() public returns (uint256) {
24+
function inc() public {
2525
changed += 1;
2626
}
2727

@@ -539,7 +539,7 @@ contract SignatureTester {
539539
owner = msg.sender;
540540
}
541541

542-
function verifySignature(bytes32 digest, uint8 v, bytes32 r, bytes32 s) public view returns (bool) {
542+
function verifySignature(bytes32 digest, uint8 v, bytes32 r, bytes32 s) public view {
543543
require(ecrecover(digest, v, r, s) == owner, "Invalid signature");
544544
}
545545
}

testdata/default/cheats/ExpectCall.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ contract SimpleCall {
5555

5656
contract ProxyWithDelegateCall {
5757
function delegateCall(SimpleCall simpleCall) public {
58-
address(simpleCall).delegatecall(abi.encodeWithSignature("call()"));
58+
(bool success,) = address(simpleCall).delegatecall(abi.encodeWithSignature("call()"));
59+
require(success, "delegatecall failed");
5960
}
6061
}
6162

testdata/default/cheats/ExpectEmit.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ contract Emitter {
108108
/// Emulates `Emitter` in #760
109109
contract LowLevelCaller {
110110
function f() external {
111-
address(this).call(abi.encodeWithSignature("g()"));
111+
(bool success,) = address(this).call(abi.encodeWithSignature("g()"));
112+
require(success, "call failed");
112113
}
113114

114115
function g() public {}

testdata/default/cheats/Fork2.t.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ contract MyContract {
1111
uint256 forkId;
1212
bytes32 blockHash;
1313

14-
constructor(uint256 _forkId) public {
14+
constructor(uint256 _forkId) {
1515
forkId = _forkId;
1616
blockHash = blockhash(block.number - 1);
1717
}
@@ -94,14 +94,14 @@ contract ForkTest is Test {
9494
// test that we can "roll" blocks until a transaction
9595
function testCanRollForkUntilTransaction() public {
9696
// block to run transactions from
97-
uint256 block = 16261704;
97+
uint256 blockNumber = 16261704;
9898

9999
// fork until previous block
100-
uint256 fork = vm.createSelectFork("mainnet", block - 1);
100+
uint256 fork = vm.createSelectFork("mainnet", blockNumber - 1);
101101

102102
// block transactions in order: https://beaconcha.in/block/16261704#transactions
103103
// run transactions from current block until tx
104-
bytes32 tx = 0x67cbad73764049e228495a3f90144aab4a37cb4b5fd697dffc234aa5ed811ace;
104+
bytes32 transaction = 0x67cbad73764049e228495a3f90144aab4a37cb4b5fd697dffc234aa5ed811ace;
105105

106106
// account that sends ether in 2 transaction before tx
107107
address account = 0xAe45a8240147E6179ec7c9f92c5A18F9a97B3fCA;
@@ -115,7 +115,7 @@ contract ForkTest is Test {
115115
uint256 newBalance = account.balance - transferAmount;
116116

117117
// execute transactions in block until tx
118-
vm.rollFork(tx);
118+
vm.rollFork(transaction);
119119

120120
// balance must be less than newBalance due to gas spent
121121
assert(account.balance < newBalance);
@@ -152,7 +152,7 @@ contract ForkTest is Test {
152152
DummyContract dummy = new DummyContract();
153153

154154
// this will succeed since `dummy` is deployed on the currently active fork
155-
string memory msg = dummy.hello();
155+
string memory message = dummy.hello();
156156

157157
address dummyAddress = address(dummy);
158158

testdata/default/cheats/Prank.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ contract PrankTest is Test {
198198
vm.expectRevert("vm.prank: cannot `prank` delegate call from an EOA");
199199
vm.prank(alice, true);
200200
// Should fail when EOA pranked with delegatecall.
201-
address(impl).delegatecall(abi.encodeWithSignature("assertCorrectCaller(address)", alice));
201+
(bool success,) = address(impl).delegatecall(abi.encodeWithSignature("assertCorrectCaller(address)", alice));
202+
require(success, "delegate call failed");
202203
}
203204

204205
function testPrankSender(address sender) public {

testdata/default/cheats/RecordAccountAccesses.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ contract RecordAccountAccessesTest is Test {
223223
Proxy proxy = new Proxy(address(one));
224224

225225
vm.startStateDiffRecording();
226-
address(proxy).call(abi.encodeCall(StorageAccessor.read, bytes32(uint256(1234))));
226+
(bool success,) = address(proxy).call(abi.encodeCall(StorageAccessor.read, bytes32(uint256(1234))));
227+
require(success, "call failed");
227228
Vm.AccountAccess[] memory called = filterExtcodesizeForLegacyTests(vm.stopAndReturnStateDiff());
228229

229230
assertEq(called.length, 2, "incorrect length");

testdata/default/repros/Issue6293.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import "utils/Test.sol";
77
contract Issue6293Test is Test {
88
constructor() {
99
require(address(this).balance > 0);
10-
payable(address(1)).call{value: 1}("");
10+
(bool success,) = payable(address(1)).call{value: 1}("");
11+
require(success, "call failed");
1112
}
1213

1314
function test() public {

testdata/default/repros/Issue7481.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ contract Issue7481Test is Test {
1212
vm.createSelectFork("mainnet", 19514903);
1313

1414
// Transfer some funds to sender of tx being transacted to ensure that it appears in journaled state
15-
payable(address(0x5C60cD7a3D50877Bfebd484750FBeb245D936dAD)).call{value: 1}("");
15+
(bool success,) = payable(address(0x5C60cD7a3D50877Bfebd484750FBeb245D936dAD)).call{value: 1}("");
16+
console.log(success);
1617
vm.transact(0xccfd66fc409a633a99b5b75b0e9a2040fcf562d03d9bee3fefc1a5c0eb49c999);
1718

1819
// Revert the current call to ensure that revm can revert state journal

testdata/foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ ignored_error_codes = [
88
1878, # SPDX license identifier not provided
99
2018, # Function state mutability can be restricted
1010
2072, # Unused local variable
11-
2319, # This declaration shadows a builtin symbol
1211
2519, # This declaration shadows an existing declaration
1312
3860, # Contract init code size exceeds limit
13+
5159, # Selfdestruct has been deprecated
1414
5574, # Contract code size exceeds limit
1515
5667, # Unused function parameter
1616
]

0 commit comments

Comments
 (0)