Merge rust-bitcoin/rust-bitcoin#3863: Add serde roundtrip tests to relative locktime types
55a999e0b5
Add serde roundtrip tests to relative locktime types (Tobin C. Harding)
Pull request description:
As we do for absolute locktime types add a couple of `serde` roundtrip tests to the relative locktime types.
ACKs for top commit:
apoelstra:
ACK 55a999e0b5c5867ed66ee64d2b516b80e059e402; successfully ran local tests
Tree-SHA512: 28923a0e2c2053a7346e91a21619dc5d2700ea131aa5ec5a5f6d89d09c70cb45ce9731055bbcc1447d46d5dbe231cb075436dd682229ee8530307e199af54ce2
This commit is contained in:
commit
4dd2c04ce9
|
@ -191,6 +191,9 @@ impl<'a> Arbitrary<'a> for Time {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
#[cfg(feature = "serde")]
|
||||||
|
use internals::serde_round_trip;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const MAXIMUM_ENCODABLE_SECONDS: u32 = u16::MAX as u32 * 512;
|
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);
|
let result = Time::from_seconds_floor(MAXIMUM_ENCODABLE_SECONDS + 512);
|
||||||
assert!(result.is_err());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue