@@ -303,7 +303,7 @@ Test( oracle, add_publisher ) {
303303
304304 // Now give the price account enough lamports to be rent exempt
305305 acc [1 ].lamports = & PRICE_ACCOUNT_LAMPORTS ;
306-
306+
307307 cr_assert ( SUCCESS == dispatch ( & prm , acc ) );
308308 cr_assert ( sptr -> num_ == 1 );
309309 cr_assert ( pc_pub_key_equal ( & idata .pub_ , & sptr -> comp_ [0 ].pub_ ) );
@@ -348,7 +348,7 @@ Test(oracle, pc_size ) {
348348}
349349
350350Test ( oracle , upd_test ) {
351-
351+
352352 // Initialize the test account
353353 SolPubkey p_id = {.x = { 0xff , }};
354354 SolPubkey pkey = {.x = { 1 , }};
@@ -416,7 +416,7 @@ Test( oracle, upd_price ) {
416416 .cmd_ = e_cmd_upd_price ,
417417 .status_ = PC_STATUS_TRADING ,
418418 .price_ = 42L ,
419- .conf_ = 9L ,
419+ .conf_ = 2L ,
420420 .pub_slot_ = 1
421421 };
422422 SolPubkey p_id = {.x = { 0xff , }};
@@ -474,7 +474,7 @@ Test( oracle, upd_price ) {
474474 };
475475 cr_assert ( SUCCESS == dispatch ( & prm , acc ) );
476476 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 );
478478 cr_assert ( sptr -> comp_ [0 ].latest_ .pub_slot_ == 1 );
479479 cr_assert ( sptr -> agg_ .pub_slot_ == 1 );
480480 cr_assert ( sptr -> valid_slot_ == 0 );
@@ -519,6 +519,30 @@ Test( oracle, upd_price ) {
519519 // try to publish back-in-time
520520 idata .pub_slot_ = 1 ;
521521 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 );
522546}
523547
524548Test ( oracle , upd_price_no_fail_on_error ) {
@@ -544,7 +568,7 @@ Test( oracle, upd_price_no_fail_on_error ) {
544568 sptr -> ptype_ = PC_PTYPE_PRICE ;
545569 sptr -> type_ = PC_ACCTYPE_PRICE ;
546570 sptr -> num_ = 1 ;
547-
571+
548572 SolAccountInfo acc [] = {{
549573 .key = & pkey ,
550574 .lamports = & pqty ,
@@ -592,7 +616,7 @@ Test( oracle, upd_price_no_fail_on_error ) {
592616 cr_assert ( sptr -> comp_ [0 ].latest_ .conf_ == 0L );
593617 cr_assert ( sptr -> comp_ [0 ].latest_ .pub_slot_ == 0 );
594618 cr_assert ( sptr -> agg_ .pub_slot_ == 0 );
595- cr_assert ( sptr -> valid_slot_ == 0 );
619+ cr_assert ( sptr -> valid_slot_ == 0 );
596620
597621 // Now permission the publish account for the price account.
598622 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 ) {
605629 cr_assert ( sptr -> agg_ .pub_slot_ == 1 );
606630 cr_assert ( sptr -> valid_slot_ == 0 );
607631
608- // Invalid updates, such as publishing an update for the current slot,
632+ // Invalid updates, such as publishing an update for the current slot,
609633 // should still fail silently and have no effect.
610634 idata .price_ = 55L ;
611635 idata .conf_ = 22L ;
0 commit comments