This repository has been archived by the owner on Jun 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/add price slot check (In on-chain programs) (#16)
Adds `get_current_price_status` to Price struct which returns the current price status. If run on-chain with the current slot it checks whether price information has got stale or not. `get_current_price` uses this function to make the interface consistent. Additional changes: - Moves `test_instr` for testing to `common.rs` (as it's used in the test for this feature) and renamed it to `test_instr_exex_ok` to be more clear. - Adds Borsh SerDe traits to PriceStatus as it is used for testing instructions. - Makes Ema fields public. It was required for creating testing Price object.
- Loading branch information
1 parent
961c49a
commit 210087a
Showing
8 changed files
with
200 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use { | ||
pyth_client::id, | ||
pyth_client::processor::process_instruction, | ||
solana_program::instruction::Instruction, | ||
solana_program_test::*, | ||
solana_sdk::{signature::Signer, transaction::Transaction}, | ||
}; | ||
|
||
// Panics if running instruction fails | ||
pub async fn test_instr_exec_ok(instr: Instruction) { | ||
let (mut banks_client, payer, recent_blockhash) = ProgramTest::new( | ||
"pyth_client", | ||
id(), | ||
processor!(process_instruction), | ||
) | ||
.start() | ||
.await; | ||
let mut transaction = Transaction::new_with_payer( | ||
&[instr], | ||
Some(&payer.pubkey()), | ||
); | ||
transaction.sign(&[&payer], recent_blockhash); | ||
banks_client.process_transaction(transaction).await.unwrap() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.