@@ -337,15 +337,15 @@ async fn on_error<'a, C: Unlocked + 'static>(
337
337
#[ cfg( test) ]
338
338
mod test {
339
339
use super :: * ;
340
- use crate :: sentry_interface:: { AuthToken , ChainsValidators , Validator } ;
340
+ use crate :: sentry_interface:: { ChainsValidators , Validator } ;
341
341
use adapter:: dummy:: { Adapter , Dummy , Options } ;
342
342
use chrono:: Utc ;
343
343
use primitives:: {
344
344
balances:: UncheckedState ,
345
- config:: { configuration , Environment } ,
345
+ config:: GANACHE_CONFIG ,
346
346
test_util:: {
347
- discard_logger, ServerSetup , ADVERTISER , DUMMY_CAMPAIGN , DUMMY_VALIDATOR_FOLLOWER ,
348
- DUMMY_VALIDATOR_LEADER , FOLLOWER , GUARDIAN , GUARDIAN_2 , IDS , LEADER , PUBLISHER ,
347
+ discard_logger, ServerSetup , ADVERTISER , DUMMY_AUTH , DUMMY_CAMPAIGN , DUMMY_VALIDATOR_FOLLOWER ,
348
+ DUMMY_VALIDATOR_LEADER , FOLLOWER , CREATOR , GUARDIAN_2 , IDS , LEADER , PUBLISHER ,
349
349
PUBLISHER_2 ,
350
350
} ,
351
351
util:: ApiUrl ,
@@ -361,20 +361,18 @@ mod test {
361
361
362
362
let adapter = Adapter :: with_unlocked ( Dummy :: init ( Options {
363
363
dummy_identity : IDS [ & LEADER ] ,
364
- dummy_auth_tokens : vec ! [ ( IDS [ & LEADER ] . to_address( ) , "AUTH_Leader" . into( ) ) ]
365
- . into_iter ( )
366
- . collect ( ) ,
364
+ dummy_auth_tokens : DUMMY_AUTH . clone ( ) ,
367
365
} ) ) ;
368
366
let logger = discard_logger ( ) ;
369
367
370
368
let mut validators: HashMap < ValidatorId , Validator > = HashMap :: new ( ) ;
371
369
let leader = Validator {
372
370
url : ApiUrl :: from_str ( & format ! ( "{}/leader" , server. uri( ) ) ) . expect ( "should be valid" ) ,
373
- token : AuthToken :: default ( ) ,
371
+ token : DUMMY_AUTH . get ( & * LEADER ) . expect ( "should retrieve" ) . to_string ( ) ,
374
372
} ;
375
373
let follower = Validator {
376
374
url : ApiUrl :: from_str ( & format ! ( "{}/follower" , server. uri( ) ) ) . expect ( "should be valid" ) ,
377
- token : AuthToken :: default ( ) ,
375
+ token : DUMMY_AUTH . get ( & * FOLLOWER ) . expect ( "should retrieve" ) . to_string ( ) ,
378
376
} ;
379
377
validators. insert ( DUMMY_VALIDATOR_LEADER . id , leader) ;
380
378
validators. insert ( DUMMY_VALIDATOR_FOLLOWER . id , follower) ;
@@ -390,7 +388,7 @@ mod test {
390
388
#[ tokio:: test]
391
389
async fn test_follower_tick ( ) {
392
390
let server_setup = ServerSetup :: init ( & DUMMY_CAMPAIGN . channel ) . await ;
393
- let config = configuration ( Environment :: Development , None ) . expect ( "Should get Config" ) ;
391
+ let config = GANACHE_CONFIG . clone ( ) ;
394
392
let sentry = setup_sentry ( & server_setup. server , & config) . await ;
395
393
396
394
let channel_context = config
@@ -407,10 +405,10 @@ mod test {
407
405
. spend ( * ADVERTISER , * PUBLISHER_2 , UnifiedNum :: from_u64 ( 1000 ) )
408
406
. expect ( "should spend" ) ;
409
407
balances
410
- . spend ( * GUARDIAN , * PUBLISHER , UnifiedNum :: from_u64 ( 1000 ) )
408
+ . spend ( * CREATOR , * PUBLISHER , UnifiedNum :: from_u64 ( 1000 ) )
411
409
. expect ( "should spend" ) ;
412
410
balances
413
- . spend ( * GUARDIAN , * PUBLISHER_2 , UnifiedNum :: from_u64 ( 1000 ) )
411
+ . spend ( * CREATOR , * PUBLISHER_2 , UnifiedNum :: from_u64 ( 1000 ) )
414
412
. expect ( "should spend" ) ;
415
413
balances
416
414
} ;
@@ -425,7 +423,7 @@ mod test {
425
423
} ,
426
424
) ;
427
425
spenders. insert (
428
- * GUARDIAN ,
426
+ * CREATOR ,
429
427
Spender {
430
428
total_deposited : UnifiedNum :: from_u64 ( 10_000 ) ,
431
429
total_spent : Some ( UnifiedNum :: from_u64 ( 2000 ) ) ,
@@ -446,7 +444,7 @@ mod test {
446
444
} ,
447
445
) ;
448
446
all_spenders. insert (
449
- * GUARDIAN ,
447
+ * CREATOR ,
450
448
Spender {
451
449
total_deposited : UnifiedNum :: from_u64 ( u64:: MAX ) ,
452
450
total_spent : None ,
@@ -541,7 +539,7 @@ mod test {
541
539
)
542
540
. expect ( "should encode" ) ;
543
541
let new_state: NewState < UncheckedState > = NewState {
544
- state_root : state_root ,
542
+ state_root,
545
543
signature : IDS [ & * FOLLOWER ] . to_checksum ( ) ,
546
544
balances : proposed_balances. into_unchecked ( ) ,
547
545
} ;
@@ -581,7 +579,7 @@ mod test {
581
579
)
582
580
. expect ( "should encode" ) ;
583
581
let new_state: NewState < UncheckedState > = NewState {
584
- state_root : state_root ,
582
+ state_root,
585
583
signature : IDS [ & * LEADER ] . to_checksum ( ) ,
586
584
balances : proposed_balances. into_unchecked ( ) ,
587
585
} ;
@@ -627,7 +625,7 @@ mod test {
627
625
)
628
626
. expect ( "should encode" ) ;
629
627
let new_state: NewState < UncheckedState > = NewState {
630
- state_root : state_root ,
628
+ state_root,
631
629
signature : IDS [ & * LEADER ] . to_checksum ( ) ,
632
630
balances : proposed_balances. into_unchecked ( ) ,
633
631
} ;
@@ -667,7 +665,7 @@ mod test {
667
665
. spend ( * ADVERTISER , * PUBLISHER , UnifiedNum :: from_u64 ( 200_000 ) )
668
666
. expect ( "should spend" ) ;
669
667
our_balances
670
- . spend ( * GUARDIAN , * PUBLISHER_2 , UnifiedNum :: from_u64 ( 200_000 ) )
668
+ . spend ( * CREATOR , * PUBLISHER_2 , UnifiedNum :: from_u64 ( 200_000 ) )
671
669
. expect ( "should spend" ) ;
672
670
673
671
let state_root = get_initial_balances ( )
@@ -677,7 +675,7 @@ mod test {
677
675
)
678
676
. expect ( "should encode" ) ;
679
677
let new_state: NewState < UncheckedState > = NewState {
680
- state_root : state_root ,
678
+ state_root,
681
679
signature : IDS [ & * LEADER ] . to_checksum ( ) ,
682
680
balances : get_initial_balances ( ) . into_unchecked ( ) ,
683
681
} ;
@@ -702,8 +700,8 @@ mod test {
702
700
// Case where no NewState is returned
703
701
{
704
702
// Setting up the expected response
705
- let _mock_guard = server_setup. setup_new_state_response ( None ) . await ;
706
- let _mock_guard = server_setup. setup_approve_state_response ( None ) . await ;
703
+ let _mock_guard_new_state = server_setup. setup_new_state_response ( None ) . await ;
704
+ let _mock_guard_approve_state = server_setup. setup_approve_state_response ( None ) . await ;
707
705
708
706
let tick_status = tick (
709
707
& sentry,
@@ -733,13 +731,13 @@ mod test {
733
731
signature : IDS [ & * LEADER ] . to_checksum ( ) ,
734
732
balances : get_initial_balances ( ) . into_unchecked ( ) ,
735
733
} ;
736
- let _mock_guard = server_setup. setup_new_state_response ( Some ( new_state) ) . await ;
734
+ let _mock_guard_new_state = server_setup. setup_new_state_response ( Some ( new_state) ) . await ;
737
735
let approve_state = ApproveState {
738
736
state_root,
739
737
signature : IDS [ & * FOLLOWER ] . to_checksum ( ) ,
740
738
is_healthy : true ,
741
739
} ;
742
- let _mock_guard = server_setup
740
+ let _mock_guard_approve_state = server_setup
743
741
. setup_approve_state_response ( Some ( approve_state) )
744
742
. await ;
745
743
@@ -818,7 +816,7 @@ mod test {
818
816
)
819
817
. expect ( "should encode" ) ;
820
818
let new_state: NewState < UncheckedState > = NewState {
821
- state_root : state_root ,
819
+ state_root,
822
820
signature : IDS [ & * LEADER ] . to_checksum ( ) ,
823
821
balances : get_initial_balances ( ) . into_unchecked ( ) ,
824
822
} ;
@@ -834,7 +832,7 @@ mod test {
834
832
assert ! ( matches!( res, ApproveStateResult :: Sent ( Some ( ..) ) ) ) ;
835
833
let propagated_to = match res {
836
834
ApproveStateResult :: Sent ( propagated_to) => propagated_to,
837
- _ => None , // Shouldn't happen
835
+ _ => panic ! ( " Shouldn't happen" ) ,
838
836
} ;
839
837
let propagated_to: Vec < ValidatorId > = propagated_to
840
838
. unwrap ( )
0 commit comments