@@ -428,22 +428,36 @@ mod tests {
428
428
429
429
#[ tokio:: test]
430
430
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( ) ] ;
439
451
440
452
let service = MessageServiceBuilder :: new ( )
441
- . with_signed_entity_records ( & [ record ] )
453
+ . with_signed_entity_records ( & records )
442
454
. build ( )
443
455
. await ;
444
456
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( ) ) ;
446
459
460
+ let response = service. get_snapshot_list_message ( 3 ) . await . unwrap ( ) ;
447
461
assert_eq ! ( message, response) ;
448
462
}
449
463
}
@@ -490,24 +504,37 @@ mod tests {
490
504
491
505
#[ tokio:: test]
492
506
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
+ ] ;
501
526
let message: CardanoDatabaseSnapshotListMessage =
502
- vec ! [ record . clone( ) . try_into( ) . unwrap( ) ] ;
527
+ vec ! [ records [ 0 ] . clone( ) . try_into( ) . unwrap( ) ] ;
503
528
504
529
let service = MessageServiceBuilder :: new ( )
505
- . with_signed_entity_records ( & [ record ] )
530
+ . with_signed_entity_records ( & records )
506
531
. build ( )
507
532
. await ;
508
533
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( ) ) ;
510
536
537
+ let response = service. get_cardano_database_list_message ( 3 ) . await . unwrap ( ) ;
511
538
assert_eq ! ( message, response) ;
512
539
}
513
540
}
@@ -555,27 +582,42 @@ mod tests {
555
582
556
583
#[ tokio:: test]
557
584
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
+ ] ;
566
603
let message: MithrilStakeDistributionListMessage =
567
- vec ! [ record . clone( ) . try_into( ) . unwrap( ) ] ;
604
+ vec ! [ records [ 0 ] . clone( ) . try_into( ) . unwrap( ) ] ;
568
605
569
606
let service = MessageServiceBuilder :: new ( )
570
- . with_signed_entity_records ( & [ record ] )
607
+ . with_signed_entity_records ( & records )
571
608
. build ( )
572
609
. await ;
573
610
574
611
let response = service
575
- . get_mithril_stake_distribution_list_message ( 10 )
612
+ . get_mithril_stake_distribution_list_message ( 0 )
576
613
. await
577
614
. unwrap ( ) ;
615
+ assert ! ( response. is_empty( ) ) ;
578
616
617
+ let response = service
618
+ . get_mithril_stake_distribution_list_message ( 3 )
619
+ . await
620
+ . unwrap ( ) ;
579
621
assert_eq ! ( message, response) ;
580
622
}
581
623
}
@@ -626,30 +668,47 @@ mod tests {
626
668
627
669
#[ tokio:: test]
628
670
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
+ )
637
682
. 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
+ ] ;
640
694
let message: CardanoTransactionSnapshotListMessage =
641
- vec ! [ record . clone( ) . try_into( ) . unwrap( ) ] ;
695
+ vec ! [ records [ 0 ] . clone( ) . try_into( ) . unwrap( ) ] ;
642
696
643
697
let service = MessageServiceBuilder :: new ( )
644
- . with_signed_entity_records ( & [ record ] )
698
+ . with_signed_entity_records ( & records )
645
699
. build ( )
646
700
. await ;
647
701
648
702
let response = service
649
- . get_cardano_transaction_list_message ( 10 )
703
+ . get_cardano_transaction_list_message ( 0 )
650
704
. await
651
705
. unwrap ( ) ;
706
+ assert ! ( response. is_empty( ) ) ;
652
707
708
+ let response = service
709
+ . get_cardano_transaction_list_message ( 3 )
710
+ . await
711
+ . unwrap ( ) ;
653
712
assert_eq ! ( message, response) ;
654
713
}
655
714
}
@@ -737,27 +796,42 @@ mod tests {
737
796
738
797
#[ tokio:: test]
739
798
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
+ ] ;
748
817
let message: CardanoStakeDistributionListMessage =
749
- vec ! [ record . clone( ) . try_into( ) . unwrap( ) ] ;
818
+ vec ! [ records [ 0 ] . clone( ) . try_into( ) . unwrap( ) ] ;
750
819
751
820
let service = MessageServiceBuilder :: new ( )
752
- . with_signed_entity_records ( & [ record ] )
821
+ . with_signed_entity_records ( & records )
753
822
. build ( )
754
823
. await ;
755
824
756
825
let response = service
757
- . get_cardano_stake_distribution_list_message ( 10 )
826
+ . get_cardano_stake_distribution_list_message ( 0 )
758
827
. await
759
828
. unwrap ( ) ;
829
+ assert ! ( response. is_empty( ) ) ;
760
830
831
+ let response = service
832
+ . get_cardano_stake_distribution_list_message ( 3 )
833
+ . await
834
+ . unwrap ( ) ;
761
835
assert_eq ! ( message, response) ;
762
836
}
763
837
}
0 commit comments