@@ -143,7 +143,7 @@ mod tests {
143143 contract : & mut MpcContract ,
144144 first_participant_id : & AccountId ,
145145 participants : Participants ,
146- threshold : GovernanceThreshold ,
146+ governance_threshold : GovernanceThreshold ,
147147 ) -> Result < ( ) , Error > {
148148 let voting_context = VMContextBuilder :: new ( )
149149 . signer_account_id ( first_participant_id. clone ( ) )
@@ -153,7 +153,7 @@ mod tests {
153153 testing_env ! ( voting_context) ;
154154
155155 let proposal = ProposedGovernanceThresholdParameters :: new (
156- GovernanceThresholdParameters :: new ( participants, threshold ) . unwrap ( ) ,
156+ GovernanceThresholdParameters :: new ( participants, governance_threshold ) . unwrap ( ) ,
157157 BTreeMap :: new ( ) ,
158158 ) ;
159159 contract. vote_new_parameters ( EpochId :: new ( 1 ) , ( & proposal) . into_dto_type ( ) )
@@ -166,14 +166,14 @@ mod tests {
166166 #[ test]
167167 fn test_vote_new_parameters_succeeds_with_default_tee_status ( ) {
168168 let ( mut contract, participants, first_participant_id) = setup_tee_test_contract ( 3 , 2 ) ;
169- let threshold = GovernanceThreshold :: new ( 2 ) ;
169+ let governance_threshold = GovernanceThreshold :: new ( 2 ) ;
170170
171171 // No attestations submitted - all participants have default TEE status None
172172 let result = setup_voting_context_and_vote (
173173 & mut contract,
174174 & first_participant_id,
175175 participants,
176- threshold ,
176+ governance_threshold ,
177177 ) ;
178178 assert ! (
179179 result. is_ok( ) ,
@@ -188,7 +188,7 @@ mod tests {
188188 #[ test]
189189 fn test_vote_new_parameters_succeeds_when_all_participants_have_valid_tee ( ) {
190190 let ( mut contract, participants, first_participant_id) = setup_tee_test_contract ( 3 , 2 ) ;
191- let threshold = GovernanceThreshold :: new ( 2 ) ;
191+ let governance_threshold = GovernanceThreshold :: new ( 2 ) ;
192192
193193 // Submit valid attestations for all participants
194194 submit_valid_attestations ( & mut contract, & participants, & [ 0 , 1 , 2 ] ) ;
@@ -198,7 +198,7 @@ mod tests {
198198 & mut contract,
199199 & first_participant_id,
200200 participants,
201- threshold ,
201+ governance_threshold ,
202202 ) ;
203203 assert ! (
204204 result. is_ok( ) ,
@@ -215,7 +215,7 @@ mod tests {
215215 #[ test]
216216 fn test_vote_new_parameters_succeeds_after_invalid_attestation_rejected ( ) {
217217 let ( mut contract, participants, first_participant_id) = setup_tee_test_contract ( 4 , 3 ) ;
218- let threshold = GovernanceThreshold :: new ( 3 ) ;
218+ let governance_threshold = GovernanceThreshold :: new ( 3 ) ;
219219
220220 // Submit valid attestations for first 3 participants
221221 submit_valid_attestations ( & mut contract, & participants, & [ 0 , 1 , 2 ] ) ;
@@ -245,21 +245,21 @@ mod tests {
245245 & mut contract,
246246 & first_participant_id,
247247 participants,
248- threshold ,
248+ governance_threshold ,
249249 ) ;
250250 assert ! (
251251 result. is_ok( ) ,
252252 "Should succeed when participants have Valid or None TEE status (invalid attestations rejected)"
253253 ) ;
254254 }
255255
256- /// Builds a Running contract with `num_participants` participants, signing
257- /// threshold ` threshold` , and a single CaitSith [`Sign`] domain whose
258- /// reconstruction threshold is `reconstruction_threshold` .
256+ /// Builds a Running contract with `num_participants` participants, the given
257+ /// governance threshold, and a single CaitSith [`Sign`] domain with the given
258+ /// reconstruction threshold.
259259 fn setup_running_contract_with_domain (
260260 num_participants : usize ,
261- threshold : u64 ,
262- reconstruction_threshold : u64 ,
261+ governance_threshold : GovernanceThreshold ,
262+ reconstruction_threshold : ReconstructionThreshold ,
263263 ) -> ( MpcContract , Participants , AccountId , DomainId ) {
264264 let participants = gen_participants ( num_participants) ;
265265 let first_participant_id = participants. participants ( ) [ 0 ] . 0 . clone ( ) ;
@@ -271,16 +271,13 @@ mod tests {
271271 . build( )
272272 ) ;
273273
274- let parameters = GovernanceThresholdParameters :: new (
275- participants. clone ( ) ,
276- GovernanceThreshold :: new ( threshold) ,
277- )
278- . unwrap ( ) ;
274+ let parameters =
275+ GovernanceThresholdParameters :: new ( participants. clone ( ) , governance_threshold) . unwrap ( ) ;
279276 let domain_id = DomainId :: default ( ) ;
280277 let domains = vec ! [ DomainConfig {
281278 id: domain_id,
282279 protocol: Protocol :: CaitSith ,
283- reconstruction_threshold: ReconstructionThreshold :: new ( reconstruction_threshold ) ,
280+ reconstruction_threshold,
284281 purpose: DomainPurpose :: Sign ,
285282 } ] ;
286283 let ( pk, _) = make_public_key_for_curve ( Curve :: Secp256k1 , & mut OsRng ) ;
@@ -322,8 +319,11 @@ mod tests {
322319 #[ test]
323320 fn vote_new_parameters__should_reject_when_per_domain_threshold_exceeds_participants ( ) {
324321 // Given: a Running contract with 3 participants and one domain.
325- let ( mut contract, participants, signer, domain_id) =
326- setup_running_contract_with_domain ( 3 , 2 , 2 ) ;
322+ let ( mut contract, participants, signer, domain_id) = setup_running_contract_with_domain (
323+ 3 ,
324+ GovernanceThreshold :: new ( 2 ) ,
325+ ReconstructionThreshold :: new ( 2 ) ,
326+ ) ;
327327 // ...and a proposal raising that domain's reconstruction threshold to 4.
328328 let mut per_domain = BTreeMap :: new ( ) ;
329329 per_domain. insert ( domain_id, ReconstructionThreshold :: new ( 4 ) ) ;
@@ -348,8 +348,11 @@ mod tests {
348348 #[ test]
349349 fn vote_new_parameters__should_reject_when_shrinking_below_governance_threshold ( ) {
350350 // Given: a Running contract with 4 participants and a GovernanceThreshold of 3.
351- let ( mut contract, participants, signer, _domain_id) =
352- setup_running_contract_with_domain ( 4 , 3 , 3 ) ;
351+ let ( mut contract, participants, signer, _domain_id) = setup_running_contract_with_domain (
352+ 4 ,
353+ GovernanceThreshold :: new ( 3 ) ,
354+ ReconstructionThreshold :: new ( 3 ) ,
355+ ) ;
353356 // ...and a proposal that shrinks the participant set to 2 without touching
354357 // the per-domain thresholds.
355358 let proposal = ProposedGovernanceThresholdParameters :: new (
@@ -377,8 +380,11 @@ mod tests {
377380 #[ test]
378381 fn vote_new_parameters__should_reject_when_signing_threshold_exceeds_participants ( ) {
379382 // Given: a Running contract with 3 participants and one domain.
380- let ( mut contract, participants, signer, _domain_id) =
381- setup_running_contract_with_domain ( 3 , 2 , 2 ) ;
383+ let ( mut contract, participants, signer, _domain_id) = setup_running_contract_with_domain (
384+ 3 ,
385+ GovernanceThreshold :: new ( 2 ) ,
386+ ReconstructionThreshold :: new ( 2 ) ,
387+ ) ;
382388 // ...and a proposal whose signing threshold (4) exceeds the participant set.
383389 let proposal = ProposedGovernanceThresholdParameters :: new (
384390 GovernanceThresholdParameters :: new_unvalidated (
@@ -401,8 +407,11 @@ mod tests {
401407 #[ test]
402408 fn vote_new_parameters__should_accept_per_domain_threshold_within_participant_count ( ) {
403409 // Given: a Running contract with 5 participants (GovernanceThreshold 4) and one domain.
404- let ( mut contract, participants, signer, domain_id) =
405- setup_running_contract_with_domain ( 5 , 4 , 2 ) ;
410+ let ( mut contract, participants, signer, domain_id) = setup_running_contract_with_domain (
411+ 5 ,
412+ GovernanceThreshold :: new ( 4 ) ,
413+ ReconstructionThreshold :: new ( 2 ) ,
414+ ) ;
406415 // ...and a proposal raising the domain's reconstruction threshold to 4,
407416 // which fits the 5 participants and does not exceed the GovernanceThreshold.
408417 let mut per_domain = BTreeMap :: new ( ) ;
@@ -423,8 +432,11 @@ mod tests {
423432 fn vote_new_parameters__should_reject_governance_below_max_reconstruction ( ) {
424433 // Given: a Running contract with 5 participants, GovernanceThreshold 4, and a
425434 // domain whose reconstruction threshold is 4.
426- let ( mut contract, participants, signer, _domain_id) =
427- setup_running_contract_with_domain ( 5 , 4 , 4 ) ;
435+ let ( mut contract, participants, signer, _domain_id) = setup_running_contract_with_domain (
436+ 5 ,
437+ GovernanceThreshold :: new ( 4 ) ,
438+ ReconstructionThreshold :: new ( 4 ) ,
439+ ) ;
428440 // ...and a proposal lowering the GovernanceThreshold to 3 (valid on its own)
429441 // while the domain keeps its reconstruction threshold of 4.
430442 let proposal = ProposedGovernanceThresholdParameters :: new (
@@ -452,9 +464,9 @@ mod tests {
452464 // Given: a participant whose vote is forwarded through another contract,
453465 // so signer_account_id (the participant) != predecessor_account_id (the forwarder).
454466 let ( mut contract, participants, first_participant_id) = setup_tee_test_contract ( 3 , 2 ) ;
455- let threshold = GovernanceThreshold :: new ( 2 ) ;
467+ let governance_threshold = GovernanceThreshold :: new ( 2 ) ;
456468 let proposal = ProposedGovernanceThresholdParameters :: new (
457- GovernanceThresholdParameters :: new ( participants, threshold ) . unwrap ( ) ,
469+ GovernanceThresholdParameters :: new ( participants, governance_threshold ) . unwrap ( ) ,
458470 BTreeMap :: new ( ) ,
459471 ) ;
460472
0 commit comments