1
1
use crate :: {
2
2
bank:: {
3
- pyth_accumulator:: { get_accumulator_keys, ACCUMULATOR_RING_SIZE } ,
3
+ pyth_accumulator:: { get_accumulator_keys, ACCUMULATOR_RING_SIZE , ORACLE_PUBKEY } ,
4
4
Bank ,
5
5
} ,
6
6
genesis_utils:: { create_genesis_config_with_leader, GenesisConfigInfo } ,
7
7
} ;
8
8
use byteorder:: ByteOrder ;
9
9
use byteorder:: { LittleEndian , ReadBytesExt } ;
10
10
use itertools:: Itertools ;
11
+ use pyth_oracle:: solana_program:: account_info:: AccountInfo ;
12
+ use pyth_oracle:: { PriceAccount , PythAccount } ;
11
13
use pythnet_sdk:: {
12
14
accumulators:: { merkle:: MerkleAccumulator , Accumulator } ,
13
15
hashers:: { keccak256_160:: Keccak160 , Hasher } ,
@@ -17,6 +19,7 @@ use pythnet_sdk::{
17
19
use solana_sdk:: {
18
20
account:: { AccountSharedData , ReadableAccount , WritableAccount } ,
19
21
borsh:: { BorshDeserialize , BorshSerialize } ,
22
+ clock:: Epoch ,
20
23
epoch_schedule:: EpochSchedule ,
21
24
feature:: { self , Feature } ,
22
25
feature_set,
@@ -25,7 +28,7 @@ use solana_sdk::{
25
28
signature:: keypair_from_seed,
26
29
signer:: Signer ,
27
30
} ;
28
- use std:: { io:: Read , sync:: Arc } ;
31
+ use std:: { io:: Read , mem :: size_of , sync:: Arc } ;
29
32
30
33
// Create Message Account Bytes
31
34
//
@@ -125,6 +128,25 @@ fn test_update_accumulator_sysvar() {
125
128
// Store Message account so the accumulator sysvar updater can find it.
126
129
bank. store_account ( & price_message_key. pubkey ( ) , & price_message_account) ;
127
130
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
+
128
150
// Derive the Wormhole Message Account that will be generated by the sysvar updater.
129
151
let ( wormhole_message_pubkey, _bump) = Pubkey :: find_program_address (
130
152
& [ b"AccumulatorMessage" , & ( bank. slot ( ) as u32 ) . to_be_bytes ( ) ] ,
@@ -396,6 +418,25 @@ fn test_update_accumulator_end_of_block() {
396
418
// Store Message account so the accumulator sysvar updater can find it.
397
419
bank. store_account ( & price_message_key. pubkey ( ) , & price_message_account) ;
398
420
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
+
399
440
// Derive the Wormhole Message Account that will be generated by the sysvar updater.
400
441
let ( wormhole_message_pubkey, _bump) = Pubkey :: find_program_address (
401
442
& [ b"AccumulatorMessage" , & ( bank. slot ( ) as u32 ) . to_be_bytes ( ) ] ,
@@ -631,7 +672,6 @@ fn test_update_accumulator_end_of_block() {
631
672
#[ test]
632
673
fn test_get_accumulator_keys ( ) {
633
674
use pythnet_sdk:: { pythnet, ACCUMULATOR_EMITTER_ADDRESS , MESSAGE_BUFFER_PID } ;
634
- let leader_pubkey = solana_sdk:: pubkey:: new_rand ( ) ;
635
675
let accumulator_keys: Vec < Pubkey > = get_accumulator_keys ( )
636
676
. iter ( )
637
677
. map ( |( _, pk_res) | * pk_res. as_ref ( ) . unwrap ( ) )
0 commit comments