@@ -18,7 +18,10 @@ pub mod voter;
18
18
#[ cfg( test) ]
19
19
mod tests {
20
20
use super :: * ;
21
- use crate :: { config:: SIGNATURE , coordinator} ;
21
+ use crate :: {
22
+ config:: { POLL_RESULT_KEY_TOTAL_BALLOTS , SIGNATURE } ,
23
+ coordinator,
24
+ } ;
22
25
use wedpr_l_crypto_zkp_utils:: {
23
26
bytes_to_point, get_random_scalar, scalar_to_bytes,
24
27
} ;
@@ -681,6 +684,7 @@ mod tests {
681
684
. unwrap( )
682
685
) ;
683
686
// aggregate
687
+ wedpr_println ! ( "##### aggregate_vote_sum_response_unlisted request1" ) ;
684
688
assert_eq ! (
685
689
true ,
686
690
coordinator:: aggregate_vote_sum_response_unlisted(
@@ -690,6 +694,11 @@ mod tests {
690
694
)
691
695
. unwrap( )
692
696
) ;
697
+ wedpr_println ! (
698
+ "##### aggregate_vote_sum_response_unlisted request1 success, \
699
+ size: {:?}",
700
+ encrypted_vote_sum. get_voted_ballot_unlisted( ) . len( )
701
+ ) ;
693
702
// vote2
694
703
let choice_candidate_unlisted2 =
695
704
& candidate_list_unlisted[ 1 ..3 ] . to_vec ( ) ;
@@ -713,6 +722,7 @@ mod tests {
713
722
)
714
723
. unwrap( )
715
724
) ;
725
+ wedpr_println ! ( "##### aggregate_vote_sum_response_unlisted request2" ) ;
716
726
assert_eq ! (
717
727
true ,
718
728
coordinator:: aggregate_vote_sum_response_unlisted(
@@ -722,6 +732,11 @@ mod tests {
722
732
)
723
733
. unwrap( )
724
734
) ;
735
+ wedpr_println ! (
736
+ "##### aggregate_vote_sum_response_unlisted request2 success, \
737
+ size: {:?}",
738
+ encrypted_vote_sum. get_voted_ballot_unlisted( ) . len( )
739
+ ) ;
725
740
// vote3
726
741
let choice_candidate_unlisted3 =
727
742
& candidate_list_unlisted[ 2 ..3 ] . to_vec ( ) ;
@@ -736,6 +751,7 @@ mod tests {
736
751
& poll_parameters,
737
752
)
738
753
. unwrap ( ) ;
754
+ wedpr_println ! ( "##### aggregate_vote_sum_response_unlisted request3" ) ;
739
755
assert_eq ! (
740
756
true ,
741
757
verifier:: verify_unbounded_vote_request_unlisted(
@@ -754,7 +770,13 @@ mod tests {
754
770
)
755
771
. unwrap( )
756
772
) ;
757
- wedpr_println ! ( "encrypted_vote_sum: {:?}" , encrypted_vote_sum) ;
773
+ wedpr_println ! (
774
+ "##### aggregate_vote_sum_response_unlisted request3 success"
775
+ ) ;
776
+ wedpr_println ! (
777
+ "encrypted_vote_sum, unlisted size: {:?}" ,
778
+ encrypted_vote_sum. get_voted_ballot_unlisted( ) . len( )
779
+ ) ;
758
780
759
781
let mut vote_sum_total = DecryptedResultPartStorage :: new ( ) ;
760
782
@@ -778,6 +800,11 @@ mod tests {
778
800
. unwrap( )
779
801
) ;
780
802
803
+ wedpr_println ! (
804
+ "##### aggregate_decrypted_part_sum_unlisted request1, unlisted \
805
+ size: {:?}",
806
+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
807
+ ) ;
781
808
assert_eq ! (
782
809
true ,
783
810
coordinator:: aggregate_decrypted_part_sum_unlisted(
@@ -787,6 +814,11 @@ mod tests {
787
814
)
788
815
. unwrap( )
789
816
) ;
817
+ wedpr_println ! (
818
+ "##### aggregate_decrypted_part_sum_unlisted request1, success \
819
+ unlisted size: {:?}",
820
+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
821
+ ) ;
790
822
let decrypt_request2 = counter:: count_unlisted (
791
823
counter_id_list[ 1 ] ,
792
824
& counter2,
@@ -806,7 +838,11 @@ mod tests {
806
838
)
807
839
. unwrap( )
808
840
) ;
809
-
841
+ wedpr_println ! (
842
+ "##### aggregate_decrypted_part_sum_unlisted request2, unlisted \
843
+ size: {:?}",
844
+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
845
+ ) ;
810
846
assert_eq ! (
811
847
true ,
812
848
coordinator:: aggregate_decrypted_part_sum_unlisted(
@@ -816,6 +852,11 @@ mod tests {
816
852
)
817
853
. unwrap( )
818
854
) ;
855
+ wedpr_println ! (
856
+ "##### aggregate_decrypted_part_sum_unlisted request2, unlisted \
857
+ size: {:?} succ",
858
+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
859
+ ) ;
819
860
820
861
let decrypt_request3 = counter:: count_unlisted (
821
862
counter_id_list[ 2 ] ,
@@ -836,7 +877,11 @@ mod tests {
836
877
)
837
878
. unwrap( )
838
879
) ;
839
-
880
+ wedpr_println ! (
881
+ "##### aggregate_decrypted_part_sum_unlisted request3, unlisted \
882
+ size: {:?}",
883
+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
884
+ ) ;
840
885
assert_eq ! (
841
886
true ,
842
887
coordinator:: aggregate_decrypted_part_sum_unlisted(
@@ -846,6 +891,11 @@ mod tests {
846
891
)
847
892
. unwrap( )
848
893
) ;
894
+ wedpr_println ! (
895
+ "##### aggregate_decrypted_part_sum_unlisted request3, unlisted \
896
+ size: {:?} success",
897
+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
898
+ ) ;
849
899
// wedpr_println!("vote_sum_total:{:?}", vote_sum_total);
850
900
851
901
let final_result_request_unlisted =
@@ -871,5 +921,38 @@ mod tests {
871
921
)
872
922
. unwrap ( ) ;
873
923
assert ! ( result) ;
924
+ // check the candidate result(with Wedpr_voting_total_ballots)
925
+ assert ! ( final_result_request_unlisted. get_result( ) . len( ) == 4 ) ;
926
+ for candidate_result in final_result_request_unlisted. get_result ( ) {
927
+ if candidate_result. get_key ( )
928
+ == POLL_RESULT_KEY_TOTAL_BALLOTS . to_string ( )
929
+ {
930
+ assert ! ( candidate_result. get_value( ) == 60 ) ;
931
+ }
932
+ if candidate_result. get_key ( ) == "Alice" {
933
+ assert ! ( candidate_result. get_value( ) == 40 ) ;
934
+ }
935
+ if candidate_result. get_key ( ) == "Bob" {
936
+ assert ! ( candidate_result. get_value( ) == 50 ) ;
937
+ }
938
+ if candidate_result. get_key ( ) == "charlie" {
939
+ assert ! ( candidate_result. get_value( ) == 60 ) ;
940
+ }
941
+ }
942
+ // check the unlisted candidate result
943
+ assert ! ( final_result_request_unlisted. get_unlisted_result( ) . len( ) == 3 ) ;
944
+ for candidate_result in
945
+ final_result_request_unlisted. get_unlisted_result ( )
946
+ {
947
+ if candidate_result. get_candidate_id ( ) == 1 {
948
+ assert ! ( candidate_result. get_value( ) == 10 ) ;
949
+ }
950
+ if candidate_result. get_candidate_id ( ) == 2 {
951
+ assert ! ( candidate_result. get_value( ) == 0 ) ;
952
+ }
953
+ if candidate_result. get_candidate_id ( ) == 3 {
954
+ assert ! ( candidate_result. get_value( ) == 60 ) ;
955
+ }
956
+ }
874
957
}
875
958
}
0 commit comments