@@ -450,9 +450,10 @@ Test( oracle, upd_price ) {
450450
451451Test ( oracle , batch_upd_price ) {
452452
453- // In this test we submit a batch update containing both a valid and invalid
454- // price update. The valid update should have an affect; the invalid update
455- // should not, and the transaction should complete successfully.
453+ // In this test we submit a batch update containing two price updates for different
454+ // price accounts. We will only permission the publisher account for the first price
455+ // account, making the update to the second invalid. The valid update should have an
456+ // affect; the invalid update should not, and the transaction should complete successfully.
456457
457458 // Set up the Solana accounts
458459 SolPubkey p_id = {.x = { 0xff , }};
@@ -472,9 +473,11 @@ Test( oracle, batch_upd_price ) {
472473 sptr [i ].ptype_ = PC_PTYPE_PRICE ;
473474 sptr [i ].type_ = PC_ACCTYPE_PRICE ;
474475 sptr [i ].num_ = 1 ;
475- pc_pub_key_assign ( & sptr [i ].comp_ [0 ].pub_ , (pc_pub_key_t * )& pkey );
476476 }
477477
478+ // Only permission the publisher account for the first price account.
479+ pc_pub_key_assign ( & sptr [0 ].comp_ [0 ].pub_ , (pc_pub_key_t * )& pkey );
480+
478481 SolAccountInfo acc [] = {{
479482 .key = & pkey ,
480483 .lamports = & pqty ,
@@ -486,38 +489,39 @@ Test( oracle, batch_upd_price ) {
486489 .is_writable = true,
487490 .executable = false
488491 },{
489- .key = & skey ,
492+ .key = ( SolPubkey * ) sysvar_clock ,
490493 .lamports = & sqty ,
491- .data_len = sizeof ( pc_price_t ),
492- .data = (uint8_t * )& sptr [ 0 ] ,
494+ .data_len = sizeof ( sysvar_clock_t ),
495+ .data = (uint8_t * )& cvar ,
493496 .owner = & p_id ,
494497 .rent_epoch = 0 ,
495498 .is_signer = false,
496- .is_writable = true ,
499+ .is_writable = false ,
497500 .executable = false
498501 },{
499502 .key = & skey ,
500503 .lamports = & sqty ,
501504 .data_len = sizeof ( pc_price_t ),
502- .data = (uint8_t * )& sptr [1 ],
505+ .data = (uint8_t * )& sptr [0 ],
503506 .owner = & p_id ,
504507 .rent_epoch = 0 ,
505508 .is_signer = false,
506509 .is_writable = true,
507510 .executable = false
508511 },{
509- .key = ( SolPubkey * ) sysvar_clock ,
512+ .key = & skey ,
510513 .lamports = & sqty ,
511- .data_len = sizeof ( sysvar_clock_t ),
512- .data = (uint8_t * )& cvar ,
514+ .data_len = sizeof ( pc_price_t ),
515+ .data = (uint8_t * )& sptr [ 1 ] ,
513516 .owner = & p_id ,
514517 .rent_epoch = 0 ,
515518 .is_signer = false,
516- .is_writable = false ,
519+ .is_writable = true ,
517520 .executable = false
518521 }};
519522
520- // Create a request with two updates: one valid and one invalid
523+ // Create a request with two updates: one valid and one invalid. The second update is invalid
524+ // because the publisher key isn't permissioned for that price account.
521525 uint64_t data_len = sizeof (cmd_batch_upd_price_header_t ) + (sizeof (cmd_upd_price_t ) * num_price_accounts );
522526 char input_data [data_len ];
523527 cmd_batch_upd_price_t * req = (cmd_batch_upd_price_t * )& input_data ;
@@ -534,9 +538,9 @@ Test( oracle, batch_upd_price ) {
534538 upd -> conf_ = 9L ;
535539 upd -> pub_slot_ = 1 ;
536540
537- // The invalid update: incorrect program version
541+ // The invalid update: not permissioned
538542 upd = & req -> upds_ [1 ];
539- upd -> ver_ = 1 ;
543+ upd -> ver_ = PC_VERSION ;
540544 upd -> cmd_ = e_cmd_batch_upd_price ;
541545 upd -> status_ = PC_STATUS_TRADING ;
542546 upd -> price_ = 73L ;
0 commit comments