Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Aursen committed Sep 3, 2024
1 parent 421ea74 commit d95649f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion utils/src/pyth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl anchor_lang::AccountDeserialize for PriceUpdateV2 {
return Err(anchor_lang::error::ErrorCode::AccountDiscriminatorNotFound.into());
}
let given_disc = &buf[..8];
if &[34, 241, 35, 99, 157, 126, 244, 205] != given_disc {
if [34, 241, 35, 99, 157, 126, 244, 205] != given_disc {
return Err(anchor_lang::error::Error::from(
anchor_lang::error::AnchorError {
error_name: anchor_lang::error::ErrorCode::AccountDiscriminatorMismatch.name(),
Expand Down Expand Up @@ -165,3 +165,22 @@ pub fn get_oracle_key(shard_id: u16, feed_id: FeedId) -> Pubkey {
Pubkey::find_program_address(&[&shard_id.to_be_bytes(), &feed_id], &PYTH_PUSH_ORACLE_ID);
pubkey
}

#[cfg(test)]
mod tests {
use base64::Engine;

use super::*;

#[test]
fn test_price_update_v2() {
let data = base64::engine::general_purpose::STANDARD.decode("IvEjY51+9M1gMUcENA3t3zcf1CRyFI8kjp0abRpesqw6zYt/1dayQwHvDYtv2izrpB2hXUCV0do5Kg0vjtDGx7wPTPrIwoC1bdYkWB4DAAAAPA/bAAAAAAD4////rbTWZgAAAACttNZmAAAAAOx1oSEDAAAAtpvRAAAAAADMB0YTAAAAAAA=").unwrap();

let price_update = PriceUpdateV2::try_deserialize(&mut data.as_slice()).unwrap();

assert_eq!(
price_update.write_authority,
key!("7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE")
);
}
}

0 comments on commit d95649f

Please sign in to comment.