Skip to content
Merged
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
54 changes: 54 additions & 0 deletions crates/forge/tests/cli/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,46 @@ const COUNTER_B: &str = r#"
}
"#;

const COUNTER_WITH_CONST: &str = r#"
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

uint256 constant MAX = 1000000;

contract Counter {
uint256 public number;

function setNumber(uint256 newNumber) public {
number = newNumber;
}

function increment() public {
number++;
}
}
"#;

const COUNTER_TEST_WITH_CONST: &str = r#"
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import { Counter, MAX } from "../src/Counter.sol";

contract CounterTest {
Counter public counter;

function setUp() public {
counter = new Counter();
}

function testFuzz_setNumber(uint256[MAX] calldata numbers) public {
for (uint256 i = 0; i < numbers.length; ++i) {
counter.setNumber(numbers[i]);
}
}
}
"#;

forgetest!(can_use_config, |prj, cmd| {
prj.wipe_contracts();
prj.add_source("ContractWithLints", CONTRACT).unwrap();
Expand Down Expand Up @@ -476,6 +516,20 @@ note[mixed-case-variable]: mutable variables should use mixedCase
]);
});

// <https://github.com/foundry-rs/foundry/issues/11392>
forgetest!(can_lint_param_constants, |prj, cmd| {
prj.wipe_contracts();
prj.add_source("Counter", COUNTER_WITH_CONST).unwrap();
prj.add_test("CounterTest", COUNTER_TEST_WITH_CONST).unwrap();

cmd.forge_fuse().args(["build"]).assert_success().stdout_eq(str![[r#"
[COMPILING_FILES] with [SOLC_VERSION]
[SOLC_VERSION] [ELAPSED]
Compiler run successful!

"#]]);
});

// ------------------------------------------------------------------------------------------------

#[tokio::test]
Expand Down
Loading