Skip to main content

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