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 = CardanoTransactionsSigningConfig::dummy();
58
59 AggregatorEpochSettings {
61 protocol_parameters,
62 cardano_transactions_signing_config,
63 }
64 }
65 }
66
67 impl Dummy for LeaderAggregatorEpochSettings {
68 fn dummy() -> Self {
70 let beacon = fake_data::beacon();
72
73 let registration_protocol_parameters = fake_data::protocol_parameters();
75
76 let signers = fake_data::signers(5);
78 let current_signers = signers[1..3].to_vec();
79 let next_signers = signers[2..5].to_vec();
80
81 let cardano_transactions_signing_config =
83 Some(CardanoTransactionsSigningConfig::dummy());
84 let next_cardano_transactions_signing_config =
85 Some(CardanoTransactionsSigningConfig::dummy());
86
87 LeaderAggregatorEpochSettings {
89 epoch: beacon.epoch,
90 registration_protocol_parameters,
91 current_signers,
92 next_signers,
93 cardano_transactions_signing_config,
94 next_cardano_transactions_signing_config,
95 }
96 }
97 }
98
99 impl Dummy for OpenMessage {
100 fn dummy() -> Self {
101 let beacon = fake_data::beacon();
102 let epoch = beacon.epoch;
103 let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon);
104
105 Self {
106 epoch,
107 signed_entity_type,
108 protocol_message: ProtocolMessage::new(),
109 is_certified: false,
110 is_expired: false,
111 single_signatures: vec![
112 fake_data::single_signature(vec![1, 4, 5]),
113 fake_data::single_signature(vec![2, 3, 8]),
114 ],
115 created_at: Utc::now(),
116 expires_at: None,
117 }
118 }
119 }
120}