Skip to content

Commit

Permalink
Implement Message::inv_strategy()
Browse files Browse the repository at this point in the history
A method to return a proptest strategy that creates `Message::Inv`
instances.
  • Loading branch information
jvff committed Jul 6, 2021
1 parent 423dfc1 commit 3f1ba69
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion zebra-network/src/protocol/external/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::convert::TryInto;

use proptest::{arbitrary::any, arbitrary::Arbitrary, collection::vec, prelude::*};

use super::{types::PeerServices, InventoryHash};
use super::{types::PeerServices, InventoryHash, Message};

use zebra_chain::{block, transaction};

Expand Down Expand Up @@ -90,3 +90,10 @@ impl Arbitrary for PeerServices {

type Strategy = BoxedStrategy<Self>;
}

impl Message {
/// Create a strategy that only generates [`Message::Inv`] messages.
pub fn inv_strategy() -> BoxedStrategy<Self> {
any::<Vec<InventoryHash>>().prop_map(Message::Inv).boxed()
}
}

0 comments on commit 3f1ba69

Please sign in to comment.