@@ -337,6 +337,69 @@ Test(oracle, pc_size ) {
337337 PC_COMP_SIZE * sizeof ( pc_price_comp_t ) );
338338}
339339
340+ Test ( oracle , upd_test ) {
341+
342+ // Initialize the test account
343+ SolPubkey p_id = {.x = { 0xff , }};
344+ SolPubkey pkey = {.x = { 1 , }};
345+ SolPubkey mkey = {.x = { 2 , }};
346+ uint64_t pqty = 100 ;
347+ pc_map_table_t mptr [1 ];
348+ sol_memset ( mptr , 0 , sizeof ( pc_price_t ) );
349+ SolAccountInfo acc [] = {{
350+ .key = & pkey ,
351+ .lamports = & pqty ,
352+ .data_len = 0 ,
353+ .data = NULL ,
354+ .owner = NULL ,
355+ .rent_epoch = 0 ,
356+ .is_signer = true,
357+ .is_writable = true,
358+ .executable = false
359+ },{
360+ .key = & mkey ,
361+ .lamports = & pqty ,
362+ .data_len = sizeof ( pc_price_t ),
363+ .data = (uint8_t * )mptr ,
364+ .owner = & p_id ,
365+ .rent_epoch = 0 ,
366+ .is_signer = true,
367+ .is_writable = true,
368+ .executable = false
369+ }};
370+ cmd_hdr_t hdata = {
371+ .ver_ = PC_VERSION ,
372+ .cmd_ = e_cmd_init_test ,
373+ };
374+ SolParameters prm = {
375+ .ka = acc ,
376+ .ka_num = 2 ,
377+ .data = (const uint8_t * )& hdata ,
378+ .data_len = sizeof ( hdata ),
379+ .program_id = & p_id
380+ };
381+ cr_assert ( SUCCESS == dispatch ( & prm , acc ) );
382+
383+ // Try and send an upd_test instruction with an invalid num_ parameter
384+ cmd_upd_test_t idata = {
385+ .ver_ = PC_VERSION ,
386+ .cmd_ = e_cmd_upd_test ,
387+ .num_ = PC_COMP_SIZE + 1 ,
388+ .expo_ = -8 ,
389+ .slot_diff_ = {1 , 1 },
390+ .price_ = {10 , 10 },
391+ .conf_ = {20 , 20 }
392+ };
393+ prm .data = (const uint8_t * )& idata ;
394+ prm .data_len = sizeof ( idata );
395+ cr_assert ( ERROR_INVALID_ARGUMENT == dispatch ( & prm , acc ) );
396+
397+ // Send an upd_test instruction with a valid num_ parameter
398+ idata .num_ = 2 ;
399+ cr_assert ( SUCCESS == dispatch ( & prm , acc ) );
400+
401+ }
402+
340403Test ( oracle , upd_price ) {
341404 cmd_upd_price_t idata = {
342405 .ver_ = PC_VERSION ,
0 commit comments