Skip to content

Commit d949c27

Browse files
committed
chore: add missing imports and fix warnings
1 parent 5d1b09d commit d949c27

File tree

4 files changed

+27
-66
lines changed

4 files changed

+27
-66
lines changed

program/rust/src/accounts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ mod product;
4343
#[cfg(feature = "strum")]
4444
pub use price::MessageType;
4545
#[cfg(test)]
46+
pub use price::PriceCumulative;
47+
#[cfg(test)]
4648
pub use product::{
4749
account_has_key_values,
4850
create_pc_str_t,
@@ -54,13 +56,11 @@ pub use {
5456
PriceAccount,
5557
PriceAccountFlags,
5658
PriceComponent,
57-
PriceCumulative,
5859
PriceEma,
5960
PriceInfo,
6061
PythOracleSerialize,
6162
},
6263
product::{
63-
read_pc_str_t,
6464
update_product_metadata,
6565
ProductAccount,
6666
},

program/rust/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ pub use accounts::{
3737
MappingAccount,
3838
PermissionAccount,
3939
PriceAccount,
40+
PriceAccountFlags,
4041
PriceComponent,
4142
PriceEma,
4243
PriceInfo,
4344
ProductAccount,
4445
PythAccount,
46+
PythOracleSerialize,
4547
};
4648
use {
4749
crate::error::OracleError,

program/rust/src/processor.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ mod upd_permissions;
2727
mod upd_price;
2828
mod upd_product;
2929

30+
#[cfg(test)]
31+
pub use add_publisher::{
32+
DISABLE_ACCUMULATOR_V2,
33+
ENABLE_ACCUMULATOR_V2,
34+
};
3035
pub use {
3136
add_price::add_price,
3237
add_product::add_product,
33-
add_publisher::{
34-
add_publisher,
35-
DISABLE_ACCUMULATOR_V2,
36-
ENABLE_ACCUMULATOR_V2,
37-
},
38+
add_publisher::add_publisher,
3839
del_price::del_price,
3940
del_product::del_product,
4041
del_publisher::del_publisher,

program/rust/src/tests/test_upd_price_with_validator.rs

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ use {
2424
update_clock_slot,
2525
AccountSetup,
2626
},
27-
validator::{
28-
self,
29-
},
27+
validator,
3028
},
3129
solana_program::{
3230
program_error::ProgramError,
@@ -122,22 +120,12 @@ fn test_upd_price_with_validator() {
122120
}
123121

124122
// We aggregate the price at the end of each slot now.
125-
validator::aggregate_price(
126-
1,
127-
101,
128-
price_account.key,
129-
&mut *price_account.data.borrow_mut(),
130-
)
131-
.unwrap();
123+
validator::aggregate_price(1, 101, price_account.key, *price_account.data.borrow_mut())
124+
.unwrap();
132125
update_clock_slot(&mut clock_account, 2);
133126

134-
validator::aggregate_price(
135-
2,
136-
102,
137-
price_account.key,
138-
&mut *price_account.data.borrow_mut(),
139-
)
140-
.unwrap();
127+
validator::aggregate_price(2, 102, price_account.key, *price_account.data.borrow_mut())
128+
.unwrap();
141129
update_clock_slot(&mut clock_account, 3);
142130
// add next price in new slot triggering snapshot and aggregate calc
143131
populate_instruction(&mut instruction_data, 81, 2, 2);
@@ -168,13 +156,8 @@ fn test_upd_price_with_validator() {
168156

169157
// next price doesn't change but slot does
170158
populate_instruction(&mut instruction_data, 81, 2, 3);
171-
validator::aggregate_price(
172-
3,
173-
103,
174-
price_account.key,
175-
&mut *price_account.data.borrow_mut(),
176-
)
177-
.unwrap();
159+
validator::aggregate_price(3, 103, price_account.key, *price_account.data.borrow_mut())
160+
.unwrap();
178161
update_clock_slot(&mut clock_account, 4);
179162
assert!(process_instruction(
180163
&program_id,
@@ -201,13 +184,8 @@ fn test_upd_price_with_validator() {
201184

202185
// next price doesn't change and neither does aggregate but slot does
203186
populate_instruction(&mut instruction_data, 81, 2, 4);
204-
validator::aggregate_price(
205-
4,
206-
104,
207-
price_account.key,
208-
&mut *price_account.data.borrow_mut(),
209-
)
210-
.unwrap();
187+
validator::aggregate_price(4, 104, price_account.key, *price_account.data.borrow_mut())
188+
.unwrap();
211189
update_clock_slot(&mut clock_account, 5);
212190

213191
assert!(process_instruction(
@@ -263,13 +241,8 @@ fn test_upd_price_with_validator() {
263241
}
264242

265243
populate_instruction(&mut instruction_data, 50, 20, 5);
266-
validator::aggregate_price(
267-
5,
268-
105,
269-
price_account.key,
270-
&mut *price_account.data.borrow_mut(),
271-
)
272-
.unwrap();
244+
validator::aggregate_price(5, 105, price_account.key, *price_account.data.borrow_mut())
245+
.unwrap();
273246
update_clock_slot(&mut clock_account, 6);
274247

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

309-
validator::aggregate_price(
310-
6,
311-
106,
312-
price_account.key,
313-
&mut *price_account.data.borrow_mut(),
314-
)
315-
.unwrap();
282+
validator::aggregate_price(6, 106, price_account.key, *price_account.data.borrow_mut())
283+
.unwrap();
316284
update_clock_slot(&mut clock_account, 7);
317285

318286

@@ -341,13 +309,8 @@ fn test_upd_price_with_validator() {
341309

342310
// Negative prices are accepted
343311
populate_instruction(&mut instruction_data, -100, 1, 7);
344-
validator::aggregate_price(
345-
7,
346-
107,
347-
price_account.key,
348-
&mut *price_account.data.borrow_mut(),
349-
)
350-
.unwrap();
312+
validator::aggregate_price(7, 107, price_account.key, *price_account.data.borrow_mut())
313+
.unwrap();
351314
update_clock_slot(&mut clock_account, 8);
352315

353316

@@ -376,13 +339,8 @@ fn test_upd_price_with_validator() {
376339

377340
// Crank again for aggregate
378341
populate_instruction(&mut instruction_data, -100, 1, 8);
379-
validator::aggregate_price(
380-
8,
381-
108,
382-
price_account.key,
383-
&mut *price_account.data.borrow_mut(),
384-
)
385-
.unwrap();
342+
validator::aggregate_price(8, 108, price_account.key, *price_account.data.borrow_mut())
343+
.unwrap();
386344
update_clock_slot(&mut clock_account, 9);
387345

388346

0 commit comments

Comments
 (0)