@@ -246,18 +246,27 @@ impl Amm {
246246 initial_observation : oracle. initial_observation ,
247247 } ;
248248
249- require ! ( new_oracle. last_updated_slot > oracle. last_updated_slot, AmmError :: AssertFailed ) ;
249+ require ! (
250+ new_oracle. last_updated_slot > oracle. last_updated_slot,
251+ AmmError :: AssertFailed
252+ ) ;
250253 // assert that the new observation is between price and last observation
251254 match price. cmp ( & oracle. last_observation ) {
252255 Ordering :: Greater => {
253- require ! ( new_observation >= oracle. last_observation, AmmError :: AssertFailed ) ;
256+ require ! (
257+ new_observation >= oracle. last_observation,
258+ AmmError :: AssertFailed
259+ ) ;
254260 require ! ( new_observation <= price, AmmError :: AssertFailed ) ;
255261 }
256262 Ordering :: Equal => {
257263 require ! ( new_observation == price, AmmError :: AssertFailed ) ;
258264 }
259265 Ordering :: Less => {
260- require ! ( new_observation <= oracle. last_observation, AmmError :: AssertFailed ) ;
266+ require ! (
267+ new_observation <= oracle. last_observation,
268+ AmmError :: AssertFailed
269+ ) ;
261270 require ! ( new_observation >= price, AmmError :: AssertFailed ) ;
262271 }
263272 }
@@ -341,10 +350,13 @@ mod simple_amm_tests {
341350 } ;
342351
343352 // minute hasn't passed since last slot
344- assert_eq ! ( amm. update_twap( 1 ) , None ) ;
353+ assert_eq ! ( amm. update_twap( 1 ) , Err ( AmmError :: AssertFailed . into ( ) ) ) ;
345354 assert_eq ! ( amm. oracle. last_updated_slot, 0 ) ;
346355
347- assert_eq ! ( amm. update_twap( ONE_MINUTE_IN_SLOTS ) , Some ( 10 * PRICE_SCALE ) ) ;
356+ assert_eq ! (
357+ amm. update_twap( ONE_MINUTE_IN_SLOTS ) ,
358+ Ok ( Some ( 10 * PRICE_SCALE ) )
359+ ) ;
348360 }
349361
350362 #[ test]
@@ -360,15 +372,15 @@ mod simple_amm_tests {
360372
361373 let slots_until_overflow = u128:: MAX / ( u64:: MAX as u128 * PRICE_SCALE ) ;
362374
363- amm. update_twap ( slots_until_overflow as u64 ) ;
364- require ! ( amm. oracle. aggregator > MAX_PRICE * 18_400_000 ) ;
375+ let _ = amm. update_twap ( slots_until_overflow as u64 ) ;
376+ assert ! ( amm. oracle. aggregator > MAX_PRICE * 18_400_000 ) ;
365377 assert_ne ! ( amm. oracle. aggregator, u128 :: MAX ) ;
366378
367- amm_clone. update_twap ( slots_until_overflow as u64 + 1 ) ;
379+ let _ = amm_clone. update_twap ( slots_until_overflow as u64 + 1 ) ;
368380 assert_eq ! ( amm_clone. oracle. aggregator, u128 :: MAX ) ;
369381
370382 // check that it wraps over
371- amm_clone. update_twap ( slots_until_overflow as u64 + 1 + ONE_MINUTE_IN_SLOTS ) ;
383+ let _ = amm_clone. update_twap ( slots_until_overflow as u64 + 1 + ONE_MINUTE_IN_SLOTS ) ;
372384 assert_eq ! (
373385 amm_clone. oracle. aggregator,
374386 ONE_MINUTE_IN_SLOTS as u128 * MAX_PRICE - 1
0 commit comments