Skip to content

Commit

Permalink
Add a ±10% tolerance for gas usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Lacy committed Sep 19, 2022
1 parent bae2177 commit b0a1278
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions contracts/tg4-mixer/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn main() {

println!();
for (poe_fn_name, poe_fn, result, gas) in [
("GeometricMean", GeometricMean {}, 22360, 5729550000),
("GeometricMean", GeometricMean {}, 22360, 5729550000i64),
(
"Sigmoid",
Sigmoid { max_points, p, s },
Expand Down Expand Up @@ -99,6 +99,10 @@ fn main() {
"{} result",
poe_fn_name
);
assert_eq!(gas, gas_used, "{} gas", poe_fn_name);
assert!(
(gas - gas_used as i64).abs() < gas / 10,
"{} gas",
poe_fn_name
);
}
}

0 comments on commit b0a1278

Please sign in to comment.