Skip to content

Commit 9d1b2ec

Browse files
authored
Gate sma with test flag (#295)
* Gate sma with test flag * Restore current gating
1 parent 7ee7bfb commit 9d1b2ec

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

program/rust/src/rust_oracle.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,16 @@ pub fn resize_price_account(
127127

128128
// Check that everything is ok
129129
check_valid_signable_account(program_id, price_account_info)?;
130-
let mut price_account =
131-
load_checked::<PriceAccountWrapper>(price_account_info, PC_VERSION)?;
132-
// Initialize Time Machine
133-
price_account.initialize_time_machine()?;
130+
131+
#[cfg(test)]
132+
// Sma feature disabled except in tests
133+
{
134+
let mut price_account =
135+
load_checked::<PriceAccountWrapper>(price_account_info, PC_VERSION)?;
136+
// Initialize Time Machine
137+
price_account.initialize_time_machine()?;
138+
}
139+
134140
Ok(())
135141
}
136142
PriceAccountWrapper::MINIMUM_SIZE => Ok(()),
@@ -251,8 +257,10 @@ pub fn upd_price(
251257
}
252258

253259
// Try to update the aggregate
260+
#[allow(unused_variables)]
254261
let mut aggregate_updated = false;
255262
if clock.slot > latest_aggregate_price.pub_slot_ {
263+
#[allow(unused_assignments)]
256264
unsafe {
257265
aggregate_updated = c_upd_aggregate(
258266
price_account.try_borrow_mut_data()?.as_mut_ptr(),
@@ -262,11 +270,15 @@ pub fn upd_price(
262270
}
263271
}
264272

265-
let account_len = price_account.try_data_len()?;
266-
if aggregate_updated && account_len == PriceAccountWrapper::MINIMUM_SIZE {
267-
let mut price_account =
268-
load_checked::<PriceAccountWrapper>(price_account, cmd_args.header.version)?;
269-
price_account.add_price_to_time_machine()?;
273+
#[cfg(test)]
274+
// Sma feature disabled in production for now
275+
{
276+
let account_len = price_account.try_data_len()?;
277+
if aggregate_updated && account_len == PriceAccountWrapper::MINIMUM_SIZE {
278+
let mut price_account =
279+
load_checked::<PriceAccountWrapper>(price_account, cmd_args.header.version)?;
280+
price_account.add_price_to_time_machine()?;
281+
}
270282
}
271283

272284
// Try to update the publisher's price

0 commit comments

Comments
 (0)