-
Notifications
You must be signed in to change notification settings - Fork 115
Move tests to rust #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move tests to rust #352
Conversation
a12ab92
to
cfb076b
Compare
// Try to update the publisher's price | ||
if is_component_update(cmd_args)? { | ||
let mut status: u32 = cmd_args.status; | ||
let mut threshold_conf = cmd_args.price / MAX_CI_DIVISOR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code gets refactored so I can use it in test_publish_batch.rs
.
@@ -64,7 +76,7 @@ use { | |||
/// this struct to test how pyth instructions execute in the Solana runtime. | |||
pub struct PythSimulator { | |||
program_id: Pubkey, | |||
banks_client: BanksClient, | |||
context: ProgramTestContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need this refactor to be able to advance the clock in the simulator
/// `payer` is used to pay for and sign the transaction. | ||
async fn process_ix( | ||
async fn process_ixs( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function got updated to support multiple instructions in the same transaction
@@ -0,0 +1,164 @@ | |||
use { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will replace test_update_price.py
@@ -0,0 +1,128 @@ | |||
use { | |||
crate::{ | |||
accounts::PriceAccount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will replace test_update_price.py
|
||
sim.warp_to_slot(2).await.unwrap(); | ||
|
||
let mut new_quotes: HashMap<String, Quote> = HashMap::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In test_update_price.py
, the second set of quotes are (1,1,"TRADING"). I changed the second set of quotes to be random here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool. i left you a very minor comment. feel free to merge this and rename that function in whatever your next pr is.
@@ -195,6 +199,25 @@ pub fn is_component_update(cmd_args: &UpdPriceArgs) -> Result<bool, OracleError> | |||
} | |||
} | |||
|
|||
// Return PC_STATUS_IGNORED if confidence is bigger than price divided by MAX_CI_DIVISOR else returns status | |||
pub fn check_confidence_too_big( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function name sounds like it's going to error if the confidence is too big. something more like get_status_for_update
would be better. (I don't love that name either, but the point being the name should indicate that this returns a status)
This PR aims to move the last python tests to rust.
I had to refactor parts of pyth_simulator.rs to support moving the clock and to support sending multiple instruction in one transaction.
The tests imitate what was happening in Python but with some extra assertions.
I will delete the python tests once this gets merged.