mithril_aggregator/test/double/
dummies.rs1use chrono::Utc;
2use uuid::Uuid;
3
4use mithril_common::test::double::{Dummy, fake_data};
5
6mod record {
7 use mithril_common::entities::{ProtocolMessage, SignedEntityType};
8
9 use crate::database::record::{ImmutableFileDigestRecord, OpenMessageRecord};
10
11 use super::*;
12
13 impl Dummy for ImmutableFileDigestRecord {
14 fn dummy() -> Self {
16 Self {
17 immutable_file_name: "123.chunk".to_string(),
18 digest: "dummy_digest".to_string(),
19 }
20 }
21 }
22
23 impl Dummy for OpenMessageRecord {
24 fn dummy() -> Self {
26 let beacon = fake_data::beacon();
27 let epoch = beacon.epoch;
28 let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon);
29
30 Self {
31 open_message_id: Uuid::parse_str("193d1442-e89b-43cf-9519-04d8db9a12ff").unwrap(),
32 epoch,
33 signed_entity_type,
34 protocol_message: ProtocolMessage::new(),
35 is_certified: false,
36 is_expired: false,
37 created_at: Utc::now(),
38 expires_at: None,
39 }
40 }
41 }
42}
43
44mod entities {
45 use mithril_common::entities::{
46 CardanoTransactionsSigningConfig, ProtocolMessage, SignedEntityType,
47 };
48
49 use crate::entities::{AggregatorEpochSettings, LeaderAggregatorEpochSettings, OpenMessage};
50
51 use super::*;
52
53 impl Dummy for AggregatorEpochSettings {
54 fn dummy() -> Self {
56 let protocol_parameters = fake_data::protocol_parameters();
57 let cardano_transactions_signing_config =
58 Some(CardanoTransactionsSigningConfig::dummy());
59
60 AggregatorEpochSettings {
62 protocol_parameters,
63 cardano_transactions_signing_config,
64 }
65 }
66 }
67
68 impl Dummy for LeaderAggregatorEpochSettings {
69 fn dummy() -> Self {
71 let beacon = fake_data::beacon();
72 let signers = fake_data::signers(5);
73
74 LeaderAggregatorEpochSettings {
75 epoch: beacon.epoch,
76 current_signers: signers[1..3].to_vec(),
77 next_signers: signers[2..5].to_vec(),
78 }
79 }
80 }
81
82 impl Dummy for OpenMessage {
83 fn dummy() -> Self {
84 let beacon = fake_data::beacon();
85 let epoch = beacon.epoch;
86 let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon);
87
88 Self {
89 epoch,
90 signed_entity_type,
91 protocol_message: ProtocolMessage::new(),
92 is_certified: false,
93 is_expired: false,
94 single_signatures: vec![
95 fake_data::single_signature(vec![1, 4, 5]),
96 fake_data::single_signature(vec![2, 3, 8]),
97 ],
98 created_at: Utc::now(),
99 expires_at: None,
100 }
101 }
102 }
103}