Skip to content

Commit

Permalink
feat(pyth-lazer-solana-contract): add test for alignment issue (#2298)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyvankhademi authored Jan 24, 2025
1 parent 70b3f35 commit 4e10ebe
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,49 @@ async fn test_basic() {
setup.verify_message(&message, treasury).await;
}

#[tokio::test]
async fn test_alignment() {
let mut setup = Setup::new().await;
let treasury = setup.create_treasury().await;

let mut transaction_init_contract = Transaction::new_with_payer(
&[Instruction::new_with_bytes(
pyth_lazer_solana_contract::ID,
&pyth_lazer_solana_contract::instruction::Initialize {
top_authority: setup.payer.pubkey(),
treasury,
}
.data(),
vec![
AccountMeta::new(setup.payer.pubkey(), true),
AccountMeta::new(pyth_lazer_solana_contract::STORAGE_ID, false),
AccountMeta::new_readonly(system_program::ID, false),
],
)],
Some(&setup.payer.pubkey()),
);
transaction_init_contract.sign(&[&setup.payer], setup.recent_blockhash);
setup
.banks_client
.process_transaction(transaction_init_contract)
.await
.unwrap();

let verifying_key =
hex::decode("f65210bee4fcf5b1cee1e537fabcfd95010297653b94af04d454fc473e94834f").unwrap();
let message = hex::decode(
"b9011a82d100f6ce88ef26fd5a74312b4bb19e18e74162ffbfe66a7204c6f7ee9085ad6b670ec96d167cfef\
ad437a1c79e67c75581c5cf99e64e680a1badeb3d88733d02f65210bee4fcf5b1cee1e537fabcfd950102976\
53b94af04d454fc473e94834f770075d3c79340d609f7652c06000303010000000400305680106309000002a\
023551b6309000001a62ab3056309000004f8ff02000000040021ae69754b00000002a04b8f764b000000018\
8b24b744b00000004f8ff060000000400377180d00500000002f2c19dd0050000000162c26ad00500000004f8ff",
)
.unwrap();

setup.set_trusted(verifying_key.try_into().unwrap()).await;
setup.verify_message(&message, treasury).await;
}

#[tokio::test]
async fn test_rejects_wrong_offset() {
let mut setup = Setup::new().await;
Expand Down

0 comments on commit 4e10ebe

Please sign in to comment.