Skip to content

Commit ee9a478

Browse files
committed
Merge branch 'accumulator-v2' into feat/publisher-caps
2 parents fe64764 + d949c27 commit ee9a478

File tree

4 files changed

+27
-64
lines changed

4 files changed

+27
-64
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 & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use {
2424
update_clock_slot,
2525
AccountSetup,
2626
},
27-
validator::{self,},
27+
validator,
2828
},
2929
solana_program::{
3030
program_error::ProgramError,
@@ -120,22 +120,12 @@ fn test_upd_price_with_validator() {
120120
}
121121

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

132-
validator::aggregate_price(
133-
2,
134-
102,
135-
price_account.key,
136-
&mut *price_account.data.borrow_mut(),
137-
)
138-
.unwrap();
127+
validator::aggregate_price(2, 102, price_account.key, *price_account.data.borrow_mut())
128+
.unwrap();
139129
update_clock_slot(&mut clock_account, 3);
140130
// add next price in new slot triggering snapshot and aggregate calc
141131
populate_instruction(&mut instruction_data, 81, 2, 2);
@@ -166,13 +156,8 @@ fn test_upd_price_with_validator() {
166156

167157
// next price doesn't change but slot does
168158
populate_instruction(&mut instruction_data, 81, 2, 3);
169-
validator::aggregate_price(
170-
3,
171-
103,
172-
price_account.key,
173-
&mut *price_account.data.borrow_mut(),
174-
)
175-
.unwrap();
159+
validator::aggregate_price(3, 103, price_account.key, *price_account.data.borrow_mut())
160+
.unwrap();
176161
update_clock_slot(&mut clock_account, 4);
177162
assert!(process_instruction(
178163
&program_id,
@@ -199,13 +184,8 @@ fn test_upd_price_with_validator() {
199184

200185
// next price doesn't change and neither does aggregate but slot does
201186
populate_instruction(&mut instruction_data, 81, 2, 4);
202-
validator::aggregate_price(
203-
4,
204-
104,
205-
price_account.key,
206-
&mut *price_account.data.borrow_mut(),
207-
)
208-
.unwrap();
187+
validator::aggregate_price(4, 104, price_account.key, *price_account.data.borrow_mut())
188+
.unwrap();
209189
update_clock_slot(&mut clock_account, 5);
210190

211191
assert!(process_instruction(
@@ -261,13 +241,8 @@ fn test_upd_price_with_validator() {
261241
}
262242

263243
populate_instruction(&mut instruction_data, 50, 20, 5);
264-
validator::aggregate_price(
265-
5,
266-
105,
267-
price_account.key,
268-
&mut *price_account.data.borrow_mut(),
269-
)
270-
.unwrap();
244+
validator::aggregate_price(5, 105, price_account.key, *price_account.data.borrow_mut())
245+
.unwrap();
271246
update_clock_slot(&mut clock_account, 6);
272247

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

307-
validator::aggregate_price(
308-
6,
309-
106,
310-
price_account.key,
311-
&mut *price_account.data.borrow_mut(),
312-
)
313-
.unwrap();
282+
validator::aggregate_price(6, 106, price_account.key, *price_account.data.borrow_mut())
283+
.unwrap();
314284
update_clock_slot(&mut clock_account, 7);
315285

316286

@@ -339,13 +309,8 @@ fn test_upd_price_with_validator() {
339309

340310
// Negative prices are accepted
341311
populate_instruction(&mut instruction_data, -100, 1, 7);
342-
validator::aggregate_price(
343-
7,
344-
107,
345-
price_account.key,
346-
&mut *price_account.data.borrow_mut(),
347-
)
348-
.unwrap();
312+
validator::aggregate_price(7, 107, price_account.key, *price_account.data.borrow_mut())
313+
.unwrap();
349314
update_clock_slot(&mut clock_account, 8);
350315

351316

@@ -374,13 +339,8 @@ fn test_upd_price_with_validator() {
374339

375340
// Crank again for aggregate
376341
populate_instruction(&mut instruction_data, -100, 1, 8);
377-
validator::aggregate_price(
378-
8,
379-
108,
380-
price_account.key,
381-
&mut *price_account.data.borrow_mut(),
382-
)
383-
.unwrap();
342+
validator::aggregate_price(8, 108, price_account.key, *price_account.data.borrow_mut())
343+
.unwrap();
384344
update_clock_slot(&mut clock_account, 9);
385345

386346

0 commit comments

Comments
 (0)