@@ -281,8 +281,7 @@ pub mod running_tests {
281281 DomainConfig , DomainId , DomainPurpose , Protocol , ReconstructionThreshold ,
282282 } ;
283283
284- /// Returns the state plus an [`Environment`] already signing as the first
285- /// current participant.
284+ /// Returns the state plus an [`Environment`] signing as the first participant.
286285 fn setup ( num_domains : usize ) -> ( RunningContractState , Environment ) {
287286 with_first_participant_signer ( gen_running_state ( num_domains) )
288287 }
@@ -308,12 +307,10 @@ pub mod running_tests {
308307 ( state, env)
309308 }
310309
311- /// Returns a participant present in BOTH the current and proposed sets:
310+ /// Returns a participant present in both the current and proposed sets:
312311 /// [`gen_valid_params_proposal`] keeps only a random subset of the current
313- /// participants, so an arbitrary current participant may be absent from the
314- /// proposal (rejected as a non-participant) and a freshly added one would
315- /// be deferred as a pending newcomer. The retained overlap is non-empty
316- /// (at least `threshold` current participants are kept).
312+ /// participants, so an arbitrary current one may be absent from the proposal
313+ /// and a freshly added one would be deferred as a pending newcomer.
317314 fn overlapping_signer (
318315 state : & RunningContractState ,
319316 proposal : & ProposedGovernanceThresholdParameters ,
@@ -332,8 +329,7 @@ pub mod running_tests {
332329 . expect ( "proposal must retain at least one current participant" )
333330 }
334331
335- /// Builds a [`DomainConfig`] for the next domain id with the given protocol,
336- /// purpose, and reconstruction threshold.
332+ /// Builds a one-domain proposal for the next domain id.
337333 fn single_domain_proposal (
338334 state : & RunningContractState ,
339335 protocol : Protocol ,
@@ -514,7 +510,7 @@ pub mod running_tests {
514510
515511 #[ test]
516512 fn vote_add_domains__should_reject_threshold_below_two ( ) {
517- // Given a running state and a proposal carrying t = 1
513+ // Given
518514 let ( mut state, _env) = setup ( 1 ) ;
519515 let proposal = single_domain_proposal (
520516 & state,
@@ -523,10 +519,10 @@ pub mod running_tests {
523519 ReconstructionThreshold :: new ( 1 ) ,
524520 ) ;
525521
526- // When voting to add the domain
522+ // When
527523 let err = state. vote_add_domains ( proposal) . unwrap_err ( ) ;
528524
529- // Then the universal lower bound is enforced
525+ // Then
530526 assert ! (
531527 err. to_string( )
532528 . contains( "Reconstruction threshold must be at least 2" ) ,
@@ -536,7 +532,7 @@ pub mod running_tests {
536532
537533 #[ test]
538534 fn vote_add_domains__should_reject_threshold_exceeding_participants ( ) {
539- // Given a running state and a proposal whose threshold > n
535+ // Given
540536 let ( mut state, _env) = setup ( 1 ) ;
541537 let n = state. parameters . participants ( ) . len ( ) as u64 ;
542538 let proposal = single_domain_proposal (
@@ -546,10 +542,10 @@ pub mod running_tests {
546542 ReconstructionThreshold :: new ( n + 1 ) ,
547543 ) ;
548544
549- // When voting to add the domain
545+ // When
550546 let err = state. vote_add_domains ( proposal) . unwrap_err ( ) ;
551547
552- // Then the upper bound is enforced
548+ // Then
553549 assert ! (
554550 err. to_string( ) . contains( "exceeds participant count" ) ,
555551 "Expected ReconstructionThresholdExceedsParticipants, got: {err}"
@@ -558,10 +554,8 @@ pub mod running_tests {
558554
559555 #[ test]
560556 fn vote_add_domains__should_reject_reconstruction_threshold_above_governance ( ) {
561- // Given a Frost proposal whose ReconstructionThreshold exceeds the
562- // GovernanceThreshold (but is still <= participant count).
563- // GovernanceThreshold 4 < participant count 5, so `governance + 1 <= n`:
564- // the rejection comes from the threshold relation, not the n ceiling.
557+ // Given governance 4 < n = 5, so `governance + 1 <= n`: the rejection
558+ // comes from the threshold relation, not the n ceiling.
565559 let ( mut state, _env) = setup_with_params ( 1 , 5 , 4 ) ;
566560 let governance = state. parameters . threshold ( ) . value ( ) ;
567561 let proposal = single_domain_proposal (
@@ -574,8 +568,7 @@ pub mod running_tests {
574568 // When
575569 let err = state. vote_add_domains ( proposal) . unwrap_err ( ) ;
576570
577- // Then the GovernanceThreshold/ReconstructionThreshold relation is enforced via the
578- // canonical validate_governance_against_reconstruction helper.
571+ // Then
579572 assert ! (
580573 matches!(
581574 err,
@@ -587,9 +580,7 @@ pub mod running_tests {
587580
588581 #[ test]
589582 fn vote_add_domains__should_reject_damgard_etal_threshold_violating_honest_majority ( ) {
590- // Given a running state and a DamgardEtAl proposal with `2t - 1 > n`.
591- // gen_threshold_params produces n in [3, 30]; pick t = n so that
592- // 2t - 1 > n holds (universally true for n >= 2).
583+ // Given a DamgardEtAl proposal with t = n, so `2t - 1 > n` for any n >= 2.
593584 let ( mut state, _env) = setup ( 1 ) ;
594585 let n = state. parameters . participants ( ) . len ( ) as u64 ;
595586 let proposal = single_domain_proposal (
@@ -599,10 +590,10 @@ pub mod running_tests {
599590 ReconstructionThreshold :: new ( n) ,
600591 ) ;
601592
602- // When voting to add the domain
593+ // When
603594 let err = state. vote_add_domains ( proposal) . unwrap_err ( ) ;
604595
605- // Then the DamgardEtAl-specific bound is enforced
596+ // Then
606597 assert ! (
607598 err. to_string( ) . contains( "requires at least" ) ,
608599 "Expected InsufficientParticipantsForProtocol, got: {err}"
@@ -611,16 +602,15 @@ pub mod running_tests {
611602
612603 #[ test]
613604 fn process_new_parameters_proposal__should_accept_empty_per_domain_threshold_updates ( ) {
614- // Given a running state where existing thresholds are valid under the
615- // proposed participant count
605+ // Given
616606 let ( mut state, mut env) = setup ( 1 ) ;
617607 let proposal = gen_valid_params_proposal ( & state. parameters ) ;
618608 env. set_signer ( & overlapping_signer ( & state, & proposal) ) ;
619609
620610 // When voting with an empty per_domain_thresholds map (legacy shape)
621611 let res = state. vote_new_parameters ( state. keyset . epoch_id . next ( ) , & proposal) ;
622612
623- // Then the vote is recorded without error
613+ // Then
624614 assert ! (
625615 res. is_ok( ) ,
626616 "Expected accept with empty threshold updates: {res:?}"
@@ -629,11 +619,11 @@ pub mod running_tests {
629619
630620 #[ test]
631621 fn process_new_parameters_proposal__should_reject_threshold_update_with_unknown_domain_id ( ) {
632- // Given a running state with one domain
622+ // Given
633623 let ( mut state, _env) = setup ( 1 ) ;
634624 let proposal = gen_valid_params_proposal ( & state. parameters ) ;
635625
636- // When voting with a threshold update referencing a non-existent domain ID
626+ // When voting with a threshold update for a non-existent domain ID
637627 let proposal = proposal. with_per_domain_thresholds ( BTreeMap :: from ( [ (
638628 DomainId ( 9999 ) ,
639629 ReconstructionThreshold :: new ( 2 ) ,
@@ -642,17 +632,15 @@ pub mod running_tests {
642632 . vote_new_parameters ( state. keyset . epoch_id . next ( ) , & proposal)
643633 . unwrap_err ( ) ;
644634
645- // Then the unknown-domain guard rejects it
635+ // Then
646636 assert ! (
647637 err. to_string( ) . contains( "not in the current registry" ) ,
648638 "Expected UnknownDomainInProposal, got: {err}"
649639 ) ;
650640 }
651641
652- /// Each case proposes a single valid domain; `reconstruction_threshold` of
653- /// `None` means "use the GovernanceThreshold", the maximum allowed value
654- /// (the upper boundary case). `pinned_params` of `None` uses the randomized
655- /// fixture defaults.
642+ /// `reconstruction_threshold: None` means the GovernanceThreshold (the
643+ /// maximum allowed); `pinned_params: None` uses the randomized fixture.
656644 #[ rstest]
657645 #[ case:: caitsith_threshold_differing_from_existing( 1 , Some ( ( 5 , 5 ) ) , Protocol :: CaitSith , Some ( 3 ) ) ]
658646 #[ case:: caitsith_threshold_matching_existing( 1 , None , Protocol :: CaitSith , Some ( 2 ) ) ]
@@ -682,16 +670,13 @@ pub mod running_tests {
682670 // When
683671 let res = state. vote_add_domains ( proposal) ;
684672
685- // Then the vote is recorded without error (single voter is below
686- // quorum, so no transition).
673+ // Then the vote is recorded (single voter is below quorum, so no transition)
687674 assert ! ( res. is_ok( ) , "Expected acceptance: {res:?}" ) ;
688675 }
689676
690677 #[ test]
691678 fn vote_add_domains__should_accept_two_new_caitsith_with_differing_thresholds ( ) {
692- // Given a Running state with no existing CaitSith and a proposal
693- // adding two CaitSith domains at different thresholds.
694- // GovernanceThreshold 5 so reconstruction thresholds 2 and 3 are allowed.
679+ // Given a proposal adding two CaitSith domains at different thresholds
695680 let ( mut state, _env) = setup_with_params ( 0 , 5 , 5 ) ;
696681 let next_id = state. domains . next_domain_id ( ) ;
697682 let proposal = vec ! [
@@ -718,13 +703,11 @@ pub mod running_tests {
718703
719704 #[ test]
720705 fn process_new_parameters_proposal__should_apply_threshold_update_to_validation ( ) {
721- // Given a running state with one domain whose existing threshold would
722- // remain valid under the new participants, but the threshold update
723- // swaps it for an invalid (too-low) value.
706+ // Given
724707 let ( mut state, _env) = setup ( 1 ) ;
725708 let proposal = gen_valid_params_proposal ( & state. parameters ) ;
726709
727- // When voting with a threshold update that violates the universal lower bound
710+ // When a threshold update swaps a valid stored value for a too-low one
728711 let domain_id = state. domains . domains ( ) [ 0 ] . id ;
729712 let proposal = proposal. with_per_domain_thresholds ( BTreeMap :: from ( [ (
730713 domain_id,
@@ -734,7 +717,7 @@ pub mod running_tests {
734717 . vote_new_parameters ( state. keyset . epoch_id . next ( ) , & proposal)
735718 . unwrap_err ( ) ;
736719
737- // Then the updated value ( not the stored value) is validated and rejected
720+ // Then the updated value, not the stored one, is validated
738721 assert ! (
739722 err. to_string( )
740723 . contains( "Reconstruction threshold must be at least" ) ,
@@ -744,23 +727,20 @@ pub mod running_tests {
744727
745728 #[ test]
746729 fn process_new_parameters_proposal__should_accept_valid_per_domain_threshold_update ( ) {
747- // Given a running state with one CaitSith domain at the fixture default
748- // t = 2.
749- // GovernanceThreshold 4 so the proposal's ReconstructionThreshold (3) fits.
730+ // Given governance 4 so a ReconstructionThreshold of 3 fits
750731 let ( mut state, mut env) = setup_with_params ( 1 , 5 , 4 ) ;
751732 let proposal = gen_valid_params_proposal ( & state. parameters ) ;
752733 env. set_signer ( & overlapping_signer ( & state, & proposal) ) ;
753734
754- // When voting with an update raising t to 3, which stays within both the proposed
755- // participant count and the GovernanceThreshold (>= 3 by the pinned params above).
735+ // When voting with an update raising t from the fixture default 2 to 3
756736 let domain_id = state. domains . domains ( ) [ 0 ] . id ;
757737 let proposal = proposal. with_per_domain_thresholds ( BTreeMap :: from ( [ (
758738 domain_id,
759739 ReconstructionThreshold :: new ( 3 ) ,
760740 ) ] ) ) ;
761741 let res = state. vote_new_parameters ( state. keyset . epoch_id . next ( ) , & proposal) ;
762742
763- // Then the vote is recorded without error
743+ // Then
764744 assert ! (
765745 res. is_ok( ) ,
766746 "Expected accept with valid threshold update: {res:?}"
@@ -770,7 +750,7 @@ pub mod running_tests {
770750 #[ test]
771751 fn process_new_parameters_proposal__should_reject_threshold_update_exceeding_participant_count ( )
772752 {
773- // Given a running state with one domain
753+ // Given
774754 let ( mut state, _env) = setup ( 1 ) ;
775755 let proposal = gen_valid_params_proposal ( & state. parameters ) ;
776756
@@ -786,7 +766,6 @@ pub mod running_tests {
786766 . unwrap_err ( ) ;
787767
788768 // Then the updated value is validated against the proposed participants
789- // and rejected.
790769 assert ! (
791770 err. to_string( ) . contains( "exceeds participant count" ) ,
792771 "Expected ReconstructionThresholdExceedsParticipants, got: {err}"
@@ -795,9 +774,8 @@ pub mod running_tests {
795774
796775 #[ test]
797776 fn process_new_parameters_proposal__should_accept_threshold_update_diverging_caitsith ( ) {
798- // Given a running state with two CaitSith domains, both at the fixture
799- // default t = 2 (the protocols cycle, so 5 domains yields two CaitSith).
800- // GovernanceThreshold 4 so the proposal's ReconstructionThreshold (3) fits.
777+ // Given two CaitSith domains at the fixture default t = 2 (the
778+ // protocols cycle, so 5 domains yields two CaitSith)
801779 let ( mut state, mut env) = setup_with_params ( 5 , 5 , 4 ) ;
802780 assert ! (
803781 state
@@ -812,8 +790,7 @@ pub mod running_tests {
812790 let proposal = gen_valid_params_proposal ( & state. parameters ) ;
813791 env. set_signer ( & overlapping_signer ( & state, & proposal) ) ;
814792
815- // When an update raises only one CaitSith domain's threshold, leaving the
816- // CaitSith domains non-uniform.
793+ // When an update raises only one CaitSith domain's threshold
817794 let caitsith_id = state
818795 . domains
819796 . domains ( )
0 commit comments