Skip to content

Commit

Permalink
Bump serdect to v0.3.0-rc.0 (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri authored Sep 10, 2024
1 parent db9d587 commit 9cc3e4a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ hybrid-array = { version = "0.2.0-rc.8", optional = true }
num-traits = { version = "0.2.19", default-features = false }
rand_core = { version = "0.6.4", optional = true }
rlp = { version = "0.5", optional = true, default-features = false }
serdect = { version = "0.2", optional = true, default-features = false }
serdect = { version = "=0.3.0-rc.0", optional = true, default-features = false }
zeroize = { version = "1", optional = true, default-features = false }

[dev-dependencies]
Expand Down
32 changes: 0 additions & 32 deletions src/odd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ mod tests {
#[cfg(feature = "serde")]
mod serde_tests {
use crate::{Odd, U128, U64};
use alloc::string::ToString;
use bincode::ErrorKind;

#[test]
Expand Down Expand Up @@ -302,36 +301,5 @@ mod tests {
ErrorKind::Custom(mess) if mess == "invalid value: even, expected a non-zero odd value"
))
}

#[test]
fn cannot_deserialize_into_bigger_type() {
let three = Odd::new(U64::from_u64(0x3)).unwrap();
let three_ser = bincode::serialize(&three).unwrap();
let error_message = bincode::deserialize::<Odd<U128>>(&three_ser)
.unwrap_err()
.to_string();

assert_eq!(&error_message, "io error: unexpected end of file");
}

#[test]
fn silently_coerces_bigger_type_into_smaller_type() {
use bincode::Options;

// Use custom options to disallow trailing bytes.
let options = bincode::DefaultOptions::new();

let three = Odd::new(U128::from_u128(0x77777777777777773333333333333333)).unwrap();
let three_ser = options.serialize(&three).unwrap();
let error_message = options
.deserialize::<Odd<U64>>(&three_ser)
.unwrap_err()
.to_string();

assert_eq!(
&error_message,
"Slice had bytes remaining after deserialization"
);
}
}
}

0 comments on commit 9cc3e4a

Please sign in to comment.