@@ -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 ) ;
@@ -317,8 +314,11 @@ mod tests {
317314 #[ test]
318315 fn vote_new_parameters__should_reject_when_per_domain_threshold_exceeds_participants ( ) {
319316 // Given: a Running contract with 3 participants and one domain.
320- let ( mut contract, participants, signer, domain_id) =
321- setup_running_contract_with_domain ( 3 , 2 , 2 ) ;
317+ let ( mut contract, participants, signer, domain_id) = setup_running_contract_with_domain (
318+ 3 ,
319+ GovernanceThreshold :: new ( 2 ) ,
320+ ReconstructionThreshold :: new ( 2 ) ,
321+ ) ;
322322 // ...and a proposal raising that domain's reconstruction threshold to 4.
323323 let mut per_domain = BTreeMap :: new ( ) ;
324324 per_domain. insert ( domain_id, ReconstructionThreshold :: new ( 4 ) ) ;
@@ -343,8 +343,11 @@ mod tests {
343343 #[ test]
344344 fn vote_new_parameters__should_reject_when_shrinking_below_governance_threshold ( ) {
345345 // Given: a Running contract with 4 participants and a GovernanceThreshold of 3.
346- let ( mut contract, participants, signer, _domain_id) =
347- setup_running_contract_with_domain ( 4 , 3 , 3 ) ;
346+ let ( mut contract, participants, signer, _domain_id) = setup_running_contract_with_domain (
347+ 4 ,
348+ GovernanceThreshold :: new ( 3 ) ,
349+ ReconstructionThreshold :: new ( 3 ) ,
350+ ) ;
348351 // ...and a proposal that shrinks the participant set to 2 without touching
349352 // the per-domain thresholds.
350353 let proposal = ProposedGovernanceThresholdParameters :: new (
@@ -372,8 +375,11 @@ mod tests {
372375 #[ test]
373376 fn vote_new_parameters__should_reject_when_signing_threshold_exceeds_participants ( ) {
374377 // Given: a Running contract with 3 participants and one domain.
375- let ( mut contract, participants, signer, _domain_id) =
376- setup_running_contract_with_domain ( 3 , 2 , 2 ) ;
378+ let ( mut contract, participants, signer, _domain_id) = setup_running_contract_with_domain (
379+ 3 ,
380+ GovernanceThreshold :: new ( 2 ) ,
381+ ReconstructionThreshold :: new ( 2 ) ,
382+ ) ;
377383 // ...and a proposal whose signing threshold (4) exceeds the participant set.
378384 let proposal = ProposedGovernanceThresholdParameters :: new (
379385 GovernanceThresholdParameters :: new_unvalidated (
@@ -396,8 +402,11 @@ mod tests {
396402 #[ test]
397403 fn vote_new_parameters__should_accept_per_domain_threshold_within_participant_count ( ) {
398404 // Given: a Running contract with 5 participants (GovernanceThreshold 4) and one domain.
399- let ( mut contract, participants, signer, domain_id) =
400- setup_running_contract_with_domain ( 5 , 4 , 2 ) ;
405+ let ( mut contract, participants, signer, domain_id) = setup_running_contract_with_domain (
406+ 5 ,
407+ GovernanceThreshold :: new ( 4 ) ,
408+ ReconstructionThreshold :: new ( 2 ) ,
409+ ) ;
401410 // ...and a proposal raising the domain's reconstruction threshold to 4,
402411 // which fits the 5 participants and does not exceed the GovernanceThreshold.
403412 let mut per_domain = BTreeMap :: new ( ) ;
@@ -418,8 +427,11 @@ mod tests {
418427 fn vote_new_parameters__should_reject_governance_below_max_reconstruction ( ) {
419428 // Given: a Running contract with 5 participants, GovernanceThreshold 4, and a
420429 // domain whose reconstruction threshold is 4.
421- let ( mut contract, participants, signer, _domain_id) =
422- setup_running_contract_with_domain ( 5 , 4 , 4 ) ;
430+ let ( mut contract, participants, signer, _domain_id) = setup_running_contract_with_domain (
431+ 5 ,
432+ GovernanceThreshold :: new ( 4 ) ,
433+ ReconstructionThreshold :: new ( 4 ) ,
434+ ) ;
423435 // ...and a proposal lowering the GovernanceThreshold to 3 (valid on its own)
424436 // while the domain keeps its reconstruction threshold of 4.
425437 let proposal = ProposedGovernanceThresholdParameters :: new (
@@ -447,9 +459,9 @@ mod tests {
447459 // Given: a participant whose vote is forwarded through another contract,
448460 // so signer_account_id (the participant) != predecessor_account_id (the forwarder).
449461 let ( mut contract, participants, first_participant_id) = setup_tee_test_contract ( 3 , 2 ) ;
450- let threshold = GovernanceThreshold :: new ( 2 ) ;
462+ let governance_threshold = GovernanceThreshold :: new ( 2 ) ;
451463 let proposal = ProposedGovernanceThresholdParameters :: new (
452- GovernanceThresholdParameters :: new ( participants, threshold ) . unwrap ( ) ,
464+ GovernanceThresholdParameters :: new ( participants, governance_threshold ) . unwrap ( ) ,
453465 BTreeMap :: new ( ) ,
454466 ) ;
455467
0 commit comments