diff --git a/tendermint/Cargo.toml b/tendermint/Cargo.toml index d79dca3b9..9a0b9f5a7 100644 --- a/tendermint/Cargo.toml +++ b/tendermint/Cargo.toml @@ -52,6 +52,7 @@ ed25519-consensus = { version = "2", optional = true, default-features = false } sha2 = { version = "0.10", optional = true, default-features = false } k256 = { version = "0.13", optional = true, default-features = false, features = ["alloc", "ecdsa"] } ripemd = { version = "0.1.3", optional = true, default-features = false } +arbitrary = { version = "1.3.2", features = ["derive"], optional = true } [features] default = ["std", "rust-crypto"] @@ -59,6 +60,7 @@ std = ["flex-error/std", "clock"] clock = ["time/std"] secp256k1 = ["k256", "ripemd"] rust-crypto = ["sha2", "ed25519-consensus"] +arbitrary = ["dep:arbitrary"] [dev-dependencies] k256 = { version = "0.13", default-features = false, features = ["ecdsa"] } diff --git a/tendermint/src/account.rs b/tendermint/src/account.rs index 069918bc2..32176e4dd 100644 --- a/tendermint/src/account.rs +++ b/tendermint/src/account.rs @@ -19,6 +19,7 @@ pub const LENGTH: usize = 20; /// Account IDs #[derive(Copy, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct Id([u8; LENGTH]); // JSON custom serialization for priv_validator_key.json impl Protobuf> for Id {} diff --git a/tendermint/src/crypto/ed25519/verification_key.rs b/tendermint/src/crypto/ed25519/verification_key.rs index 9ef90c3e8..5161c2c83 100644 --- a/tendermint/src/crypto/ed25519/verification_key.rs +++ b/tendermint/src/crypto/ed25519/verification_key.rs @@ -1,6 +1,7 @@ use crate::Error; #[derive(Copy, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct VerificationKey([u8; 32]); impl core::fmt::Display for VerificationKey { diff --git a/tendermint/src/public_key.rs b/tendermint/src/public_key.rs index f17cc5c25..7d28a8e0d 100644 --- a/tendermint/src/public_key.rs +++ b/tendermint/src/public_key.rs @@ -31,6 +31,7 @@ use crate::{error::Error, prelude::*}; #[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[non_exhaustive] #[serde(tag = "type", content = "value")] // JSON custom serialization for priv_validator_key.json +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub enum PublicKey { /// Ed25519 keys #[serde( diff --git a/tendermint/src/validator.rs b/tendermint/src/validator.rs index 7db1a7cef..4147a0c8c 100644 --- a/tendermint/src/validator.rs +++ b/tendermint/src/validator.rs @@ -145,6 +145,7 @@ impl Set { /// Validator information // Todo: Remove address and make it into a function that generates it on the fly from pub_key. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct Info { /// Validator account address pub address: account::Id, @@ -228,6 +229,7 @@ impl Info { // Todo: Is there more knowledge/restrictions about proposerPriority? /// Proposer priority #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Default)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct ProposerPriority(i64); impl From for ProposerPriority { diff --git a/tendermint/src/vote/power.rs b/tendermint/src/vote/power.rs index 7ebf6e56a..5f3a0653e 100644 --- a/tendermint/src/vote/power.rs +++ b/tendermint/src/vote/power.rs @@ -8,6 +8,7 @@ use crate::{error::Error, prelude::*}; /// Voting power #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Default)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct Power(u64); impl fmt::Display for Power {