Skip to content

Commit

Permalink
add test for non-1 offset
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Aug 5, 2024
1 parent 68a6762 commit b25b74f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions transaction-view/src/signature_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ mod tests {
assert_eq!(offset, 1 + 12 * core::mem::size_of::<Signature>());
}

#[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::<Signature>());
}

#[test]
fn test_too_many_signatures() {
let signatures = vec![Signature::default(); 13];
Expand Down

0 comments on commit b25b74f

Please sign in to comment.