From 0448ade4feb6d1cb7c16a468f4bc87e5e0966592 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Thu, 29 Feb 2024 19:01:02 +0100 Subject: [PATCH] assert that expected is a valid address --- src/addr.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/addr.rs b/src/addr.rs index 2002eafe..2959d7de 100644 --- a/src/addr.rs +++ b/src/addr.rs @@ -803,7 +803,7 @@ mod proofs { let same = Step::forward(start, 0); assert!(start == same); - // Verify that we can add 1 to any address. + // Manually calculate the expected address after stepping once. let expected = match start_raw { // Adding 1 to addresses in this range don't require gap jumps, so // we can just add 1. @@ -818,6 +818,11 @@ mod proofs { // Adding 1 to this address causes an overflow. 0xffff_ffff_ffff_ffff => None, }; + if let Some(expected) = expected { + // Verify that `expected` is a valid address. + assert!(VirtAddr::try_new(expected).is_ok()); + } + // Verify `forward_checked`. let next = Step::forward_checked(start, 1); assert!(next.map(VirtAddr::as_u64) == expected); }