Skip to content

Commit 4d32168

Browse files
committed
primitives - get_cfg_response - update example:
- primitives - Config - Derive Eq & PartialEq - compare with GANACHE_CONFIG
1 parent 0419a7e commit 4d32168

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

primitives/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ name = "validator_messages_list_response"
7777

7878
[[example]]
7979
name = "get_cfg_response"
80+
required-features = ["test-util"]
8081

8182
[dependencies]
8283
# (De)Serialization

primitives/examples/get_cfg_response.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use primitives::Config;
1+
use primitives::{config::GANACHE_CONFIG, Config};
22
use serde_json::{from_value, json};
33

44
fn main() {
@@ -22,8 +22,16 @@ fn main() {
2222
"type": "ip",
2323
"timeframe": 1200000
2424
},
25-
"creators_whitelist": [],
26-
"validators_whitelist": [],
25+
"creators_whitelist": [
26+
"0xaCBaDA2d5830d1875ae3D2de207A1363B316Df2F",
27+
"0xDd589B43793934EF6Ad266067A0d1D4896b0dff0",
28+
"0x541b401362Ea1D489D322579552B099e801F3632"
29+
],
30+
"validators_whitelist": [
31+
"0x80690751969B234697e9059e04ed72195c3507fa",
32+
"0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7",
33+
"0x6B83e7D6B72c098d48968441e0d05658dc17Adb9"
34+
],
2735
"admins": [
2836
"0x80690751969B234697e9059e04ed72195c3507fa"
2937
],
@@ -66,5 +74,8 @@ fn main() {
6674
}
6775
}
6876
});
69-
assert!(from_value::<Config>(json).is_ok());
77+
assert_eq!(
78+
from_value::<Config>(json).expect("Should deserialize"),
79+
GANACHE_CONFIG.clone()
80+
);
7081
}

primitives/src/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl Default for Environment {
5151
/// ```
5252
#[doc = include_str!("../../primitives/examples/get_cfg_response.rs")]
5353
/// ```
54-
#[derive(Serialize, Deserialize, Debug, Clone)]
54+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
5555
pub struct Config {
5656
/// The maximum number of [`Channel`](crate::Channel)s that the worker
5757
/// can process for one tick.
@@ -211,7 +211,7 @@ impl Config {
211211
}
212212
}
213213

214-
#[derive(Serialize, Deserialize, Debug, Clone)]
214+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
215215
pub struct PlatformConfig {
216216
pub url: ApiUrl,
217217
#[serde(with = "std_duration_millis")]
@@ -247,7 +247,7 @@ pub struct TokenInfo {
247247
pub address: Address,
248248
}
249249

250-
#[derive(Serialize, Deserialize, Debug, Clone)]
250+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
251251
pub struct Limits {
252252
pub units_for_slot: limits::UnitsForSlot,
253253
}
@@ -289,7 +289,7 @@ pub mod limits {
289289
use crate::UnifiedNum;
290290

291291
/// Limits applied to the `POST /units-for-slot` route
292-
#[derive(Serialize, Deserialize, Debug, Clone)]
292+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
293293
pub struct UnitsForSlot {
294294
/// The maximum number of campaigns a publisher can earn from.
295295
/// This will limit the returned Campaigns to the set number.

0 commit comments

Comments
 (0)