@@ -303,7 +303,7 @@ Test( oracle, add_publisher ) {
303
303
304
304
// Now give the price account enough lamports to be rent exempt
305
305
acc [1 ].lamports = & PRICE_ACCOUNT_LAMPORTS ;
306
-
306
+
307
307
cr_assert ( SUCCESS == dispatch ( & prm , acc ) );
308
308
cr_assert ( sptr -> num_ == 1 );
309
309
cr_assert ( pc_pub_key_equal ( & idata .pub_ , & sptr -> comp_ [0 ].pub_ ) );
@@ -348,7 +348,7 @@ Test(oracle, pc_size ) {
348
348
}
349
349
350
350
Test ( oracle , upd_test ) {
351
-
351
+
352
352
// Initialize the test account
353
353
SolPubkey p_id = {.x = { 0xff , }};
354
354
SolPubkey pkey = {.x = { 1 , }};
@@ -416,7 +416,7 @@ Test( oracle, upd_price ) {
416
416
.cmd_ = e_cmd_upd_price ,
417
417
.status_ = PC_STATUS_TRADING ,
418
418
.price_ = 42L ,
419
- .conf_ = 9L ,
419
+ .conf_ = 2L ,
420
420
.pub_slot_ = 1
421
421
};
422
422
SolPubkey p_id = {.x = { 0xff , }};
@@ -474,7 +474,7 @@ Test( oracle, upd_price ) {
474
474
};
475
475
cr_assert ( SUCCESS == dispatch ( & prm , acc ) );
476
476
cr_assert ( sptr -> comp_ [0 ].latest_ .price_ == 42L );
477
- cr_assert ( sptr -> comp_ [0 ].latest_ .conf_ == 9L );
477
+ cr_assert ( sptr -> comp_ [0 ].latest_ .conf_ == 2L );
478
478
cr_assert ( sptr -> comp_ [0 ].latest_ .pub_slot_ == 1 );
479
479
cr_assert ( sptr -> agg_ .pub_slot_ == 1 );
480
480
cr_assert ( sptr -> valid_slot_ == 0 );
@@ -519,6 +519,30 @@ Test( oracle, upd_price ) {
519
519
// try to publish back-in-time
520
520
idata .pub_slot_ = 1 ;
521
521
cr_assert ( ERROR_INVALID_ARGUMENT == dispatch ( & prm , acc ) );
522
+
523
+
524
+ // Publishing a wide CI results in a status of unknown.
525
+
526
+ // check that someone doesn't accidentally break the test.
527
+ cr_assert (sptr -> comp_ [0 ].latest_ .status_ == PC_STATUS_TRADING );
528
+ idata .pub_slot_ = 5 ;
529
+ cvar .slot_ = 6 ;
530
+ idata .price_ = 50 ;
531
+ idata .conf_ = 6 ;
532
+ cr_assert ( SUCCESS == dispatch ( & prm , acc ) );
533
+ cr_assert ( sptr -> comp_ [0 ].latest_ .price_ == 50L );
534
+ cr_assert ( sptr -> comp_ [0 ].latest_ .conf_ == 6L );
535
+ cr_assert ( sptr -> comp_ [0 ].latest_ .status_ == PC_STATUS_UNKNOWN );
536
+ cr_assert ( sptr -> comp_ [0 ].latest_ .pub_slot_ == 5 );
537
+ cr_assert ( sptr -> agg_ .pub_slot_ == 6 );
538
+ // Aggregate is still trading because it uses price from previous slot
539
+ cr_assert ( sptr -> agg_ .status_ == PC_STATUS_TRADING );
540
+
541
+ // Crank one more time and aggregate should be unknown
542
+ idata .pub_slot_ = 6 ;
543
+ cvar .slot_ = 7 ;
544
+ cr_assert ( SUCCESS == dispatch ( & prm , acc ) );
545
+ cr_assert ( sptr -> agg_ .status_ == PC_STATUS_UNKNOWN );
522
546
}
523
547
524
548
Test ( oracle , upd_price_no_fail_on_error ) {
@@ -544,7 +568,7 @@ Test( oracle, upd_price_no_fail_on_error ) {
544
568
sptr -> ptype_ = PC_PTYPE_PRICE ;
545
569
sptr -> type_ = PC_ACCTYPE_PRICE ;
546
570
sptr -> num_ = 1 ;
547
-
571
+
548
572
SolAccountInfo acc [] = {{
549
573
.key = & pkey ,
550
574
.lamports = & pqty ,
@@ -592,7 +616,7 @@ Test( oracle, upd_price_no_fail_on_error ) {
592
616
cr_assert ( sptr -> comp_ [0 ].latest_ .conf_ == 0L );
593
617
cr_assert ( sptr -> comp_ [0 ].latest_ .pub_slot_ == 0 );
594
618
cr_assert ( sptr -> agg_ .pub_slot_ == 0 );
595
- cr_assert ( sptr -> valid_slot_ == 0 );
619
+ cr_assert ( sptr -> valid_slot_ == 0 );
596
620
597
621
// Now permission the publish account for the price account.
598
622
pc_pub_key_assign ( & sptr -> comp_ [0 ].pub_ , (pc_pub_key_t * )& pkey );
@@ -605,7 +629,7 @@ Test( oracle, upd_price_no_fail_on_error ) {
605
629
cr_assert ( sptr -> agg_ .pub_slot_ == 1 );
606
630
cr_assert ( sptr -> valid_slot_ == 0 );
607
631
608
- // Invalid updates, such as publishing an update for the current slot,
632
+ // Invalid updates, such as publishing an update for the current slot,
609
633
// should still fail silently and have no effect.
610
634
idata .price_ = 55L ;
611
635
idata .conf_ = 22L ;
0 commit comments