Skip to content

Commit 3a78b4c

Browse files
committed
primitives - validator fixtures
1 parent 32a9f3e commit 3a78b4c

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

primitives/src/validator.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
use crate::Channel;
2-
use crate::{BalancesMap, BigNum};
1+
use std::pin::Pin;
2+
33
use chrono::{DateTime, Utc};
44
use futures::prelude::*;
55
use serde::{Deserialize, Serialize};
6-
use std::pin::Pin;
6+
7+
use crate::Channel;
8+
use crate::{BalancesMap, BigNum};
79

810
pub type ValidatorFuture<T> = Pin<Box<dyn Future<Output = Result<T, ValidatorError>> + Send>>;
911

@@ -104,3 +106,22 @@ pub enum MessageTypes {
104106
Heartbeat(Heartbeat),
105107
Accounting(Accounting),
106108
}
109+
110+
pub mod fixtures {
111+
use fake::faker::*;
112+
113+
use crate::BigNum;
114+
115+
use super::ValidatorDesc;
116+
117+
pub fn get_validator<V: AsRef<str>>(validator_id: V, fee: Option<BigNum>) -> ValidatorDesc {
118+
let fee = fee.unwrap_or_else(|| BigNum::from(<Faker as Number>::between(1, 13)));
119+
let url = format!(
120+
"http://{}-validator-url.com/validator",
121+
validator_id.as_ref()
122+
);
123+
let id = validator_id.as_ref().to_string();
124+
125+
ValidatorDesc { id, url, fee }
126+
}
127+
}

0 commit comments

Comments
 (0)