Skip to content

Commit 0448ade

Browse files
committed
assert that expected is a valid address
1 parent f1cf34f commit 0448ade

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/addr.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ mod proofs {
803803
let same = Step::forward(start, 0);
804804
assert!(start == same);
805805

806-
// Verify that we can add 1 to any address.
806+
// Manually calculate the expected address after stepping once.
807807
let expected = match start_raw {
808808
// Adding 1 to addresses in this range don't require gap jumps, so
809809
// we can just add 1.
@@ -818,6 +818,11 @@ mod proofs {
818818
// Adding 1 to this address causes an overflow.
819819
0xffff_ffff_ffff_ffff => None,
820820
};
821+
if let Some(expected) = expected {
822+
// Verify that `expected` is a valid address.
823+
assert!(VirtAddr::try_new(expected).is_ok());
824+
}
825+
// Verify `forward_checked`.
821826
let next = Step::forward_checked(start, 1);
822827
assert!(next.map(VirtAddr::as_u64) == expected);
823828
}

0 commit comments

Comments
 (0)