11use crate :: {
22 bank:: {
3- pyth_accumulator:: { get_accumulator_keys, ACCUMULATOR_RING_SIZE } ,
3+ pyth_accumulator:: { get_accumulator_keys, ACCUMULATOR_RING_SIZE , ORACLE_PUBKEY } ,
44 Bank ,
55 } ,
66 genesis_utils:: { create_genesis_config_with_leader, GenesisConfigInfo } ,
77} ;
88use byteorder:: ByteOrder ;
99use byteorder:: { LittleEndian , ReadBytesExt } ;
1010use itertools:: Itertools ;
11+ use pyth_oracle:: solana_program:: account_info:: AccountInfo ;
12+ use pyth_oracle:: { PriceAccount , PythAccount } ;
1113use pythnet_sdk:: {
1214 accumulators:: { merkle:: MerkleAccumulator , Accumulator } ,
1315 hashers:: { keccak256_160:: Keccak160 , Hasher } ,
@@ -17,6 +19,7 @@ use pythnet_sdk::{
1719use solana_sdk:: {
1820 account:: { AccountSharedData , ReadableAccount , WritableAccount } ,
1921 borsh:: { BorshDeserialize , BorshSerialize } ,
22+ clock:: Epoch ,
2023 epoch_schedule:: EpochSchedule ,
2124 feature:: { self , Feature } ,
2225 feature_set,
@@ -25,7 +28,7 @@ use solana_sdk::{
2528 signature:: keypair_from_seed,
2629 signer:: Signer ,
2730} ;
28- use std:: { io:: Read , sync:: Arc } ;
31+ use std:: { io:: Read , mem :: size_of , sync:: Arc } ;
2932
3033// Create Message Account Bytes
3134//
@@ -125,6 +128,25 @@ fn test_update_accumulator_sysvar() {
125128 // Store Message account so the accumulator sysvar updater can find it.
126129 bank. store_account ( & price_message_key. pubkey ( ) , & price_message_account) ;
127130
131+ let ( price_feed_key, _bump) = Pubkey :: find_program_address ( & [ b"123" ] , & ORACLE_PUBKEY ) ;
132+ let mut price_feed_account =
133+ AccountSharedData :: new ( 42 , size_of :: < PriceAccount > ( ) , & ORACLE_PUBKEY ) ;
134+ PriceAccount :: initialize (
135+ & AccountInfo :: new (
136+ & price_feed_key. to_bytes ( ) . into ( ) ,
137+ false ,
138+ true ,
139+ & mut 0 ,
140+ & mut price_feed_account. data_mut ( ) ,
141+ & ORACLE_PUBKEY . to_bytes ( ) . into ( ) ,
142+ false ,
143+ Epoch :: default ( ) ,
144+ ) ,
145+ 0 ,
146+ )
147+ . unwrap ( ) ;
148+ bank. store_account ( & price_feed_key, & price_feed_account) ;
149+
128150 // Derive the Wormhole Message Account that will be generated by the sysvar updater.
129151 let ( wormhole_message_pubkey, _bump) = Pubkey :: find_program_address (
130152 & [ b"AccumulatorMessage" , & ( bank. slot ( ) as u32 ) . to_be_bytes ( ) ] ,
@@ -396,6 +418,25 @@ fn test_update_accumulator_end_of_block() {
396418 // Store Message account so the accumulator sysvar updater can find it.
397419 bank. store_account ( & price_message_key. pubkey ( ) , & price_message_account) ;
398420
421+ let ( price_feed_key, _bump) = Pubkey :: find_program_address ( & [ b"123" ] , & ORACLE_PUBKEY ) ;
422+ let mut price_feed_account =
423+ AccountSharedData :: new ( 42 , size_of :: < PriceAccount > ( ) , & ORACLE_PUBKEY ) ;
424+ PriceAccount :: initialize (
425+ & AccountInfo :: new (
426+ & price_feed_key. to_bytes ( ) . into ( ) ,
427+ false ,
428+ true ,
429+ & mut 0 ,
430+ & mut price_feed_account. data_mut ( ) ,
431+ & ORACLE_PUBKEY . to_bytes ( ) . into ( ) ,
432+ false ,
433+ Epoch :: default ( ) ,
434+ ) ,
435+ 0 ,
436+ )
437+ . unwrap ( ) ;
438+ bank. store_account ( & price_feed_key, & price_feed_account) ;
439+
399440 // Derive the Wormhole Message Account that will be generated by the sysvar updater.
400441 let ( wormhole_message_pubkey, _bump) = Pubkey :: find_program_address (
401442 & [ b"AccumulatorMessage" , & ( bank. slot ( ) as u32 ) . to_be_bytes ( ) ] ,
@@ -631,7 +672,6 @@ fn test_update_accumulator_end_of_block() {
631672#[ test]
632673fn test_get_accumulator_keys ( ) {
633674 use pythnet_sdk:: { pythnet, ACCUMULATOR_EMITTER_ADDRESS , MESSAGE_BUFFER_PID } ;
634- let leader_pubkey = solana_sdk:: pubkey:: new_rand ( ) ;
635675 let accumulator_keys: Vec < Pubkey > = get_accumulator_keys ( )
636676 . iter ( )
637677 . map ( |( _, pk_res) | * pk_res. as_ref ( ) . unwrap ( ) )
0 commit comments