Remove usage of Cursor in multi key read

We do not need to know the position of the reader when reading multiple
keys, usage of `Cursor` is unnecessary.
This commit is contained in:
Tobin C. Harding 2024-01-18 08:42:56 +11:00
parent fa716fb638
commit 35b5350088
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 3 additions and 4 deletions

View File

@ -1096,16 +1096,15 @@ mod tests {
k.write_into(&mut v).expect("writing into vec"); k.write_into(&mut v).expect("writing into vec");
} }
let mut reader = v.as_slice();
let mut dec_keys = vec![]; let mut dec_keys = vec![];
let mut cursor = io::Cursor::new(&v);
for _ in 0..N_KEYS { for _ in 0..N_KEYS {
dec_keys.push(PublicKey::read_from(&mut cursor).expect("reading from vec")); dec_keys.push(PublicKey::read_from(&mut reader).expect("reading from vec"));
} }
assert_eq!(keys, dec_keys); assert_eq!(keys, dec_keys);
assert!(PublicKey::read_from(&mut reader).is_err());
// sanity checks // sanity checks
assert!(PublicKey::read_from(&mut cursor).is_err());
assert!(PublicKey::read_from(&mut io::Cursor::new(&[])).is_err()); assert!(PublicKey::read_from(&mut io::Cursor::new(&[])).is_err());
assert!(PublicKey::read_from(&mut io::Cursor::new(&[0; 33][..])).is_err()); assert!(PublicKey::read_from(&mut io::Cursor::new(&[0; 33][..])).is_err());
assert!(PublicKey::read_from(&mut io::Cursor::new(&[2; 32][..])).is_err()); assert!(PublicKey::read_from(&mut io::Cursor::new(&[2; 32][..])).is_err());