Skip to content

Commit 84b67d3

Browse files
shinghimyancyribbens
authored andcommitted
Add arbitrary impl for ProprietaryKey and Key
cherry-pick of: caa4b91
1 parent fb0adf1 commit 84b67d3

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

bitcoin/src/psbt/raw.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
99
use core::fmt;
1010

11+
#[cfg(feature = "arbitrary")]
12+
use actual_arbitrary::{self as arbitrary, Arbitrary, Unstructured};
1113
use io::{Read, Write};
1214

1315
use super::serialize::{Deserialize, Serialize};
@@ -198,3 +200,21 @@ where
198200
Ok(deserialize(&key.key)?)
199201
}
200202
}
203+
204+
#[cfg(feature = "arbitrary")]
205+
impl<'a> Arbitrary<'a> for ProprietaryKey {
206+
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
207+
Ok(ProprietaryKey {
208+
prefix: Vec::<u8>::arbitrary(u)?,
209+
subtype: u8::arbitrary(u)?,
210+
key: Vec::<u8>::arbitrary(u)?,
211+
})
212+
}
213+
}
214+
215+
#[cfg(feature = "arbitrary")]
216+
impl<'a> Arbitrary<'a> for Key {
217+
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
218+
Ok(Key { type_value: u.arbitrary()?, key: Vec::<u8>::arbitrary(u)? })
219+
}
220+
}

0 commit comments

Comments
 (0)