mirror of
https://github.com/crytic/echidna.git
synced 2026-10-12 02:12:32 +00:00
* allow to disable testing of view/pure function, except prefix ones in property mode * removed unused import * test/config: fix remaining CI failures for excludeViewPure - default.yaml: add excludeViewPure (the config test requires every option be listed; it was failing with 'unset options: fromList ["excludeViewPure"]') - Tests/Integration: pin basic/excludeviewpure.sol to solc >= 0.8.0 (pragma ^0.8.0), so it is skipped on the <0.8 solc CI matrix instead of failing to compile. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * test: prove view/pure functions are excluded, using notPresent Addresses review feedback: excludeviewpure.sol gains a view function with a planted assert(false), and a new assertion-mode run checks that no assertion test is created for any view/pure function (via the previously unused notPresent helper), so the planted assert can never fire. A control run without excludeViewPure proves the assert IS found otherwise and pins the test names the notPresent checks look up. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
36 lines
1.1 KiB
Solidity
36 lines
1.1 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.0;
|
|
|
|
// Tests that excludeViewPure does NOT exclude prefixed view/pure functions
|
|
// in property mode, since those are property tests.
|
|
contract ViewPureProperty {
|
|
uint256 public counter;
|
|
|
|
function increment() external {
|
|
counter++;
|
|
}
|
|
|
|
// view property — must NOT be excluded even with excludeViewPure: true
|
|
function echidna_counter_small() public view returns (bool) {
|
|
return counter < 10;
|
|
}
|
|
|
|
// non-prefixed view — should be excluded
|
|
function getCounter() external view returns (uint256) {
|
|
return counter;
|
|
}
|
|
|
|
// non-prefixed pure — should be excluded
|
|
function getConst() external pure returns (uint256) {
|
|
return 42;
|
|
}
|
|
|
|
// planted failing assert: with excludeViewPure no assertion test may be
|
|
// created for it (and the fuzzer must never call it); without the flag
|
|
// its assertion test must be found immediately
|
|
function neverCalled() external view returns (uint256) {
|
|
assert(false);
|
|
return counter;
|
|
}
|
|
}
|