Skip to content

Commit 0724277

Browse files
author
Stefan Effenberger
committed
added check for fewer events than expected
1 parent 68bb9ad commit 0724277

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

lib/web3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ pub fn get_eth_events(
13791379
to_block: u64,
13801380
topics: &Vec<B256>,
13811381
) -> Result<Vec<Log>, ValidationError> {
1382-
println!("Quering events from {} to {}", from_block, to_block);
1382+
println!("Querying events from {} to {}", from_block, to_block);
13831383
let from_block_hex = format!("{:#x}", from_block);
13841384
let to_block_hex = format!("{:#x}", to_block);
13851385
let request_body = json!({

src/dvf.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ fn validate_dvf(
221221

222222
if num_occurrences + seen_events.len() > num_occurrences_expected {
223223
return Err(ValidationError::Invalid(format!(
224-
"Found at least {} occurrences of event {}, but expected {}.",
225-
num_occurrences + seen_events.len(),
224+
"Found more occurrences of event {} than expected ({}).",
226225
critical_event.sig,
227226
num_occurrences_expected
228227
)));
@@ -264,6 +263,14 @@ fn validate_dvf(
264263
current_from = current_to + 1;
265264
}
266265

266+
if num_occurrences < num_occurrences_expected {
267+
return Err(ValidationError::Invalid(format!(
268+
"Found less occurrences of event {} than expected ({}).",
269+
critical_event.sig,
270+
num_occurrences_expected
271+
)));
272+
}
273+
267274
pb.inc(1);
268275
}
269276

@@ -304,7 +311,7 @@ fn validate_dvf(
304311
registry,
305312
seen_ids,
306313
allow_untrusted,
307-
false,
314+
continue_on_mismatch,
308315
Some(reference.contract_name.clone()),
309316
));
310317
}

tests/test_end_to_end.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ mod tests {
13921392
let output = String::from_utf8_lossy(&dvf_assert.get_output().stdout);
13931393
println!("{}", &output);
13941394

1395-
assert!(output.contains("Deployment invalid: Found at least 3 occurrences of event Huh((uint256,address,bool,uint64[6],uint128)), but expected 2"), "The string does not contain the required text.");
1395+
assert!(output.contains("Deployment invalid: Found more occurrences of event Huh((uint256,address,bool,uint64[6],uint128)) than expected (2)."));
13961396
drop(local_client);
13971397
}
13981398
}

0 commit comments

Comments
 (0)