pyth_solana_receiver_sdk/
config.rs1use {anchor_lang::prelude::*, solana_program::pubkey::Pubkey};
2
3#[account]
4#[derive(Debug, PartialEq)]
5pub struct Config {
6 pub governance_authority: Pubkey, pub target_governance_authority: Option<Pubkey>, pub wormhole: Pubkey, pub valid_data_sources: Vec<DataSource>, pub single_update_fee_in_lamports: u64, pub minimum_signatures: u8, }
13
14#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Debug)]
15pub struct DataSource {
16 pub chain: u16,
17 pub emitter: Pubkey,
18}
19
20impl Config {
21 pub const LEN: usize = 370; }
23
24#[cfg(test)]
25pub mod tests {
26 use {
27 super::DataSource,
28 crate::config::Config,
29 anchor_lang::{AnchorSerialize, Discriminator},
30 solana_program::pubkey::Pubkey,
31 };
32
33 #[test]
34 fn check_size() {
35 let test_config = Config {
36 governance_authority: Pubkey::new_unique(),
37 target_governance_authority: Some(Pubkey::new_unique()),
38 wormhole: Pubkey::new_unique(),
39 valid_data_sources: vec![
40 DataSource {
41 chain: 1,
42 emitter: Pubkey::new_unique(),
43 },
44 DataSource {
45 chain: 2,
46 emitter: Pubkey::new_unique(),
47 },
48 ],
49 single_update_fee_in_lamports: 0,
50 minimum_signatures: 0,
51 };
52
53 assert_eq!(
54 test_config.try_to_vec().unwrap().len(),
55 32 + 1 + 32 + 32 + 4 + 1 + 33 + 1 + 33 + 8 + 1
56 );
57 assert!(
58 Config::discriminator().len() + test_config.try_to_vec().unwrap().len() <= Config::LEN
59 );
60 }
61}