pyth_solana_receiver_sdk/
config.rs1use anchor_lang::prelude::*;
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::prelude::*
30 };
31
32 #[test]
33 fn check_size() {
34 let test_config = Config {
35 governance_authority: Pubkey::new_unique(),
36 target_governance_authority: Some(Pubkey::new_unique()),
37 wormhole: Pubkey::new_unique(),
38 valid_data_sources: vec![
39 DataSource {
40 chain: 1,
41 emitter: Pubkey::new_unique(),
42 },
43 DataSource {
44 chain: 2,
45 emitter: Pubkey::new_unique(),
46 },
47 ],
48 single_update_fee_in_lamports: 0,
49 minimum_signatures: 0,
50 };
51
52 assert_eq!(
53 test_config.try_to_vec().unwrap().len(),
54 32 + 1 + 32 + 32 + 4 + 1 + 33 + 1 + 33 + 8 + 1
55 );
56 assert!(
57 Config::DISCRIMINATOR.len() + test_config.try_to_vec().unwrap().len() <= Config::LEN
58 );
59 }
60}