@@ -246,12 +246,12 @@ impl ForeignChainRpcWhitelist {
246246#[ expect( non_snake_case) ]
247247mod tests {
248248 use super :: * ;
249- use crate :: primitives:: { key_state:: AuthenticatedParticipantId , test_utils:: gen_participants} ;
249+ use crate :: primitives:: {
250+ key_state:: AuthenticatedParticipantId , test_utils:: gen_authenticated_participants,
251+ } ;
250252 use assert_matches:: assert_matches;
251253 use mpc_primitives:: Threshold ;
252254 use near_mpc_contract_interface:: types:: AuthScheme ;
253- use near_sdk:: test_utils:: VMContextBuilder ;
254- use near_sdk:: testing_env;
255255
256256 /// Build a `ThresholdParameters` for tests, bypassing the relative-threshold
257257 /// validation so tests can express edge-case combinations (e.g. the stale-votes
@@ -300,22 +300,6 @@ mod tests {
300300 NonEmptyBTreeMap :: try_from ( map) . expect ( "test setup: batch must be non-empty" )
301301 }
302302
303- /// Build `n` participants and pre-authenticate each one. The pattern intentionally
304- /// runs all `testing_env!` resets *before* any storage-backed state is touched —
305- /// later vote ops can then write to the mocked storage without an env reset
306- /// wiping prior writes.
307- fn setup ( n : usize ) -> ( Participants , Vec < AuthenticatedParticipantId > ) {
308- let participants = gen_participants ( n) ;
309- let mut auth_ids = Vec :: with_capacity ( n) ;
310- for ( account_id, _, _) in participants. participants ( ) {
311- let mut ctx = VMContextBuilder :: new ( ) ;
312- ctx. signer_account_id ( account_id. clone ( ) ) ;
313- testing_env ! ( ctx. build( ) ) ;
314- auth_ids. push ( AuthenticatedParticipantId :: new ( & participants) . unwrap ( ) ) ;
315- }
316- ( participants, auth_ids)
317- }
318-
319303 fn assert_malformed ( err : Error , reason_substring : & str ) {
320304 match err {
321305 Error :: InvalidParameters ( InvalidParameters :: MalformedPayload { reason } ) => {
@@ -363,7 +347,7 @@ mod tests {
363347 #[ test]
364348 fn vote__should_apply_chain_when_all_participants_match ( ) {
365349 // Given
366- let ( participants, auth_ids) = setup ( 2 ) ;
350+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
367351 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
368352
369353 // When
@@ -406,7 +390,7 @@ mod tests {
406390 fn vote__should_canonicalize_provider_order_for_threshold_comparison ( ) {
407391 // Two participants submit the same logical set in different orders.
408392 // Given
409- let ( participants, auth_ids) = setup ( 2 ) ;
393+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
410394 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
411395
412396 // When
@@ -431,7 +415,7 @@ mod tests {
431415 #[ test]
432416 fn vote__should_apply_chains_independently ( ) {
433417 // Given
434- let ( participants, auth_ids) = setup ( 2 ) ;
418+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
435419 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
436420
437421 // When: both participants agree on Ethereum, disagree on Polygon.
@@ -475,7 +459,7 @@ mod tests {
475459 #[ test]
476460 fn vote__should_overwrite_only_mentioned_chain_slots_on_recast ( ) {
477461 // Given
478- let ( participants, auth_ids) = setup ( 2 ) ;
462+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
479463 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
480464 let p0 = auth_ids[ 0 ] . clone ( ) ;
481465 wl. vote (
@@ -501,7 +485,7 @@ mod tests {
501485 #[ test]
502486 fn vote__should_overwrite_same_chain_slot_with_latest_proposal ( ) {
503487 // Given: p0 has voted Polygon with providers=[alchemy], response quorum=1.
504- let ( participants, auth_ids) = setup ( 2 ) ;
488+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
505489 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
506490 let p0 = auth_ids[ 0 ] . clone ( ) ;
507491 wl. vote (
@@ -542,7 +526,7 @@ mod tests {
542526 #[ test]
543527 fn vote__should_replace_full_chain_state_on_apply ( ) {
544528 // Given: chain currently holds [alchemy, ankr].
545- let ( participants, auth_ids) = setup ( 2 ) ;
529+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
546530 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
547531 wl. vote (
548532 auth_ids[ 0 ] . clone ( ) ,
@@ -583,7 +567,7 @@ mod tests {
583567
584568 #[ test]
585569 fn vote__should_return_err_on_zero_quorum ( ) {
586- let ( participants, auth_ids) = setup ( 2 ) ;
570+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
587571 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
588572 let err = wl
589573 . vote (
@@ -597,7 +581,7 @@ mod tests {
597581
598582 #[ test]
599583 fn vote__should_return_err_on_quorum_exceeding_providers_len ( ) {
600- let ( participants, auth_ids) = setup ( 2 ) ;
584+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
601585 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
602586 let err = wl
603587 . vote (
@@ -611,7 +595,7 @@ mod tests {
611595
612596 #[ test]
613597 fn vote__should_return_err_on_path_segment_with_slash ( ) {
614- let ( participants, auth_ids) = setup ( 2 ) ;
598+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
615599 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
616600 let bad = (
617601 ProviderId ( "ankr" . to_string ( ) ) ,
@@ -641,7 +625,7 @@ mod tests {
641625
642626 #[ test]
643627 fn vote__should_return_err_on_query_param_name_colliding_with_auth_query ( ) {
644- let ( participants, auth_ids) = setup ( 2 ) ;
628+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
645629 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
646630 let bad = (
647631 ProviderId ( "drpc" . to_string ( ) ) ,
@@ -675,7 +659,7 @@ mod tests {
675659 #[ test]
676660 fn vote__should_accept_non_colliding_query_param_and_auth_query ( ) {
677661 // Given
678- let ( participants, auth_ids) = setup ( 2 ) ;
662+ let ( participants, auth_ids) = gen_authenticated_participants ( 2 ) ;
679663 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
680664 let drpc = || {
681665 (
@@ -727,7 +711,7 @@ mod tests {
727711 fn vote__should_not_count_stale_non_participant_votes ( ) {
728712 // Given: 3 participants; p0 and p1 each vote the same proposal — chain
729713 // hasn't applied yet (count = 2, threshold = 3).
730- let ( participants, auth_ids) = setup ( 3 ) ;
714+ let ( participants, auth_ids) = gen_authenticated_participants ( 3 ) ;
731715 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
732716 wl. vote (
733717 auth_ids[ 0 ] . clone ( ) ,
@@ -765,7 +749,7 @@ mod tests {
765749 #[ test]
766750 fn clean_non_participant_votes__should_drop_stale_votes ( ) {
767751 // Given
768- let ( participants, auth_ids) = setup ( 3 ) ;
752+ let ( participants, auth_ids) = gen_authenticated_participants ( 3 ) ;
769753 let mut wl = ForeignChainRpcWhitelist :: default ( ) ;
770754 let p0 = auth_ids[ 0 ] . clone ( ) ;
771755 let p1 = auth_ids[ 1 ] . clone ( ) ;
0 commit comments