Rlp decode returns Result (#8527)
rlp::decode returns Result Make a best effort to handle decoding errors gracefully throughout the code, using `expect` where the value is guaranteed to be valid (and in other places where it makes sense).
This commit is contained in:
@@ -209,8 +209,10 @@ struct VDTestPair<T>(Vec<T>, Vec<u8>) where T: Decodable + fmt::Debug + cmp::Eq;
|
||||
|
||||
fn run_decode_tests<T>(tests: Vec<DTestPair<T>>) where T: Decodable + fmt::Debug + cmp::Eq {
|
||||
for t in &tests {
|
||||
let res: T = rlp::decode(&t.1);
|
||||
assert_eq!(res, t.0);
|
||||
let res : Result<T, DecoderError> = rlp::decode(&t.1);
|
||||
assert!(res.is_ok());
|
||||
let res = res.unwrap();
|
||||
assert_eq!(&res, &t.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user