Skip to content

Commit

Permalink
Do it
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos committed Jan 30, 2024
1 parent 01cdc02 commit 96d10c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use {
dummy_guardians,
DEFAULT_DATA_SOURCE,
},
serde_wormhole::RawMessage,
solana_program::{
keccak,
pubkey::Pubkey,
Expand All @@ -39,6 +40,7 @@ use {
},
ID as BRIDGE_ID,
},
wormhole_sdk::Vaa,
};

pub const DEFAULT_GUARDIAN_SET_INDEX: u32 = 0;
Expand All @@ -63,15 +65,15 @@ pub struct ProgramTestFixtures {
pub encoded_vaa_addresses: Vec<Pubkey>,
}

pub fn build_encoded_vaa_account_from_vaa(vaa: Vec<u8>) -> Account {
pub fn build_encoded_vaa_account_from_vaa(vaa: Vaa<&RawMessage>) -> Account {
let encoded_vaa_data = (
<EncodedVaa as anchor_lang::Discriminator>::DISCRIMINATOR,
Header {
status: ProcessingStatus::Verified,
write_authority: Pubkey::new_unique(),
version: 1,
},
vaa,
serde_wormhole::to_vec(&vaa).unwrap(),
)
.try_to_vec()
.unwrap();
Expand Down Expand Up @@ -122,7 +124,7 @@ pub fn build_guardian_set_account() -> Account {
* - The program simulator, which is used to send transactions
* - The pubkeys of the encoded VAA accounts corresponding to the VAAs passed as argument, these accounts are prepopulated and can be used to test post_updates
*/
pub async fn setup_pyth_receiver(vaas: Vec<Vec<u8>>) -> ProgramTestFixtures {
pub async fn setup_pyth_receiver(vaas: Vec<Vaa<&RawMessage>>) -> ProgramTestFixtures {
let mut program_test = ProgramTest::default();
program_test.add_program("pyth_solana_receiver", ID, None);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async fn test_post_updates() {
let ProgramTestFixtures {
mut program_simulator,
encoded_vaa_addresses,
} = setup_pyth_receiver(vec![vaa]).await;
} = setup_pyth_receiver(vec![serde_wormhole::from_slice(&vaa).unwrap()]).await;

let poster = program_simulator.get_funded_keypair().await.unwrap();
let price_update_keypair = Keypair::new();
Expand Down

0 comments on commit 96d10c6

Please sign in to comment.