Skip to content

Commit

Permalink
Change trim signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos committed Jan 30, 2024
1 parent e589550 commit 3bee847
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions pythnet/pythnet_sdk/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ pub fn create_vaa_from_payload(
(header, body).into()
}

pub fn trim_vaa_signatures(vaa: Vec<u8>, n: u8) -> Vec<u8> {
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3bee847

Please sign in to comment.