mithril_common/test/double/
dummies.rs

1use chrono::{DateTime, Utc};
2
3use crate::test::double::{Dummy, fake_data, fake_keys};
4
5mod entities {
6    use crate::crypto_helper::MKTreeStoreInMemory;
7    use crate::entities::*;
8    use crate::test::entities_extensions::CardanoTransactionsSetProofTestExtension;
9
10    use super::*;
11
12    impl Dummy for ChainPoint {
13        /// Return a dummy [ChainPoint] (test-only).
14        fn dummy() -> Self {
15            Self {
16                slot_number: SlotNumber(100),
17                block_number: BlockNumber(0),
18                block_hash: "block_hash-50".to_string(),
19            }
20        }
21    }
22
23    impl Dummy for CardanoTransactionsSetProof {
24        /// Return a dummy [CardanoTransactionsSetProof] (test-only).
25        fn dummy() -> Self {
26            let leaves = vec![
27                (BlockNumber(0), "tx-1".to_string()),
28                (BlockNumber(1), "tx-2".to_string()),
29                (BlockNumber(1), "tx-3".to_string()),
30                (BlockNumber(10), "tx-4".to_string()),
31                (BlockNumber(20), "tx-5".to_string()),
32                (BlockNumber(22), "tx-6".to_string()),
33            ];
34
35            Self::from_leaves::<MKTreeStoreInMemory>(&leaves).unwrap()
36        }
37    }
38
39    impl Dummy for SignedEntityConfig {
40        /// Return a dummy [SignedEntityConfig] (test-only).
41        fn dummy() -> Self {
42            Self {
43                allowed_discriminants: SignedEntityTypeDiscriminants::all(),
44                cardano_transactions_signing_config: Some(CardanoTransactionsSigningConfig::dummy()),
45            }
46        }
47    }
48
49    impl Dummy for CardanoTransactionsSigningConfig {
50        /// Return a dummy [CardanoTransactionsSigningConfig] (test-only).
51        fn dummy() -> Self {
52            Self {
53                security_parameter: BlockNumber(0),
54                step: BlockNumber(15),
55            }
56        }
57    }
58
59    impl Dummy for SignedEntityType {
60        /// Return a dummy [SignedEntityType] (test-only).
61        fn dummy() -> Self {
62            Self::MithrilStakeDistribution(Epoch(5))
63        }
64    }
65
66    impl Dummy for SupportedEra {
67        /// Return a dummy [SupportedEra] (test-only).
68        fn dummy() -> Self {
69            Self::eras().first().unwrap().to_owned()
70        }
71    }
72
73    impl Dummy for TimePoint {
74        /// Return a dummy [TimePoint] (test-only).
75        fn dummy() -> Self {
76            Self::new(10, 100, ChainPoint::dummy())
77        }
78    }
79
80    impl Dummy for ClientError {
81        /// Return a dummy [ClientError] (test-only).
82        fn dummy() -> Self {
83            Self::new("error", "error message")
84        }
85    }
86
87    impl Dummy for ServerError {
88        /// Return a dummy [ServerError] (test-only).
89        fn dummy() -> Self {
90            Self::new("error")
91        }
92    }
93}
94
95mod messages {
96    use std::collections::BTreeSet;
97
98    use chrono::Duration;
99
100    use mithril_stm::AggregateSignatureType;
101
102    use crate::crypto_helper::KesEvolutions;
103    use crate::entities::{
104        AncillaryLocation, BlockNumber, CardanoDbBeacon, CardanoTransactionsSetProof,
105        CardanoTransactionsSigningConfig, CompressionAlgorithm, DigestLocation, Epoch,
106        ImmutablesLocation, MultiFilesUri, ProtocolMessage, ProtocolMessagePartKey,
107        ProtocolParameters, SignedEntityType, SignedEntityTypeDiscriminants, StakeDistribution,
108        StakeDistributionParty, SupportedEra, TemplateUri,
109    };
110    use crate::messages::*;
111
112    use super::*;
113
114    impl Dummy for CardanoTransactionsSetProofMessagePart {
115        /// Return a dummy [CardanoTransactionsSetProofMessagePart] (test-only).
116        fn dummy() -> Self {
117            CardanoTransactionsSetProof::dummy().try_into().unwrap()
118        }
119    }
120
121    impl Dummy for CertificateMetadataMessagePart {
122        /// Return a dummy [CertificateMetadataMessagePart] (test-only).
123        fn dummy() -> Self {
124            let initiated_at = DateTime::parse_from_rfc3339("2024-02-12T13:11:47Z")
125                .unwrap()
126                .with_timezone(&Utc);
127
128            Self {
129                network: "testnet".to_string(),
130                protocol_version: "0.1.0".to_string(),
131                protocol_parameters: ProtocolParameters::new(1000, 100, 0.123),
132                initiated_at,
133                sealed_at: initiated_at + Duration::try_seconds(100).unwrap(),
134                signers: vec![
135                    StakeDistributionParty {
136                        party_id: "1".to_string(),
137                        stake: 10,
138                    },
139                    StakeDistributionParty {
140                        party_id: "2".to_string(),
141                        stake: 20,
142                    },
143                ],
144            }
145        }
146    }
147
148    impl Dummy for SignerWithStakeMessagePart {
149        /// Return a dummy [SignerWithStakeMessagePart] (test-only).
150        fn dummy() -> Self {
151            Self {
152                party_id: "pool1m8crhnqj5k2kyszf5j2scshupystyxc887zdfrpzh6ty6eun4fx".to_string(),
153                verification_key: fake_keys::signer_verification_key()[0].to_string(),
154                verification_key_signature: Some(
155                    fake_keys::signer_verification_key_signature()[0].to_string(),
156                ),
157                operational_certificate: Some(fake_keys::operational_certificate()[0].to_string()),
158                kes_evolutions: Some(KesEvolutions(6)),
159                stake: 234,
160            }
161        }
162    }
163
164    impl Dummy for SignerMessagePart {
165        /// Return a dummy [SignerMessagePart] (test-only).
166        fn dummy() -> Self {
167            Self {
168                party_id: "pool1m8crhnqj5k2kyszf5j2scshupystyxc887zdfrpzh6ty6eun4fx".to_string(),
169                verification_key: fake_keys::signer_verification_key()[0].to_string(),
170                verification_key_signature: Some(
171                    fake_keys::signer_verification_key_signature()[0].to_string(),
172                ),
173                operational_certificate: Some(fake_keys::operational_certificate()[0].to_string()),
174                kes_evolutions: Some(KesEvolutions(6)),
175            }
176        }
177    }
178
179    impl Dummy for AggregatorFeaturesMessage {
180        /// Return a dummy [AggregatorFeaturesMessage] (test-only).
181        fn dummy() -> Self {
182            AggregatorFeaturesMessage {
183                open_api_version: "0.0.1".to_string(),
184                documentation_url: "https://example.com".to_string(),
185                capabilities: AggregatorCapabilities {
186                    signed_entity_types: BTreeSet::from([
187                        SignedEntityTypeDiscriminants::MithrilStakeDistribution,
188                    ]),
189                    aggregate_signature_type: AggregateSignatureType::Concatenation,
190                    cardano_transactions_prover: None,
191                },
192            }
193        }
194    }
195
196    impl Dummy for AggregatorStatusMessage {
197        /// Return a dummy [AggregatorStatusMessage] (test-only).
198        fn dummy() -> Self {
199            AggregatorStatusMessage {
200                epoch: Epoch(10),
201                cardano_era: "conway".to_string(),
202                cardano_network: "devnet".to_string(),
203                mithril_era: SupportedEra::Pythagoras,
204                cardano_node_version: "10.4.1".to_string(),
205                aggregator_node_version: "0.6.24".to_string(),
206                protocol_parameters: ProtocolParameters::new(1000, 100, 0.123),
207                next_protocol_parameters: ProtocolParameters::new(2000, 200, 0.321),
208                total_signers: 10,
209                total_next_signers: 15,
210                total_stakes_signers: 100_000,
211                total_next_stakes_signers: 150_000,
212                total_cardano_spo: 100,
213                total_cardano_stake: 1_000_000,
214            }
215        }
216    }
217
218    impl Dummy for CardanoDatabaseSnapshotMessage {
219        /// Return a dummy [CardanoDatabaseSnapshotMessage] (test-only).
220        fn dummy() -> Self {
221            Self {
222                hash: "d4071d518a3ace0f6c04a9c0745b9e9560e3e2af1b373bafc4e0398423e9abfb"
223                    .to_string(),
224                merkle_root: "c8224920b9f5ad7377594eb8a15f34f08eb3103cc5241d57cafc5638403ec7c6"
225                    .to_string(),
226                network: "preview".to_string(),
227                beacon: CardanoDbBeacon {
228                    epoch: Epoch(123),
229                    immutable_file_number: 2345,
230                },
231                certificate_hash:
232                    "f6c01b373bafc4e039844071d5da3ace4a9c0745b9e9560e3e2af01823e9abfb".to_string(),
233                total_db_size_uncompressed: 800796318,
234                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
235                    .unwrap()
236                    .with_timezone(&Utc),
237                digests: DigestsMessagePart {
238                    size_uncompressed: 1024,
239                    locations: vec![DigestLocation::Aggregator {
240                        uri: "https://host-1/digest-1".to_string(),
241                    }],
242                },
243                immutables: ImmutablesMessagePart {
244                    average_size_uncompressed: 512,
245                    locations: vec![
246                        ImmutablesLocation::CloudStorage {
247                            uri: MultiFilesUri::Template(TemplateUri(
248                                "https://host-1/immutables-2".to_string(),
249                            )),
250                            compression_algorithm: Some(CompressionAlgorithm::Gzip),
251                        },
252                        ImmutablesLocation::CloudStorage {
253                            uri: MultiFilesUri::Template(TemplateUri(
254                                "https://host-2/immutables-2".to_string(),
255                            )),
256                            compression_algorithm: Some(CompressionAlgorithm::Gzip),
257                        },
258                    ],
259                },
260                ancillary: AncillaryMessagePart {
261                    size_uncompressed: 2048,
262                    locations: vec![AncillaryLocation::CloudStorage {
263                        uri: "https://host-1/ancillary-3".to_string(),
264                        compression_algorithm: Some(CompressionAlgorithm::Gzip),
265                    }],
266                },
267                cardano_node_version: "0.0.1".to_string(),
268            }
269        }
270    }
271
272    impl Dummy for CardanoDatabaseDigestListItemMessage {
273        /// Return a dummy [CardanoDatabaseDigestListItemMessage] (test-only).
274        fn dummy() -> Self {
275            Self {
276                immutable_file_name: "06685.chunk".to_string(),
277                digest: "0af556ab2620dd9363bf76963a231abe8948a500ea6be31b131d87907ab09b1e"
278                    .to_string(),
279            }
280        }
281    }
282
283    impl Dummy for CardanoDatabaseImmutableFilesRestoredMessage {
284        /// Return a dummy [CardanoDatabaseImmutableFilesRestoredMessage] (test-only).
285        fn dummy() -> Self {
286            Self {
287                nb_immutable_files: 34,
288            }
289        }
290    }
291
292    impl Dummy for CardanoDatabaseSnapshotListItemMessage {
293        /// Return a dummy [CardanoDatabaseSnapshotListItemMessage] (test-only).
294        fn dummy() -> Self {
295            Self {
296                hash: "d4071d518a3ace0f6c04a9c0745b9e9560e3e2af1b373bafc4e0398423e9abfb"
297                    .to_string(),
298                merkle_root: "c8224920b9f5ad7377594eb8a15f34f08eb3103cc5241d57cafc5638403ec7c6"
299                    .to_string(),
300                beacon: CardanoDbBeacon {
301                    epoch: Epoch(123),
302                    immutable_file_number: 2345,
303                },
304                certificate_hash:
305                    "f6c01b373bafc4e039844071d5da3ace4a9c0745b9e9560e3e2af01823e9abfb".to_string(),
306                total_db_size_uncompressed: 800796318,
307                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
308                    .unwrap()
309                    .with_timezone(&Utc),
310                cardano_node_version: "0.0.1".to_string(),
311            }
312        }
313    }
314
315    impl Dummy for CardanoStakeDistributionMessage {
316        /// Return a dummy [CardanoStakeDistributionMessage] (test-only).
317        fn dummy() -> Self {
318            Self {
319                epoch: Epoch(1),
320                hash: "hash-123".to_string(),
321                certificate_hash: "cert-hash-123".to_string(),
322                stake_distribution: StakeDistribution::from([("pool-123".to_string(), 1000)]),
323                created_at: DateTime::parse_from_rfc3339("2024-07-29T16:15:05.618857482Z")
324                    .unwrap()
325                    .with_timezone(&Utc),
326            }
327        }
328    }
329
330    impl Dummy for CardanoStakeDistributionListItemMessage {
331        /// Return a dummy [CardanoStakeDistributionListItemMessage] (test-only).
332        fn dummy() -> Self {
333            Self {
334                epoch: Epoch(1),
335                hash: "hash-123".to_string(),
336                certificate_hash: "certificate-hash-123".to_string(),
337                created_at: DateTime::parse_from_rfc3339("2024-07-29T16:15:05.618857482Z")
338                    .unwrap()
339                    .with_timezone(&Utc),
340            }
341        }
342    }
343
344    impl Dummy for CardanoTransactionSnapshotMessage {
345        /// Return a dummy [CardanoTransactionSnapshotMessage] (test-only).
346        fn dummy() -> Self {
347            Self {
348                merkle_root: "mkroot-123".to_string(),
349                epoch: Epoch(10),
350                block_number: BlockNumber(100),
351                hash: "hash-123".to_string(),
352                certificate_hash: "cert-hash-123".to_string(),
353                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
354                    .unwrap()
355                    .with_timezone(&Utc),
356            }
357        }
358    }
359
360    impl Dummy for CardanoTransactionSnapshotListItemMessage {
361        /// Return a dummy [CardanoTransactionSnapshotListItemMessage] (test-only).
362        fn dummy() -> Self {
363            Self {
364                merkle_root: "mkroot-123".to_string(),
365                epoch: Epoch(10),
366                block_number: BlockNumber(100),
367                hash: "hash-123".to_string(),
368                certificate_hash: "cert-hash-123".to_string(),
369                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
370                    .unwrap()
371                    .with_timezone(&Utc),
372            }
373        }
374    }
375
376    impl Dummy for CardanoBlocksTransactionsSnapshotMessage {
377        /// Return a dummy [CardanoBlocksTransactionsSnapshotMessage] (test-only).
378        fn dummy() -> Self {
379            Self {
380                merkle_root: "mkroot-123".to_string(),
381                epoch: Epoch(10),
382                block_number_signed: BlockNumber(100),
383                block_number_tip: BlockNumber(115),
384                hash: "hash-123".to_string(),
385                certificate_hash: "cert-hash-123".to_string(),
386                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
387                    .unwrap()
388                    .with_timezone(&Utc),
389            }
390        }
391    }
392
393    impl Dummy for CardanoBlocksTransactionsSnapshotListItemMessage {
394        /// Return a dummy [CardanoBlocksTransactionsSnapshotListItemMessage] (test-only).
395        fn dummy() -> Self {
396            Self {
397                merkle_root: "mkroot-123".to_string(),
398                epoch: Epoch(10),
399                block_number_signed: BlockNumber(100),
400                block_number_tip: BlockNumber(115),
401                hash: "hash-123".to_string(),
402                certificate_hash: "cert-hash-123".to_string(),
403                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
404                    .unwrap()
405                    .with_timezone(&Utc),
406            }
407        }
408    }
409
410    impl Dummy for CertificateMessage {
411        /// Return a dummy [CertificateMessage] (test-only).
412        fn dummy() -> Self {
413            let mut protocol_message = ProtocolMessage::new();
414            protocol_message.set_message_part(
415                ProtocolMessagePartKey::SnapshotDigest,
416                "snapshot-digest-123".to_string(),
417            );
418            protocol_message.set_message_part(
419                ProtocolMessagePartKey::NextAggregateVerificationKey,
420                fake_keys::aggregate_verification_key_for_concatenation()[1].to_owned(),
421            );
422            let epoch = Epoch(10);
423
424            Self {
425                hash: "hash".to_string(),
426                previous_hash: "previous_hash".to_string(),
427                epoch,
428                signed_entity_type: SignedEntityType::MithrilStakeDistribution(epoch),
429                metadata: CertificateMetadataMessagePart::dummy(),
430                protocol_message: protocol_message.clone(),
431                signed_message: "signed_message".to_string(),
432                aggregate_verification_key:
433                    fake_keys::aggregate_verification_key_for_concatenation()[0].to_owned(),
434                multi_signature: fake_keys::multi_signature()[0].to_owned(),
435                genesis_signature: String::new(),
436            }
437        }
438    }
439
440    impl Dummy for CertificateListItemMessage {
441        /// Return a dummy [CertificateListItemMessage] (test-only).
442        fn dummy() -> Self {
443            let mut protocol_message = ProtocolMessage::new();
444            protocol_message.set_message_part(
445                ProtocolMessagePartKey::SnapshotDigest,
446                "snapshot-digest-123".to_string(),
447            );
448            protocol_message.set_message_part(
449                ProtocolMessagePartKey::NextAggregateVerificationKey,
450                "next-avk-123".to_string(),
451            );
452            let epoch = Epoch(10);
453
454            Self {
455                hash: "hash".to_string(),
456                previous_hash: "previous_hash".to_string(),
457                epoch,
458                signed_entity_type: SignedEntityType::MithrilStakeDistribution(epoch),
459                metadata: CertificateListItemMessageMetadata {
460                    network: "testnet".to_string(),
461                    protocol_version: "0.1.0".to_string(),
462                    protocol_parameters: ProtocolParameters::new(1000, 100, 0.123),
463                    initiated_at: DateTime::parse_from_rfc3339("2024-02-12T13:11:47Z")
464                        .unwrap()
465                        .with_timezone(&Utc),
466                    sealed_at: DateTime::parse_from_rfc3339("2024-02-12T13:12:57Z")
467                        .unwrap()
468                        .with_timezone(&Utc),
469                    total_signers: 2,
470                },
471                protocol_message: protocol_message.clone(),
472                signed_message: "signed_message".to_string(),
473                aggregate_verification_key: "aggregate_verification_key".to_string(),
474            }
475        }
476    }
477
478    impl Dummy for EpochSettingsMessage {
479        /// Return a dummy [EpochSettingsMessage] (test-only).
480        fn dummy() -> Self {
481            #[allow(deprecated)]
482            Self {
483                epoch: Epoch(10),
484                signer_registration_protocol_parameters: Some(ProtocolParameters {
485                    k: 5,
486                    m: 100,
487                    phi_f: 0.65,
488                }),
489                current_signers: [SignerMessagePart::dummy()].to_vec(),
490                next_signers: [SignerMessagePart::dummy()].to_vec(),
491                cardano_transactions_signing_config: Some(CardanoTransactionsSigningConfig::dummy()),
492            }
493        }
494    }
495
496    impl Dummy for ProtocolConfigurationMessage {
497        /// Return a dummy [ProtocolConfigurationMessage] (test-only).
498        fn dummy() -> Self {
499            Self {
500                protocol_parameters: ProtocolParameters {
501                    k: 5,
502                    m: 100,
503                    phi_f: 0.65,
504                },
505                cardano_transactions_signing_config: Some(CardanoTransactionsSigningConfig::dummy()),
506                available_signed_entity_types: SignedEntityTypeDiscriminants::all(),
507            }
508        }
509    }
510
511    impl Dummy for MithrilStakeDistributionMessage {
512        /// Return a dummy [MithrilStakeDistributionMessage] (test-only).
513        fn dummy() -> Self {
514            Self {
515                epoch: Epoch(1),
516                signers_with_stake: vec![SignerWithStakeMessagePart::dummy()],
517                hash: "hash-123".to_string(),
518                certificate_hash: "cert-hash-123".to_string(),
519                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
520                    .unwrap()
521                    .with_timezone(&Utc),
522                protocol_parameters: fake_data::protocol_parameters(),
523            }
524        }
525    }
526
527    impl Dummy for MithrilStakeDistributionListItemMessage {
528        /// Return a dummy [MithrilStakeDistributionListItemMessage] (test-only).
529        fn dummy() -> Self {
530            Self {
531                epoch: Epoch(1),
532                hash: "hash-123".to_string(),
533                certificate_hash: "certificate-hash-123".to_string(),
534                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
535                    .unwrap()
536                    .with_timezone(&Utc),
537            }
538        }
539    }
540
541    impl Dummy for RegisterSignatureMessageHttp {
542        /// Return a dummy [RegisterSignatureMessageHttp] (test-only).
543        fn dummy() -> Self {
544            use crate::entities::Epoch;
545            Self {
546                signed_entity_type: SignedEntityType::MithrilStakeDistribution(Epoch(5)),
547                party_id: "party_id".to_string(),
548                signature: fake_keys::single_signature()[0].to_string(),
549                won_indexes: vec![1, 3],
550                signed_message: "6a7e737c312972d2346b65ac3075696e04286d046dddaf8004121e3d5e27cc0d"
551                    .to_string(),
552            }
553        }
554    }
555
556    impl Dummy for RegisterSignatureMessageDmq {
557        /// Return a dummy [RegisterSignatureMessageDmq] (test-only).
558        fn dummy() -> Self {
559            use crate::entities::Epoch;
560            Self {
561                signed_entity_type: SignedEntityType::MithrilStakeDistribution(Epoch(5)),
562                signature: fake_keys::single_signature()[0].try_into().unwrap(),
563            }
564        }
565    }
566
567    impl Dummy for RegisterSignerMessage {
568        /// Return a dummy [RegisterSignerMessage] (test-only).
569        fn dummy() -> Self {
570            Self {
571                epoch: Epoch(1),
572                party_id: "pool1m8crhnqj5k2kyszf5j2scshupystyxc887zdfrpzh6ty6eun4fx".to_string(),
573                verification_key: fake_keys::signer_verification_key()[0].to_string(),
574                verification_key_signature: Some(
575                    fake_keys::signer_verification_key_signature()[0].to_string(),
576                ),
577                operational_certificate: Some(fake_keys::operational_certificate()[0].to_string()),
578                kes_evolutions: Some(KesEvolutions(6)),
579            }
580        }
581    }
582
583    impl Dummy for SnapshotMessage {
584        /// Return a dummy [SnapshotMessage] (test-only).
585        fn dummy() -> Self {
586            Self {
587                digest: "0b9f5ad7f33cc523775c82249294eb8a1541d54f08eb3107cafc5638403ec7c6"
588                    .to_string(),
589                network: "preview".to_string(),
590                beacon: CardanoDbBeacon {
591                    epoch: Epoch(86),
592                    immutable_file_number: 1728,
593                },
594                certificate_hash:
595                    "d5daf6c03ace4a9c074e951844075b9b373bafc4e039160e3e2af01823e9abfb".to_string(),
596                size: 807803196,
597                ancillary_size: Some(123456789),
598                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
599                    .unwrap()
600                    .with_timezone(&Utc),
601                locations: vec!["https://host/certificate.tar.gz".to_string()],
602                ancillary_locations: Some(vec!["https://host/ancillary.tar.gz".to_string()]),
603                compression_algorithm: CompressionAlgorithm::Gzip,
604                cardano_node_version: "0.0.1".to_string(),
605            }
606        }
607    }
608
609    impl Dummy for SnapshotDownloadMessage {
610        /// Return a dummy [SnapshotDownloadMessage] (test-only).
611        fn dummy() -> Self {
612            Self {
613                digest: "0b9f5ad7f33cc523775c82249294eb8a1541d54f08eb3107cafc5638403ec7c6"
614                    .to_string(),
615                network: "preview".to_string(),
616                beacon: CardanoDbBeacon {
617                    epoch: Epoch(86),
618                    immutable_file_number: 1728,
619                },
620                size: 807803196,
621                ancillary_size: Some(123456789),
622                locations: vec!["https://host/certificate.tar.gz".to_string()],
623                ancillary_locations: Some(vec!["https://host/ancillary.tar.gz".to_string()]),
624                compression_algorithm: CompressionAlgorithm::Gzip,
625                cardano_node_version: "0.0.1".to_string(),
626            }
627        }
628    }
629
630    impl Dummy for SnapshotListItemMessage {
631        /// Return a dummy [SnapshotListItemMessage] (test-only).
632        fn dummy() -> Self {
633            Self {
634                digest: "0b9f5ad7f33cc523775c82249294eb8a1541d54f08eb3107cafc5638403ec7c6"
635                    .to_string(),
636                network: "preview".to_string(),
637                beacon: CardanoDbBeacon {
638                    epoch: Epoch(86),
639                    immutable_file_number: 1728,
640                },
641                certificate_hash:
642                    "d5daf6c03ace4a9c074e951844075b9b373bafc4e039160e3e2af01823e9abfb".to_string(),
643                size: 807803196,
644                ancillary_size: Some(123456789),
645                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
646                    .unwrap()
647                    .with_timezone(&Utc),
648                locations: vec!["https://host/certificate.tar.gz".to_string()],
649                ancillary_locations: Some(vec!["https://host/ancillary.tar.gz".to_string()]),
650                compression_algorithm: CompressionAlgorithm::default(),
651                cardano_node_version: "0.0.1".to_string(),
652            }
653        }
654    }
655}
656
657mod signable_builder {
658    use crate::entities::{
659        CardanoDbBeacon, CardanoStakeDistribution, CardanoTransactionsSnapshot, Epoch,
660        MithrilStakeDistribution, SignedEntityType, Snapshot,
661    };
662    use crate::signable_builder::SignedEntity;
663
664    use super::*;
665
666    impl Dummy for SignedEntity<Snapshot> {
667        /// Create a dummy [SignedEntity] for [Snapshot] entity
668        fn dummy() -> Self {
669            SignedEntity {
670                signed_entity_id: "snapshot-id-123".to_string(),
671                signed_entity_type: SignedEntityType::CardanoImmutableFilesFull(
672                    CardanoDbBeacon::default(),
673                ),
674                certificate_id: "certificate-hash-123".to_string(),
675                artifact: fake_data::snapshot(1),
676                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
677                    .unwrap()
678                    .with_timezone(&Utc),
679            }
680        }
681    }
682
683    impl Dummy for SignedEntity<MithrilStakeDistribution> {
684        /// Create a dummy [SignedEntity] for [MithrilStakeDistribution] entity
685        fn dummy() -> Self {
686            SignedEntity {
687                signed_entity_id: "mithril-stake-distribution-id-123".to_string(),
688                signed_entity_type: SignedEntityType::MithrilStakeDistribution(Epoch(1)),
689                certificate_id: "certificate-hash-123".to_string(),
690                artifact: fake_data::mithril_stake_distribution(
691                    Epoch(1),
692                    fake_data::signers_with_stakes(5),
693                ),
694                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
695                    .unwrap()
696                    .with_timezone(&Utc),
697            }
698        }
699    }
700
701    impl Dummy for SignedEntity<CardanoTransactionsSnapshot> {
702        /// Create a dummy [SignedEntity] for [CardanoTransactionsSnapshot] entity
703        fn dummy() -> Self {
704            let block_number = crate::entities::BlockNumber(50);
705            SignedEntity {
706                signed_entity_id: "snapshot-id-123".to_string(),
707                signed_entity_type: SignedEntityType::CardanoTransactions(Epoch(5), block_number),
708                certificate_id: "certificate-hash-123".to_string(),
709                artifact: CardanoTransactionsSnapshot::new("mkroot123".to_string(), block_number),
710                created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
711                    .unwrap()
712                    .with_timezone(&Utc),
713            }
714        }
715    }
716
717    impl Dummy for SignedEntity<CardanoStakeDistribution> {
718        /// Create a dummy [SignedEntity] for [CardanoStakeDistribution] entity
719        fn dummy() -> Self {
720            SignedEntity {
721                signed_entity_id: "cardano-stake-distribution-id-123".to_string(),
722                signed_entity_type: SignedEntityType::CardanoStakeDistribution(Epoch(1)),
723                certificate_id: "certificate-hash-123".to_string(),
724                artifact: fake_data::cardano_stake_distribution(Epoch(1)),
725                created_at: DateTime::parse_from_rfc3339("2024-07-29T16:15:05.618857482Z")
726                    .unwrap()
727                    .with_timezone(&Utc),
728            }
729        }
730    }
731}