@@ -18,7 +18,10 @@ pub mod voter;
1818#[ cfg( test) ]
1919mod tests {
2020 use super :: * ;
21- use crate :: { config:: SIGNATURE , coordinator} ;
21+ use crate :: {
22+ config:: { POLL_RESULT_KEY_TOTAL_BALLOTS , SIGNATURE } ,
23+ coordinator,
24+ } ;
2225 use wedpr_l_crypto_zkp_utils:: {
2326 bytes_to_point, get_random_scalar, scalar_to_bytes,
2427 } ;
@@ -681,6 +684,7 @@ mod tests {
681684 . unwrap( )
682685 ) ;
683686 // aggregate
687+ wedpr_println ! ( "##### aggregate_vote_sum_response_unlisted request1" ) ;
684688 assert_eq ! (
685689 true ,
686690 coordinator:: aggregate_vote_sum_response_unlisted(
@@ -690,6 +694,11 @@ mod tests {
690694 )
691695 . unwrap( )
692696 ) ;
697+ wedpr_println ! (
698+ "##### aggregate_vote_sum_response_unlisted request1 success, \
699+ size: {:?}",
700+ encrypted_vote_sum. get_voted_ballot_unlisted( ) . len( )
701+ ) ;
693702 // vote2
694703 let choice_candidate_unlisted2 =
695704 & candidate_list_unlisted[ 1 ..3 ] . to_vec ( ) ;
@@ -713,6 +722,7 @@ mod tests {
713722 )
714723 . unwrap( )
715724 ) ;
725+ wedpr_println ! ( "##### aggregate_vote_sum_response_unlisted request2" ) ;
716726 assert_eq ! (
717727 true ,
718728 coordinator:: aggregate_vote_sum_response_unlisted(
@@ -722,6 +732,11 @@ mod tests {
722732 )
723733 . unwrap( )
724734 ) ;
735+ wedpr_println ! (
736+ "##### aggregate_vote_sum_response_unlisted request2 success, \
737+ size: {:?}",
738+ encrypted_vote_sum. get_voted_ballot_unlisted( ) . len( )
739+ ) ;
725740 // vote3
726741 let choice_candidate_unlisted3 =
727742 & candidate_list_unlisted[ 2 ..3 ] . to_vec ( ) ;
@@ -736,6 +751,7 @@ mod tests {
736751 & poll_parameters,
737752 )
738753 . unwrap ( ) ;
754+ wedpr_println ! ( "##### aggregate_vote_sum_response_unlisted request3" ) ;
739755 assert_eq ! (
740756 true ,
741757 verifier:: verify_unbounded_vote_request_unlisted(
@@ -754,7 +770,13 @@ mod tests {
754770 )
755771 . unwrap( )
756772 ) ;
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+ ) ;
758780
759781 let mut vote_sum_total = DecryptedResultPartStorage :: new ( ) ;
760782
@@ -778,6 +800,11 @@ mod tests {
778800 . unwrap( )
779801 ) ;
780802
803+ wedpr_println ! (
804+ "##### aggregate_decrypted_part_sum_unlisted request1, unlisted \
805+ size: {:?}",
806+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
807+ ) ;
781808 assert_eq ! (
782809 true ,
783810 coordinator:: aggregate_decrypted_part_sum_unlisted(
@@ -787,6 +814,11 @@ mod tests {
787814 )
788815 . unwrap( )
789816 ) ;
817+ wedpr_println ! (
818+ "##### aggregate_decrypted_part_sum_unlisted request1, success \
819+ unlisted size: {:?}",
820+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
821+ ) ;
790822 let decrypt_request2 = counter:: count_unlisted (
791823 counter_id_list[ 1 ] ,
792824 & counter2,
@@ -806,7 +838,11 @@ mod tests {
806838 )
807839 . unwrap( )
808840 ) ;
809-
841+ wedpr_println ! (
842+ "##### aggregate_decrypted_part_sum_unlisted request2, unlisted \
843+ size: {:?}",
844+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
845+ ) ;
810846 assert_eq ! (
811847 true ,
812848 coordinator:: aggregate_decrypted_part_sum_unlisted(
@@ -816,6 +852,11 @@ mod tests {
816852 )
817853 . unwrap( )
818854 ) ;
855+ wedpr_println ! (
856+ "##### aggregate_decrypted_part_sum_unlisted request2, unlisted \
857+ size: {:?} succ",
858+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
859+ ) ;
819860
820861 let decrypt_request3 = counter:: count_unlisted (
821862 counter_id_list[ 2 ] ,
@@ -836,7 +877,11 @@ mod tests {
836877 )
837878 . unwrap( )
838879 ) ;
839-
880+ wedpr_println ! (
881+ "##### aggregate_decrypted_part_sum_unlisted request3, unlisted \
882+ size: {:?}",
883+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
884+ ) ;
840885 assert_eq ! (
841886 true ,
842887 coordinator:: aggregate_decrypted_part_sum_unlisted(
@@ -846,6 +891,11 @@ mod tests {
846891 )
847892 . unwrap( )
848893 ) ;
894+ wedpr_println ! (
895+ "##### aggregate_decrypted_part_sum_unlisted request3, unlisted \
896+ size: {:?} success",
897+ vote_sum_total. get_unlisted_candidate_part( ) . len( )
898+ ) ;
849899 // wedpr_println!("vote_sum_total:{:?}", vote_sum_total);
850900
851901 let final_result_request_unlisted =
@@ -871,5 +921,38 @@ mod tests {
871921 )
872922 . unwrap ( ) ;
873923 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+ }
874957 }
875958}
0 commit comments