From b25b74f5f09db0c6b07e78e23637cc52db3e66d5 Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Mon, 5 Aug 2024 09:22:31 -0500 Subject: [PATCH] add test for non-1 offset --- transaction-view/src/signature_meta.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/transaction-view/src/signature_meta.rs b/transaction-view/src/signature_meta.rs index 9c3003d633310d..9e511068c02147 100644 --- a/transaction-view/src/signature_meta.rs +++ b/transaction-view/src/signature_meta.rs @@ -79,6 +79,17 @@ mod tests { assert_eq!(offset, 1 + 12 * core::mem::size_of::()); } + #[test] + fn test_non_zero_offset() { + let mut bytes = bincode::serialize(&ShortVec(vec![Signature::default()])).unwrap(); + bytes.insert(0, 0); // Insert a byte at the beginning of the packet. + let mut offset = 1; // Start at the second byte. + let meta = SignatureMeta::try_new(&bytes, &mut offset).unwrap(); + assert_eq!(meta.num_signatures, 1); + assert_eq!(meta.offset, 2); + assert_eq!(offset, 2 + core::mem::size_of::()); + } + #[test] fn test_too_many_signatures() { let signatures = vec![Signature::default(); 13];