Add serde roundtrip tests to relative locktime types

As we do for absolute locktime types add a couple of `serde` roundtrip
tests to the relative locktime types.
This commit is contained in:
Tobin C. Harding 2025-01-06 17:56:15 +11:00
parent b0ec566742
commit 55a999e0b5
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 19 additions and 0 deletions

View File

@ -191,6 +191,9 @@ impl<'a> Arbitrary<'a> for Time {
#[cfg(test)]
mod tests {
#[cfg(feature = "serde")]
use internals::serde_round_trip;
use super::*;
const MAXIMUM_ENCODABLE_SECONDS: u32 = u16::MAX as u32 * 512;
@ -248,4 +251,20 @@ mod tests {
let result = Time::from_seconds_floor(MAXIMUM_ENCODABLE_SECONDS + 512);
assert!(result.is_err());
}
#[test]
#[cfg(feature = "serde")]
pub fn encode_decode_height() {
serde_round_trip!(Height::ZERO);
serde_round_trip!(Height::MIN);
serde_round_trip!(Height::MAX);
}
#[test]
#[cfg(feature = "serde")]
pub fn encode_decode_time() {
serde_round_trip!(Time::ZERO);
serde_round_trip!(Time::MIN);
serde_round_trip!(Time::MAX);
}
}