From a6a9957fb8a41863d4772ecc8d4cb1d0e7d7a9dc Mon Sep 17 00:00:00 2001 From: ade <93547199+oxade@users.noreply.github.com> Date: Fri, 11 Feb 2022 02:39:41 -0500 Subject: [PATCH] Prevent fail on u8 overflow (#418) * Prevent u8 overflow --- fastpay_core/src/unit_tests/authority_tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fastpay_core/src/unit_tests/authority_tests.rs b/fastpay_core/src/unit_tests/authority_tests.rs index 47a177f1f08c3..e37f3651664e7 100644 --- a/fastpay_core/src/unit_tests/authority_tests.rs +++ b/fastpay_core/src/unit_tests/authority_tests.rs @@ -1165,7 +1165,8 @@ async fn test_get_latest_parent_entry() { // The objects just after the gas object also returns None let mut x = gas_object_id.to_vec(); let last_index = x.len() - 1; - x[last_index] += 1; + // Prevent overflow + x[last_index] = u8::MAX - x[last_index]; let unknown_object_id: ObjectID = x.try_into().unwrap(); assert!(authority_state .get_latest_parent_entry(unknown_object_id)