@@ -5,7 +5,7 @@ use snforge_std::{
5
5
use pyth :: pyth :: {
6
6
IPythDispatcher , IPythDispatcherTrait , DataSource , Event as PythEvent , PriceFeedUpdated ,
7
7
WormholeAddressSet , GovernanceDataSourceSet , ContractUpgraded , DataSourcesSet , FeeSet ,
8
- PriceFeedPublishTime , GetPriceNoOlderThanError , Price , PriceFeed ,
8
+ PriceFeedPublishTime , GetPriceNoOlderThanError , Price , PriceFeed , GetPriceUnsafeError ,
9
9
};
10
10
use pyth :: byte_array :: {ByteArray , ByteArrayImpl };
11
11
use pyth :: util :: {array_try_into, UnwrapWithFelt252 };
@@ -131,6 +131,19 @@ fn update_price_feeds_works() {
131
131
assert! (last_ema_price . conf == 4096812700 );
132
132
assert! (last_ema_price . expo == - 8 );
133
133
assert! (last_ema_price . publish_time == 1712589206 );
134
+
135
+ let feed = pyth
136
+ . query_price_feed_unsafe (0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43 )
137
+ . unwrap_with_felt252 ();
138
+ assert! (feed . id == 0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43 );
139
+ assert! (feed . price. price == 7192002930010 );
140
+ assert! (feed . price. conf == 3596501465 );
141
+ assert! (feed . price. expo == - 8 );
142
+ assert! (feed . price. publish_time == 1712589206 );
143
+ assert! (feed . ema_price. price == 7181868900000 );
144
+ assert! (feed . ema_price. conf == 4096812700 );
145
+ assert! (feed . ema_price. expo == - 8 );
146
+ assert! (feed . ema_price. publish_time == 1712589206 );
134
147
}
135
148
136
149
#[test]
@@ -407,10 +420,18 @@ fn test_get_no_older_works() {
407
420
let fee_contract = deploy_fee_contract (user );
408
421
let pyth = deploy_default (wormhole . contract_address, fee_contract . contract_address);
409
422
let price_id = 0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43 ;
423
+ let err = pyth . get_price_unsafe (price_id ). unwrap_err ();
424
+ assert! (err == GetPriceUnsafeError :: PriceFeedNotFound );
425
+ let err = pyth . get_ema_price_unsafe (price_id ). unwrap_err ();
426
+ assert! (err == GetPriceUnsafeError :: PriceFeedNotFound );
427
+ let err = pyth . query_price_feed_unsafe (price_id ). unwrap_err ();
428
+ assert! (err == GetPriceUnsafeError :: PriceFeedNotFound );
410
429
let err = pyth . get_price_no_older_than (price_id , 100 ). unwrap_err ();
411
430
assert! (err == GetPriceNoOlderThanError :: PriceFeedNotFound );
412
431
let err = pyth . get_ema_price_no_older_than (price_id , 100 ). unwrap_err ();
413
432
assert! (err == GetPriceNoOlderThanError :: PriceFeedNotFound );
433
+ let err = pyth . query_price_feed_no_older_than (price_id , 100 ). unwrap_err ();
434
+ assert! (err == GetPriceNoOlderThanError :: PriceFeedNotFound );
414
435
415
436
start_prank (CheatTarget :: One (fee_contract . contract_address), user . try_into (). unwrap ());
416
437
fee_contract . approve (pyth . contract_address, 10000 );
@@ -425,6 +446,8 @@ fn test_get_no_older_works() {
425
446
assert! (err == GetPriceNoOlderThanError :: StalePrice );
426
447
let err = pyth . get_ema_price_no_older_than (price_id , 3 ). unwrap_err ();
427
448
assert! (err == GetPriceNoOlderThanError :: StalePrice );
449
+ let err = pyth . query_price_feed_no_older_than (price_id , 3 ). unwrap_err ();
450
+ assert! (err == GetPriceNoOlderThanError :: StalePrice );
428
451
429
452
start_warp (CheatTarget :: One (pyth . contract_address), 1712589208 );
430
453
let val = pyth . get_price_no_older_than (price_id , 3 ). unwrap_with_felt252 ();
@@ -433,6 +456,9 @@ fn test_get_no_older_works() {
433
456
let val = pyth . get_ema_price_no_older_than (price_id , 3 ). unwrap_with_felt252 ();
434
457
assert! (val . publish_time == 1712589206 );
435
458
assert! (val . price == 7181868900000 );
459
+ let val = pyth . query_price_feed_no_older_than (price_id , 3 ). unwrap_with_felt252 ();
460
+ assert! (val . price. publish_time == 1712589206 );
461
+ assert! (val . price. price == 7192002930010 );
436
462
437
463
start_warp (CheatTarget :: One (pyth . contract_address), 1712589204 );
438
464
let val = pyth . get_price_no_older_than (price_id , 3 ). unwrap_with_felt252 ();
@@ -441,6 +467,9 @@ fn test_get_no_older_works() {
441
467
let val = pyth . get_ema_price_no_older_than (price_id , 3 ). unwrap_with_felt252 ();
442
468
assert! (val . publish_time == 1712589206 );
443
469
assert! (val . price == 7181868900000 );
470
+ let val = pyth . query_price_feed_no_older_than (price_id , 3 ). unwrap_with_felt252 ();
471
+ assert! (val . price. publish_time == 1712589206 );
472
+ assert! (val . price. price == 7192002930010 );
444
473
445
474
stop_warp (CheatTarget :: One (pyth . contract_address));
446
475
}
0 commit comments