diff --git a/pythnet/pythnet_sdk/src/test_utils/mod.rs b/pythnet/pythnet_sdk/src/test_utils/mod.rs index bc603c8014..bdd3383894 100644 --- a/pythnet/pythnet_sdk/src/test_utils/mod.rs +++ b/pythnet/pythnet_sdk/src/test_utils/mod.rs @@ -228,13 +228,13 @@ pub fn create_vaa_from_payload( (header, body).into() } -pub fn trim_vaa_signatures(vaa: Vec, n: u8) -> Vec { - let mut parsed_vaa: Vaa<&RawMessage> = serde_wormhole::from_slice(vaa.as_slice()).unwrap(); - parsed_vaa.signatures = parsed_vaa +pub fn trim_vaa_signatures(vaa: Vaa<&RawMessage>, n: u8) -> Vaa<&RawMessage> { + let mut vaa_copy = vaa.clone(); + vaa_copy.signatures = vaa .signatures .choose_multiple(&mut thread_rng(), n.into()) .cloned() .collect(); - parsed_vaa.signatures.sort_by(|a, b| a.index.cmp(&b.index)); - serde_wormhole::to_vec(&parsed_vaa).unwrap() + vaa_copy.signatures.sort_by(|a, b| a.index.cmp(&b.index)); + vaa_copy } diff --git a/target_chains/solana/programs/pyth-solana-receiver/tests/test_post_updates_atomic.rs b/target_chains/solana/programs/pyth-solana-receiver/tests/test_post_updates_atomic.rs index 7b8ba3085b..972692ffe4 100644 --- a/target_chains/solana/programs/pyth-solana-receiver/tests/test_post_updates_atomic.rs +++ b/target_chains/solana/programs/pyth-solana-receiver/tests/test_post_updates_atomic.rs @@ -36,8 +36,11 @@ async fn test_post_updates_atomic() { let feed_2 = create_dummy_price_feed_message(200); let message = create_accumulator_message(&[feed_1, feed_2], &[feed_1, feed_2], false); let (vaa, merkle_price_updates) = deserialize_accumulator_update_data(message).unwrap(); - - let vaa = trim_vaa_signatures(vaa, 5); + let vaa = serde_wormhole::to_vec(&trim_vaa_signatures( + serde_wormhole::from_slice(&vaa).unwrap(), + 5, + )) + .unwrap(); let ProgramTestFixtures { mut program_simulator,