Skip to content

Commit 36a6513

Browse files
committed
dummy channel
1 parent e8ade59 commit 36a6513

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

primitives/src/channel_fixtures.rs

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use chrono::{DateTime, Utc};
1+
use chrono::{DateTime, TimeZone, Utc};
22
use fake::faker::*;
33
use time::Duration;
44

55
use crate::targeting_tag::fixtures::get_targeting_tags;
66
use crate::validator::fixtures::get_validator;
7-
use crate::BigNum;
7+
use crate::{BigNum, EventSubmission};
88

99
use super::{Channel, ChannelSpec, SpecValidators, ValidatorDesc};
1010
use crate::util::tests::take_one;
@@ -27,6 +27,44 @@ const ASSETS_LIST: [&str; 8] = ["DAI", "BGN", "EUR", "USD", "ADX", "BTC", "LIT",
2727
// ChannelId { bytes: id }
2828
//}
2929

30+
pub fn get_dummy_channel() -> Channel {
31+
let leader = ValidatorDesc {
32+
id: "awesomeLeader".to_string(),
33+
url: "http://localhost:8005".to_string(),
34+
fee: 100.into(),
35+
};
36+
let follower = ValidatorDesc {
37+
id: "awesomeFollower".to_string(),
38+
url: "http://localhost:8006".to_string(),
39+
fee: 100.into(),
40+
};
41+
let nonce = BigNum::from(<Faker as Number>::between(100_000_000, 999_999_999));
42+
43+
Channel {
44+
id: "awesomeTestChannel".to_string(),
45+
creator: "awesomeCreator".to_string(),
46+
deposit_asset: "DAI".to_string(),
47+
deposit_amount: 1_000.into(),
48+
// UNIX timestamp for 2100-01-01
49+
valid_until: Utc.timestamp(4_102_444_800, 0),
50+
spec: ChannelSpec {
51+
title: None,
52+
validators: SpecValidators([leader, follower]),
53+
max_per_impression: 10.into(),
54+
min_per_impression: 10.into(),
55+
targeting: vec![],
56+
min_targeting_score: None,
57+
event_submission: EventSubmission { allow: vec![] },
58+
// July 29, 2019 7:00:00 AM
59+
created: Utc.timestamp(1_564_383_600, 0),
60+
active_from: None,
61+
nonce,
62+
withdraw_period_start: Utc.timestamp_millis(4_073_414_400_000),
63+
ad_units: vec![],
64+
},
65+
}
66+
}
67+
3068
pub fn get_channel(
3169
id: &str,
3270
valid_until: &Option<DateTime<Utc>>,
@@ -80,8 +118,6 @@ pub enum ValidatorsOption<'a> {
80118
}
81119

82120
pub fn get_channel_spec(validators_option: ValidatorsOption<'_>) -> ChannelSpec {
83-
use crate::EventSubmission;
84-
85121
let validators = match validators_option {
86122
ValidatorsOption::Pair { leader, follower } => [leader, follower].into(),
87123
ValidatorsOption::SpecValidators(spec_validators) => spec_validators,

0 commit comments

Comments
 (0)