@@ -140,12 +140,21 @@ mod test_seer {
140
140
141
141
#[test]
142
142
fn test_toggle_yang_price_conversion () {
143
+ let gate_class = declare (" gate" ). unwrap ();
143
144
let (sentinel , shrine , yangs , _gates ) = sentinel_utils :: deploy_sentinel_with_gates (
144
- Option :: None , Option :: None , Option :: None , Option :: None , Option :: None
145
+ Option :: None , Option :: None , Option :: Some ( gate_class ) , Option :: None
145
146
);
147
+ let eth_addr : ContractAddress = * yangs . at (0 );
148
+ let wbtc_addr : ContractAddress = * yangs . at (1 );
149
+
150
+ let (vaults , _vault_gates ) = sentinel_utils :: add_vaults_to_sentinel (
151
+ shrine , sentinel , gate_class , Option :: None , eth_addr , wbtc_addr
152
+ );
153
+
146
154
let seer : ISeerV2Dispatcher = seer_utils :: deploy_seer_using (
147
- Option :: None , shrine . contract_address, sentinel . contract_address, yangs
155
+ Option :: None , shrine . contract_address, sentinel . contract_address
148
156
);
157
+ seer_utils :: toggle_vaults_in_seer (seer , vaults );
149
158
150
159
let mut spy = spy_events (SpyOn :: One (seer . contract_address));
151
160
@@ -155,7 +164,7 @@ mod test_seer {
155
164
pragma_utils :: add_yangs_v2 (* oracles . at (0 ), yangs );
156
165
157
166
let eth = * yangs . at (0 );
158
- let eth_vault = * yangs . at (2 );
167
+ let eth_vault = * vaults . at (0 );
159
168
let conversion_rate_info = ConversionRateInfo { asset : eth , conversion_rate_scale : 1_u128 };
160
169
161
170
assert (
@@ -204,24 +213,6 @@ mod test_seer {
204
213
seer . toggle_yang_price_conversion (seer_utils :: dummy_eth ());
205
214
}
206
215
207
- // This is commented out because we are unable to catch the exception of an entry point selector that
208
- // cannot be found.
209
- // #[test]
210
- // #[should_panic]
211
- // fn test_toggle_yang_not_vault_asset() {
212
- // let (sentinel, shrine, yangs, _gates) = sentinel_utils::deploy_sentinel_with_gates(
213
- // Option::None, Option::None, Option::None, Option::None, Option::None
214
- // );
215
- // let seer: ISeerV2Dispatcher = seer_utils::deploy_seer_using(
216
- // Option::None, shrine.contract_address, sentinel.contract_address, yangs
217
- // );
218
-
219
- // let eth = *yangs.at(0);
220
-
221
- // start_prank(CheatTarget::One(seer.contract_address), seer_utils::admin());
222
- // seer.toggle_yang_price_conversion(eth);
223
- // }
224
-
225
216
#[test]
226
217
#[should_panic(expected: (' SEER: Zero conversion rate' ,))]
227
218
fn test_toggle_yang_zero_conversion_rate () {
@@ -276,12 +267,21 @@ mod test_seer {
276
267
277
268
#[test]
278
269
fn test_update_prices_successful () {
270
+ let gate_class = declare (" gate" ). unwrap ();
279
271
let (sentinel , shrine , yangs , gates ) = sentinel_utils :: deploy_sentinel_with_gates (
280
- Option :: None , Option :: None , Option :: None , Option :: None , Option :: None
272
+ Option :: None , Option :: None , Option :: Some (gate_class ), Option :: None
273
+ );
274
+ let eth_addr : ContractAddress = * yangs . at (0 );
275
+ let wbtc_addr : ContractAddress = * yangs . at (1 );
276
+
277
+ let (vaults , vault_gates ) = sentinel_utils :: add_vaults_to_sentinel (
278
+ shrine , sentinel , gate_class , Option :: None , eth_addr , wbtc_addr
281
279
);
280
+
282
281
let seer : ISeerV2Dispatcher = seer_utils :: deploy_seer_using (
283
- Option :: None , shrine . contract_address, sentinel . contract_address, yangs
282
+ Option :: None , shrine . contract_address, sentinel . contract_address
284
283
);
284
+ seer_utils :: toggle_vaults_in_seer (seer , vaults );
285
285
286
286
let mut spy = spy_events (SpyOn :: One (seer . contract_address));
287
287
@@ -293,14 +293,12 @@ mod test_seer {
293
293
let mut eth_price : Wad = seer_utils :: ETH_INIT_PRICE . into ();
294
294
let mut wbtc_price : Wad = seer_utils :: WBTC_INIT_PRICE . into ();
295
295
296
- let eth_addr : ContractAddress = * yangs . at (0 );
297
- let wbtc_addr : ContractAddress = * yangs . at (1 );
298
- let eth_vault_addr : ContractAddress = * yangs . at (2 );
299
- let wbtc_vault_addr : ContractAddress = * yangs . at (3 );
296
+ let eth_vault_addr : ContractAddress = * vaults . at (0 );
297
+ let wbtc_vault_addr : ContractAddress = * vaults . at (1 );
300
298
let eth_gate : IGateDispatcher = * gates . at (0 );
301
299
let wbtc_gate : IGateDispatcher = * gates . at (1 );
302
- let eth_vault_gate : IGateDispatcher = * gates . at (2 );
303
- let wbtc_vault_gate : IGateDispatcher = * gates . at (3 );
300
+ let eth_vault_gate : IGateDispatcher = * vault_gates . at (0 );
301
+ let wbtc_vault_gate : IGateDispatcher = * vault_gates . at (1 );
304
302
let pragma : ContractAddress = * (oracles [0 ]);
305
303
let switchboard : ContractAddress = * (oracles [1 ]);
306
304
@@ -350,19 +348,19 @@ mod test_seer {
350
348
let expected_missing_seer = array! [
351
349
(
352
350
seer . contract_address,
353
- seer_contract :: Event :: PriceUpdateMissed (seer_contract :: PriceUpdateMissed { yang : * yangs [ 0 ] })
351
+ seer_contract :: Event :: PriceUpdateMissed (seer_contract :: PriceUpdateMissed { yang : eth_addr })
354
352
),
355
353
(
356
354
seer . contract_address,
357
- seer_contract :: Event :: PriceUpdateMissed (seer_contract :: PriceUpdateMissed { yang : * yangs [ 1 ] })
355
+ seer_contract :: Event :: PriceUpdateMissed (seer_contract :: PriceUpdateMissed { yang : wbtc_addr })
358
356
),
359
357
(
360
358
seer . contract_address,
361
- seer_contract :: Event :: PriceUpdateMissed (seer_contract :: PriceUpdateMissed { yang : * yangs [ 2 ] })
359
+ seer_contract :: Event :: PriceUpdateMissed (seer_contract :: PriceUpdateMissed { yang : eth_vault_addr })
362
360
),
363
361
(
364
362
seer . contract_address,
365
- seer_contract :: Event :: PriceUpdateMissed (seer_contract :: PriceUpdateMissed { yang : * yangs [ 3 ] })
363
+ seer_contract :: Event :: PriceUpdateMissed (seer_contract :: PriceUpdateMissed { yang : wbtc_vault_addr })
366
364
),
367
365
(
368
366
seer . contract_address,
@@ -491,13 +489,21 @@ mod test_seer {
491
489
492
490
#[test]
493
491
fn test_update_prices_from_fallback_oracle_successful () {
492
+ let gate_class = declare (" gate" ). unwrap ();
494
493
let (sentinel , shrine , yangs , _gates ) = sentinel_utils :: deploy_sentinel_with_gates (
495
- Option :: None , Option :: None , Option :: None , Option :: None , Option :: None
494
+ Option :: None , Option :: None , Option :: Some (gate_class ), Option :: None
495
+ );
496
+ let eth_addr : ContractAddress = * yangs [0 ];
497
+ let wbtc_addr : ContractAddress = * yangs [1 ];
498
+
499
+ let (vaults , _vault_gates ) = sentinel_utils :: add_vaults_to_sentinel (
500
+ shrine , sentinel , gate_class , Option :: None , eth_addr , wbtc_addr
496
501
);
497
502
498
503
let seer : ISeerV2Dispatcher = seer_utils :: deploy_seer_using (
499
- Option :: None , shrine . contract_address, sentinel . contract_address, yangs
504
+ Option :: None , shrine . contract_address, sentinel . contract_address
500
505
);
506
+ seer_utils :: toggle_vaults_in_seer (seer , vaults );
501
507
502
508
let oracles : Span <ContractAddress > = seer_utils :: add_oracles (
503
509
seer , Option :: None , Option :: None , Option :: None , Option :: None
@@ -507,7 +513,6 @@ mod test_seer {
507
513
508
514
// mock an ETH price update of spot Pragma that will fail due to too few sources,
509
515
// causing Seer to use Switchboard
510
- let eth_addr : ContractAddress = * yangs [0 ];
511
516
let eth_price : Wad = seer_utils :: ETH_INIT_PRICE . into ();
512
517
let pragma = IOracleDispatcher { contract_address : * oracles [0 ] };
513
518
let mock_pragma = IMockPragmaDispatcher { contract_address : * pragma . get_oracles (). at (0 ) };
@@ -533,7 +538,6 @@ mod test_seer {
533
538
534
539
let pragma : ContractAddress = * oracles . at (0 );
535
540
let switchboard : ContractAddress = * oracles . at (1 );
536
- let wbtc_addr : ContractAddress = * yangs [1 ];
537
541
// asserting that PriceUpdate event for ETH coming from Switchboard,
538
542
// but for WBTC coming from Pragma
539
543
let expected_events_seer = array! [
@@ -558,12 +562,21 @@ mod test_seer {
558
562
559
563
#[test]
560
564
fn test_update_prices_via_execute_task_successful () {
565
+ let gate_class = declare (" gate" ). unwrap ();
561
566
let (sentinel , shrine , yangs , _ ) = sentinel_utils :: deploy_sentinel_with_gates (
562
- Option :: None , Option :: None , Option :: None , Option :: None , Option :: None
567
+ Option :: None , Option :: None , Option :: Some (gate_class ), Option :: None
568
+ );
569
+ let eth_addr : ContractAddress = * yangs . at (0 );
570
+ let wbtc_addr : ContractAddress = * yangs . at (1 );
571
+
572
+ let (vaults , _vault_gates ) = sentinel_utils :: add_vaults_to_sentinel (
573
+ shrine , sentinel , gate_class , Option :: None , eth_addr , wbtc_addr
563
574
);
575
+
564
576
let seer : ISeerV2Dispatcher = seer_utils :: deploy_seer_using (
565
- Option :: None , shrine . contract_address, sentinel . contract_address, yangs
577
+ Option :: None , shrine . contract_address, sentinel . contract_address
566
578
);
579
+ seer_utils :: toggle_vaults_in_seer (seer , vaults );
567
580
568
581
let mut spy = spy_events (SpyOn :: One (seer . contract_address));
569
582
@@ -619,11 +632,11 @@ mod test_seer {
619
632
#[test]
620
633
#[should_panic(expected: (' PGM: Unknown yang' ,))]
621
634
fn test_update_prices_fails_with_no_yangs_in_seer () {
622
- let (sentinel , shrine , yangs , _gates ) = sentinel_utils :: deploy_sentinel_with_gates (
623
- Option :: None , Option :: None , Option :: None , Option :: None , Option :: None
635
+ let (sentinel , shrine , _yangs , _gates ) = sentinel_utils :: deploy_sentinel_with_gates (
636
+ Option :: None , Option :: None , Option :: None , Option :: None
624
637
);
625
638
let seer : ISeerV2Dispatcher = seer_utils :: deploy_seer_using (
626
- Option :: None , shrine . contract_address, sentinel . contract_address, yangs
639
+ Option :: None , shrine . contract_address, sentinel . contract_address
627
640
);
628
641
seer_utils :: add_oracles (seer , Option :: None , Option :: None , Option :: None , Option :: None );
629
642
start_prank (CheatTarget :: One (seer . contract_address), seer_utils :: admin ());
@@ -634,11 +647,11 @@ mod test_seer {
634
647
#[should_panic]
635
648
fn test_update_prices_fails_with_wrong_yang_in_seer () {
636
649
let token_class = Option :: Some (declare (" erc20_mintable" ). unwrap ());
637
- let (sentinel , shrine , yangs , _gates ) = sentinel_utils :: deploy_sentinel_with_gates (
638
- Option :: None , token_class , Option :: None , Option :: None , Option :: None
650
+ let (sentinel , shrine , _yangs , _gates ) = sentinel_utils :: deploy_sentinel_with_gates (
651
+ Option :: None , token_class , Option :: None , Option :: None
639
652
);
640
653
let seer : ISeerV2Dispatcher = seer_utils :: deploy_seer_using (
641
- Option :: None , shrine . contract_address, sentinel . contract_address, yangs
654
+ Option :: None , shrine . contract_address, sentinel . contract_address
642
655
);
643
656
let oracles : Span <ContractAddress > = seer_utils :: add_oracles (
644
657
seer , Option :: None , Option :: None , Option :: None , Option :: None
@@ -663,10 +676,10 @@ mod test_seer {
663
676
#[test]
664
677
fn test_update_prices_missed_updates () {
665
678
let (sentinel , shrine , yangs , _gates ) = sentinel_utils :: deploy_sentinel_with_gates (
666
- Option :: None , Option :: None , Option :: None , Option :: None , Option :: None
679
+ Option :: None , Option :: None , Option :: None , Option :: None
667
680
);
668
681
let seer : ISeerV2Dispatcher = seer_utils :: deploy_seer_using (
669
- Option :: None , shrine . contract_address, sentinel . contract_address, yangs
682
+ Option :: None , shrine . contract_address, sentinel . contract_address
670
683
);
671
684
672
685
let mut spy = spy_events (SpyOn :: One (seer . contract_address));
@@ -730,12 +743,22 @@ mod test_seer {
730
743
731
744
#[test]
732
745
fn test_probe_task () {
746
+ let gate_class = declare (" gate" ). unwrap ();
733
747
let (sentinel , shrine , yangs , _gates ) = sentinel_utils :: deploy_sentinel_with_gates (
734
- Option :: None , Option :: None , Option :: None , Option :: None , Option :: None
748
+ Option :: None , Option :: None , Option :: Some (gate_class ), Option :: None
749
+ );
750
+ let eth_addr : ContractAddress = * yangs . at (0 );
751
+ let wbtc_addr : ContractAddress = * yangs . at (1 );
752
+
753
+ let (vaults , _vault_gates ) = sentinel_utils :: add_vaults_to_sentinel (
754
+ shrine , sentinel , gate_class , Option :: None , eth_addr , wbtc_addr
735
755
);
756
+
736
757
let seer : ISeerV2Dispatcher = seer_utils :: deploy_seer_using (
737
- Option :: None , shrine . contract_address, sentinel . contract_address, yangs
758
+ Option :: None , shrine . contract_address, sentinel . contract_address
738
759
);
760
+ seer_utils :: toggle_vaults_in_seer (seer , vaults );
761
+
739
762
let oracles : Span <ContractAddress > = seer_utils :: add_oracles (
740
763
seer , Option :: None , Option :: None , Option :: None , Option :: None
741
764
);
0 commit comments