@@ -428,22 +428,36 @@ mod tests {
428428
429429 #[ tokio:: test]
430430 async fn get_snapshot_list_message ( ) {
431- let record = SignedEntityRecord {
432- signed_entity_id : "signed_entity_id" . to_string ( ) ,
433- signed_entity_type : SignedEntityType :: CardanoImmutableFilesFull ( fake_data:: beacon ( ) ) ,
434- certificate_id : "cert_id" . to_string ( ) ,
435- artifact : serde_json:: to_string ( & fake_data:: snapshots ( 1 ) [ 0 ] ) . unwrap ( ) ,
436- created_at : Default :: default ( ) ,
437- } ;
438- let message: SnapshotListMessage = vec ! [ record. clone( ) . try_into( ) . unwrap( ) ] ;
431+ let records = vec ! [
432+ SignedEntityRecord {
433+ signed_entity_id: "signed_entity_id-1" . to_string( ) ,
434+ signed_entity_type: SignedEntityType :: CardanoImmutableFilesFull (
435+ fake_data:: beacon( ) ,
436+ ) ,
437+ certificate_id: "cert_id-1" . to_string( ) ,
438+ artifact: serde_json:: to_string( & fake_data:: snapshots( 1 ) [ 0 ] ) . unwrap( ) ,
439+ created_at: Default :: default ( ) ,
440+ } ,
441+ SignedEntityRecord {
442+ signed_entity_id: "signed_entity_id-2" . to_string( ) ,
443+ signed_entity_type: SignedEntityType :: CardanoDatabase ( fake_data:: beacon( ) ) ,
444+ certificate_id: "cert_id-2" . to_string( ) ,
445+ artifact: serde_json:: to_string( & fake_data:: cardano_database_snapshots( 1 ) [ 0 ] )
446+ . unwrap( ) ,
447+ created_at: Default :: default ( ) ,
448+ } ,
449+ ] ;
450+ let message: SnapshotListMessage = vec ! [ records[ 0 ] . clone( ) . try_into( ) . unwrap( ) ] ;
439451
440452 let service = MessageServiceBuilder :: new ( )
441- . with_signed_entity_records ( & [ record ] )
453+ . with_signed_entity_records ( & records )
442454 . build ( )
443455 . await ;
444456
445- let response = service. get_snapshot_list_message ( 3 ) . await . unwrap ( ) ;
457+ let response = service. get_snapshot_list_message ( 0 ) . await . unwrap ( ) ;
458+ assert ! ( response. is_empty( ) ) ;
446459
460+ let response = service. get_snapshot_list_message ( 3 ) . await . unwrap ( ) ;
447461 assert_eq ! ( message, response) ;
448462 }
449463 }
@@ -490,24 +504,37 @@ mod tests {
490504
491505 #[ tokio:: test]
492506 async fn get_cardano_database_list_message ( ) {
493- let record = SignedEntityRecord {
494- signed_entity_id : "signed_entity_id" . to_string ( ) ,
495- signed_entity_type : SignedEntityType :: CardanoDatabase ( fake_data:: beacon ( ) ) ,
496- certificate_id : "cert_id" . to_string ( ) ,
497- artifact : serde_json:: to_string ( & fake_data:: cardano_database_snapshots ( 1 ) [ 0 ] )
498- . unwrap ( ) ,
499- created_at : Default :: default ( ) ,
500- } ;
507+ let records = vec ! [
508+ SignedEntityRecord {
509+ signed_entity_id: "signed_entity_id-1" . to_string( ) ,
510+ signed_entity_type: SignedEntityType :: CardanoDatabase ( fake_data:: beacon( ) ) ,
511+ certificate_id: "cert_id-1" . to_string( ) ,
512+ artifact: serde_json:: to_string( & fake_data:: cardano_database_snapshots( 1 ) [ 0 ] )
513+ . unwrap( ) ,
514+ created_at: Default :: default ( ) ,
515+ } ,
516+ SignedEntityRecord {
517+ signed_entity_id: "signed_entity_id-2" . to_string( ) ,
518+ signed_entity_type: SignedEntityType :: CardanoImmutableFilesFull (
519+ fake_data:: beacon( ) ,
520+ ) ,
521+ certificate_id: "cert_id-2" . to_string( ) ,
522+ artifact: serde_json:: to_string( & fake_data:: snapshots( 1 ) [ 0 ] ) . unwrap( ) ,
523+ created_at: Default :: default ( ) ,
524+ } ,
525+ ] ;
501526 let message: CardanoDatabaseSnapshotListMessage =
502- vec ! [ record . clone( ) . try_into( ) . unwrap( ) ] ;
527+ vec ! [ records [ 0 ] . clone( ) . try_into( ) . unwrap( ) ] ;
503528
504529 let service = MessageServiceBuilder :: new ( )
505- . with_signed_entity_records ( & [ record ] )
530+ . with_signed_entity_records ( & records )
506531 . build ( )
507532 . await ;
508533
509- let response = service. get_cardano_database_list_message ( 3 ) . await . unwrap ( ) ;
534+ let response = service. get_cardano_database_list_message ( 0 ) . await . unwrap ( ) ;
535+ assert ! ( response. is_empty( ) ) ;
510536
537+ let response = service. get_cardano_database_list_message ( 3 ) . await . unwrap ( ) ;
511538 assert_eq ! ( message, response) ;
512539 }
513540 }
@@ -555,27 +582,42 @@ mod tests {
555582
556583 #[ tokio:: test]
557584 async fn get_mithril_stake_distribution_list_message ( ) {
558- let record = SignedEntityRecord {
559- signed_entity_id : "signed_entity_id" . to_string ( ) ,
560- signed_entity_type : SignedEntityType :: MithrilStakeDistribution ( Epoch ( 18 ) ) ,
561- certificate_id : "cert_id" . to_string ( ) ,
562- artifact : serde_json:: to_string ( & fake_data:: mithril_stake_distributions ( 1 ) [ 0 ] )
563- . unwrap ( ) ,
564- created_at : Default :: default ( ) ,
565- } ;
585+ let records = vec ! [
586+ SignedEntityRecord {
587+ signed_entity_id: "signed_entity_id-1" . to_string( ) ,
588+ signed_entity_type: SignedEntityType :: MithrilStakeDistribution ( Epoch ( 18 ) ) ,
589+ certificate_id: "cert_id-1" . to_string( ) ,
590+ artifact: serde_json:: to_string( & fake_data:: mithril_stake_distributions( 1 ) [ 0 ] )
591+ . unwrap( ) ,
592+ created_at: Default :: default ( ) ,
593+ } ,
594+ SignedEntityRecord {
595+ signed_entity_id: "signed_entity_id-2" . to_string( ) ,
596+ signed_entity_type: SignedEntityType :: CardanoDatabase ( fake_data:: beacon( ) ) ,
597+ certificate_id: "cert_id-2" . to_string( ) ,
598+ artifact: serde_json:: to_string( & fake_data:: cardano_database_snapshots( 1 ) [ 0 ] )
599+ . unwrap( ) ,
600+ created_at: Default :: default ( ) ,
601+ } ,
602+ ] ;
566603 let message: MithrilStakeDistributionListMessage =
567- vec ! [ record . clone( ) . try_into( ) . unwrap( ) ] ;
604+ vec ! [ records [ 0 ] . clone( ) . try_into( ) . unwrap( ) ] ;
568605
569606 let service = MessageServiceBuilder :: new ( )
570- . with_signed_entity_records ( & [ record ] )
607+ . with_signed_entity_records ( & records )
571608 . build ( )
572609 . await ;
573610
574611 let response = service
575- . get_mithril_stake_distribution_list_message ( 10 )
612+ . get_mithril_stake_distribution_list_message ( 0 )
576613 . await
577614 . unwrap ( ) ;
615+ assert ! ( response. is_empty( ) ) ;
578616
617+ let response = service
618+ . get_mithril_stake_distribution_list_message ( 3 )
619+ . await
620+ . unwrap ( ) ;
579621 assert_eq ! ( message, response) ;
580622 }
581623 }
@@ -626,30 +668,47 @@ mod tests {
626668
627669 #[ tokio:: test]
628670 async fn get_cardano_transaction_list_message ( ) {
629- let record = SignedEntityRecord {
630- signed_entity_id : "signed_entity_id" . to_string ( ) ,
631- signed_entity_type : SignedEntityType :: CardanoTransactions (
632- Epoch ( 18 ) ,
633- BlockNumber ( 120 ) ,
634- ) ,
635- certificate_id : "cert_id" . to_string ( ) ,
636- artifact : serde_json:: to_string ( & fake_data:: cardano_transactions_snapshot ( 1 ) [ 0 ] )
671+ let records = vec ! [
672+ SignedEntityRecord {
673+ signed_entity_id: "signed_entity_id-1" . to_string( ) ,
674+ signed_entity_type: SignedEntityType :: CardanoTransactions (
675+ Epoch ( 18 ) ,
676+ BlockNumber ( 120 ) ,
677+ ) ,
678+ certificate_id: "cert_id-1" . to_string( ) ,
679+ artifact: serde_json:: to_string(
680+ & fake_data:: cardano_transactions_snapshot( 1 ) [ 0 ] ,
681+ )
637682 . unwrap( ) ,
638- created_at : Default :: default ( ) ,
639- } ;
683+ created_at: Default :: default ( ) ,
684+ } ,
685+ SignedEntityRecord {
686+ signed_entity_id: "signed_entity_id-2" . to_string( ) ,
687+ signed_entity_type: SignedEntityType :: CardanoDatabase ( fake_data:: beacon( ) ) ,
688+ certificate_id: "cert_id-2" . to_string( ) ,
689+ artifact: serde_json:: to_string( & fake_data:: cardano_database_snapshots( 1 ) [ 0 ] )
690+ . unwrap( ) ,
691+ created_at: Default :: default ( ) ,
692+ } ,
693+ ] ;
640694 let message: CardanoTransactionSnapshotListMessage =
641- vec ! [ record . clone( ) . try_into( ) . unwrap( ) ] ;
695+ vec ! [ records [ 0 ] . clone( ) . try_into( ) . unwrap( ) ] ;
642696
643697 let service = MessageServiceBuilder :: new ( )
644- . with_signed_entity_records ( & [ record ] )
698+ . with_signed_entity_records ( & records )
645699 . build ( )
646700 . await ;
647701
648702 let response = service
649- . get_cardano_transaction_list_message ( 10 )
703+ . get_cardano_transaction_list_message ( 0 )
650704 . await
651705 . unwrap ( ) ;
706+ assert ! ( response. is_empty( ) ) ;
652707
708+ let response = service
709+ . get_cardano_transaction_list_message ( 3 )
710+ . await
711+ . unwrap ( ) ;
653712 assert_eq ! ( message, response) ;
654713 }
655714 }
@@ -737,27 +796,42 @@ mod tests {
737796
738797 #[ tokio:: test]
739798 async fn get_cardano_stake_distribution_list_message ( ) {
740- let record = SignedEntityRecord {
741- signed_entity_id : "signed_entity_id" . to_string ( ) ,
742- signed_entity_type : SignedEntityType :: CardanoStakeDistribution ( Epoch ( 18 ) ) ,
743- certificate_id : "cert_id" . to_string ( ) ,
744- artifact : serde_json:: to_string ( & fake_data:: cardano_stake_distributions ( 1 ) [ 0 ] )
745- . unwrap ( ) ,
746- created_at : Default :: default ( ) ,
747- } ;
799+ let records = vec ! [
800+ SignedEntityRecord {
801+ signed_entity_id: "signed_entity_id-1" . to_string( ) ,
802+ signed_entity_type: SignedEntityType :: CardanoStakeDistribution ( Epoch ( 18 ) ) ,
803+ certificate_id: "cert_id-1" . to_string( ) ,
804+ artifact: serde_json:: to_string( & fake_data:: cardano_stake_distributions( 1 ) [ 0 ] )
805+ . unwrap( ) ,
806+ created_at: Default :: default ( ) ,
807+ } ,
808+ SignedEntityRecord {
809+ signed_entity_id: "signed_entity_id-2" . to_string( ) ,
810+ signed_entity_type: SignedEntityType :: CardanoDatabase ( fake_data:: beacon( ) ) ,
811+ certificate_id: "cert_id-2" . to_string( ) ,
812+ artifact: serde_json:: to_string( & fake_data:: cardano_database_snapshots( 1 ) [ 0 ] )
813+ . unwrap( ) ,
814+ created_at: Default :: default ( ) ,
815+ } ,
816+ ] ;
748817 let message: CardanoStakeDistributionListMessage =
749- vec ! [ record . clone( ) . try_into( ) . unwrap( ) ] ;
818+ vec ! [ records [ 0 ] . clone( ) . try_into( ) . unwrap( ) ] ;
750819
751820 let service = MessageServiceBuilder :: new ( )
752- . with_signed_entity_records ( & [ record ] )
821+ . with_signed_entity_records ( & records )
753822 . build ( )
754823 . await ;
755824
756825 let response = service
757- . get_cardano_stake_distribution_list_message ( 10 )
826+ . get_cardano_stake_distribution_list_message ( 0 )
758827 . await
759828 . unwrap ( ) ;
829+ assert ! ( response. is_empty( ) ) ;
760830
831+ let response = service
832+ . get_cardano_stake_distribution_list_message ( 3 )
833+ . await
834+ . unwrap ( ) ;
761835 assert_eq ! ( message, response) ;
762836 }
763837 }
0 commit comments