We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f7274a5 commit d1f3976Copy full SHA for d1f3976
primitives/src/locktime/relative.rs
@@ -7,6 +7,9 @@
7
8
use core::{convert, fmt};
9
10
+#[cfg(feature = "arbitrary")]
11
+use arbitrary::{Arbitrary, Unstructured};
12
+
13
use internals::write_err;
14
15
use crate::Sequence;
@@ -517,6 +520,16 @@ impl std::error::Error for IsSatisfiedByTimeError {
517
520
}
518
521
519
522
523
524
+impl<'a> Arbitrary<'a> for LockTime {
525
+ fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
526
+ match bool::arbitrary(u)? {
527
+ true => Ok(LockTime::Blocks(NumberOfBlocks::arbitrary(u)?)),
528
+ false => Ok(LockTime::Time(NumberOf512Seconds::arbitrary(u)?))
529
+ }
530
531
+}
532
533
#[cfg(test)]
534
mod tests {
535
use units::{BlockHeight, BlockTime};
0 commit comments