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