Skip to content

Commit d4aa568

Browse files
feat(invariant): rename continuous_run to assert_all and default to true
Renames the InvariantConfig field to better describe its semantics ("assert every invariant in the suite, don't stop on first failure") and flips the default to true so multi-invariant suites report all broken invariants by default, matching Echidna/Medusa behavior. Amp-Thread-ID: https://ampcode.com/threads/T-019dcd68-66ac-76ed-ac5c-7ea722a9c9ae Co-authored-by: Amp <amp@ampcode.com>
1 parent 6c0a977 commit d4aa568

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

crates/config/src/invariant.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ pub struct InvariantConfig {
4949
///
5050
/// Example: `check_interval = 10` means assert after calls 10, 20, 30, ... and the last call.
5151
pub check_interval: u32,
52-
/// Continue invariant run until all invariants declared in current test suite breaks.
53-
pub continuous_run: bool,
52+
/// Assert every invariant declared in the current test suite, continuing the campaign after
53+
/// the first failure until all invariants have been broken (or normal limits are hit).
54+
/// When `false`, the campaign aborts on the first broken invariant (legacy behavior).
55+
pub assert_all: bool,
5456
}
5557

5658
impl Default for InvariantConfig {
@@ -72,7 +74,7 @@ impl Default for InvariantConfig {
7274
max_time_delay: None,
7375
max_block_delay: None,
7476
check_interval: 1,
75-
continuous_run: false,
77+
assert_all: true,
7678
}
7779
}
7880
}

crates/forge/src/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ impl<'a, FEN: FoundryEvmNetwork> FunctionRunner<'a, FEN> {
791791
.filter(|(invariant_fn, _)| {
792792
*invariant_fn == func
793793
|| (!is_optimization
794-
&& invariant_config.continuous_run
794+
&& invariant_config.assert_all
795795
&& !canonicalized(failure_dir.join(invariant_fn.name.clone())).exists())
796796
})
797797
.collect(),

crates/forge/tests/cli/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ failure_persist_dir = "cache/invariant"
224224
show_metrics = true
225225
show_solidity = false
226226
check_interval = 1
227-
continuous_run = false
227+
assert_all = true
228228
229229
[labels]
230230
@@ -1317,7 +1317,7 @@ forgetest_init!(test_default_config, |prj, cmd| {
13171317
"max_time_delay": null,
13181318
"max_block_delay": null,
13191319
"check_interval": 1,
1320-
"continuous_run": false
1320+
"assert_all": true
13211321
},
13221322
"ffi": false,
13231323
"live_logs": false,

crates/forge/tests/cli/test_cmd/invariant/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,11 +1318,11 @@ contract CheckIntervalInlineTest is Test {
13181318
]]);
13191319
});
13201320

1321-
forgetest_init!(continous_run, |prj, cmd| {
1321+
forgetest_init!(assert_all, |prj, cmd| {
13221322
prj.update_config(|config| {
13231323
config.invariant.runs = 10;
13241324
config.invariant.depth = 100;
1325-
config.invariant.continuous_run = true;
1325+
config.invariant.assert_all = true;
13261326
});
13271327
prj.add_source(
13281328
"Counter.sol",

0 commit comments

Comments
 (0)