Skip to content

Commit 1d18030

Browse files
committed
fix: .accept()
1 parent 58278e7 commit 1d18030

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

src/est.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl SearchRange {
3434

3535
/// Calculate the midpoint of the search range.
3636
pub(crate) const fn midpoint(&self) -> u64 {
37-
(self.max() + self.min()) / 2
37+
((self.max() as u128 + self.min() as u128) / 2) as u64
3838
}
3939

4040
/// Get the start of the search range.
@@ -272,6 +272,33 @@ impl EstimationResult {
272272
}
273273
}
274274

275+
#[cfg(test)]
276+
mod tests {
277+
use super::*;
278+
279+
#[test]
280+
fn test_search_range() {
281+
let mut range = SearchRange::new(100, 200);
282+
assert_eq!(range.min(), 100);
283+
assert_eq!(range.max(), 200);
284+
assert_eq!(range.size(), 100);
285+
assert_eq!(range.ratio(), 0.5);
286+
assert_eq!(range.midpoint(), 150);
287+
assert!(range.contains(150));
288+
289+
range.maybe_raise_min(100);
290+
assert_eq!(range.min(), 100);
291+
292+
range.maybe_raise_min(125);
293+
assert_eq!(range.min(), 125);
294+
assert_eq!(range.midpoint(), 162);
295+
296+
range.maybe_lower_max(180);
297+
assert_eq!(range.max(), 180);
298+
assert_eq!(range.midpoint(), 152);
299+
}
300+
}
301+
275302
// Some code above is reproduced from `reth`. It is reused here under the MIT
276303
// license.
277304
//

src/evm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,14 +2432,14 @@ mod tests {
24322432

24332433
let tx = tx.with_gas_limit(estimation.limit());
24342434

2435-
let mut output = trevm.clear_tx().fill_tx(&tx).run().unwrap();
2435+
let mut output = trevm.clear_tx().fill_tx(&tx).run().unwrap().accept();
24362436

2437-
let bob_code = output.read_code(BOB.address());
2437+
let bob_code = output.1.read_code(BOB.address());
24382438
dbg!(&bob_code);
24392439

2440-
dbg!(&output.result());
2441-
assert!(output.result().is_success());
2442-
assert!(output.result().logs().len() == 1);
2440+
dbg!(&output.0);
2441+
assert!(output.0.is_success());
2442+
assert!(output.0.logs().len() == 1);
24432443
}
24442444
}
24452445

0 commit comments

Comments
 (0)