Skip to content

Commit

Permalink
chore: add missing imports and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Riateche committed Jul 19, 2024
1 parent 5d1b09d commit d949c27
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 66 deletions.
4 changes: 2 additions & 2 deletions program/rust/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ mod product;
#[cfg(feature = "strum")]
pub use price::MessageType;
#[cfg(test)]
pub use price::PriceCumulative;
#[cfg(test)]
pub use product::{
account_has_key_values,
create_pc_str_t,
Expand All @@ -54,13 +56,11 @@ pub use {
PriceAccount,
PriceAccountFlags,
PriceComponent,
PriceCumulative,
PriceEma,
PriceInfo,
PythOracleSerialize,
},
product::{
read_pc_str_t,
update_product_metadata,
ProductAccount,
},
Expand Down
2 changes: 2 additions & 0 deletions program/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ pub use accounts::{
MappingAccount,
PermissionAccount,
PriceAccount,
PriceAccountFlags,
PriceComponent,
PriceEma,
PriceInfo,
ProductAccount,
PythAccount,
PythOracleSerialize,
};
use {
crate::error::OracleError,
Expand Down
11 changes: 6 additions & 5 deletions program/rust/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ mod upd_permissions;
mod upd_price;
mod upd_product;

#[cfg(test)]
pub use add_publisher::{
DISABLE_ACCUMULATOR_V2,
ENABLE_ACCUMULATOR_V2,
};
pub use {
add_price::add_price,
add_product::add_product,
add_publisher::{
add_publisher,
DISABLE_ACCUMULATOR_V2,
ENABLE_ACCUMULATOR_V2,
},
add_publisher::add_publisher,
del_price::del_price,
del_product::del_product,
del_publisher::del_publisher,
Expand Down
76 changes: 17 additions & 59 deletions program/rust/src/tests/test_upd_price_with_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ use {
update_clock_slot,
AccountSetup,
},
validator::{
self,
},
validator,
},
solana_program::{
program_error::ProgramError,
Expand Down Expand Up @@ -122,22 +120,12 @@ fn test_upd_price_with_validator() {
}

// We aggregate the price at the end of each slot now.
validator::aggregate_price(
1,
101,
price_account.key,
&mut *price_account.data.borrow_mut(),
)
.unwrap();
validator::aggregate_price(1, 101, price_account.key, *price_account.data.borrow_mut())
.unwrap();
update_clock_slot(&mut clock_account, 2);

validator::aggregate_price(
2,
102,
price_account.key,
&mut *price_account.data.borrow_mut(),
)
.unwrap();
validator::aggregate_price(2, 102, price_account.key, *price_account.data.borrow_mut())
.unwrap();
update_clock_slot(&mut clock_account, 3);
// add next price in new slot triggering snapshot and aggregate calc
populate_instruction(&mut instruction_data, 81, 2, 2);
Expand Down Expand Up @@ -168,13 +156,8 @@ fn test_upd_price_with_validator() {

// next price doesn't change but slot does
populate_instruction(&mut instruction_data, 81, 2, 3);
validator::aggregate_price(
3,
103,
price_account.key,
&mut *price_account.data.borrow_mut(),
)
.unwrap();
validator::aggregate_price(3, 103, price_account.key, *price_account.data.borrow_mut())
.unwrap();
update_clock_slot(&mut clock_account, 4);
assert!(process_instruction(
&program_id,
Expand All @@ -201,13 +184,8 @@ fn test_upd_price_with_validator() {

// next price doesn't change and neither does aggregate but slot does
populate_instruction(&mut instruction_data, 81, 2, 4);
validator::aggregate_price(
4,
104,
price_account.key,
&mut *price_account.data.borrow_mut(),
)
.unwrap();
validator::aggregate_price(4, 104, price_account.key, *price_account.data.borrow_mut())
.unwrap();
update_clock_slot(&mut clock_account, 5);

assert!(process_instruction(
Expand Down Expand Up @@ -263,13 +241,8 @@ fn test_upd_price_with_validator() {
}

populate_instruction(&mut instruction_data, 50, 20, 5);
validator::aggregate_price(
5,
105,
price_account.key,
&mut *price_account.data.borrow_mut(),
)
.unwrap();
validator::aggregate_price(5, 105, price_account.key, *price_account.data.borrow_mut())
.unwrap();
update_clock_slot(&mut clock_account, 6);

// Publishing a wide CI results in a status of unknown.
Expand Down Expand Up @@ -306,13 +279,8 @@ fn test_upd_price_with_validator() {
// Crank one more time and aggregate should be unknown
populate_instruction(&mut instruction_data, 50, 20, 6);

validator::aggregate_price(
6,
106,
price_account.key,
&mut *price_account.data.borrow_mut(),
)
.unwrap();
validator::aggregate_price(6, 106, price_account.key, *price_account.data.borrow_mut())
.unwrap();
update_clock_slot(&mut clock_account, 7);


Expand Down Expand Up @@ -341,13 +309,8 @@ fn test_upd_price_with_validator() {

// Negative prices are accepted
populate_instruction(&mut instruction_data, -100, 1, 7);
validator::aggregate_price(
7,
107,
price_account.key,
&mut *price_account.data.borrow_mut(),
)
.unwrap();
validator::aggregate_price(7, 107, price_account.key, *price_account.data.borrow_mut())
.unwrap();
update_clock_slot(&mut clock_account, 8);


Expand Down Expand Up @@ -376,13 +339,8 @@ fn test_upd_price_with_validator() {

// Crank again for aggregate
populate_instruction(&mut instruction_data, -100, 1, 8);
validator::aggregate_price(
8,
108,
price_account.key,
&mut *price_account.data.borrow_mut(),
)
.unwrap();
validator::aggregate_price(8, 108, price_account.key, *price_account.data.borrow_mut())
.unwrap();
update_clock_slot(&mut clock_account, 9);


Expand Down

0 comments on commit d949c27

Please sign in to comment.