Skip to content

Commit 9c3a9a7

Browse files
committed
add asserts
1 parent 0d404c3 commit 9c3a9a7

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

program/rust/src/tests/test_upd_price.rs

+29-1
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,34 @@ fn test_upd_price() {
485485
)
486486
.is_ok());
487487

488+
{
489+
let price_data = load_checked::<PriceAccount>(&price_account, PC_VERSION).unwrap();
490+
assert_eq!(price_data.comp_[0].latest_.price_, 10);
491+
assert_eq!(price_data.comp_[0].latest_.conf_, 1);
492+
assert_eq!(price_data.comp_[0].latest_.pub_slot_, 100);
493+
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_TRADING);
494+
assert_eq!(price_data.valid_slot_, 50);
495+
assert_eq!(price_data.agg_.pub_slot_, 100);
496+
assert_eq!(price_data.agg_.price_, 10);
497+
assert_eq!(price_data.agg_.conf_, 1);
498+
assert_eq!(price_data.agg_.status_, PC_STATUS_TRADING);
499+
assert_eq!(price_data.prev_slot_, 50);
500+
assert_eq!(price_data.prev_price_, 60);
501+
assert_eq!(price_data.prev_conf_, 4);
502+
assert_eq!(
503+
price_data.prev_price_cumulative.price,
504+
42 + 81 * 4 - 100 * 3 + 10 * 2 + 60 * 40
505+
);
506+
assert_eq!(price_data.prev_price_cumulative.conf, 2 * 5 + 5 + 40 * 4);
507+
assert_eq!(price_data.prev_price_cumulative.num_down_slots, 15);
508+
assert_eq!(
509+
price_data.price_cumulative.price,
510+
42 + 81 * 4 - 100 * 3 + 10 * 2 + 60 * 40 + 10 * 50
511+
); // (42 + 81 * 4 - 100 * 3 + 10 * 2 + 60 * 40) is the price cumulative from the previous test and 10 * 50 (slot_gap) is the price cumulative from this test
512+
assert_eq!(price_data.price_cumulative.conf, 2 * 5 + 5 + 40 * 4 + 50);
513+
assert_eq!(price_data.price_cumulative.num_down_slots, 40); // prev num_down_slots was 15 and since pub slot is 100 and last pub slot was 50, slot_gap is 50 and default latency is 25, so num_down_slots = 50 - 25 = 25, so total num_down_slots = 15 + 25 = 40
514+
}
515+
488516
populate_instruction(&mut instruction_data, 20, 2, 100);
489517
assert!(process_instruction(
490518
&program_id,
@@ -524,7 +552,7 @@ fn test_upd_price() {
524552
assert_eq!(
525553
price_data.price_cumulative.price,
526554
42 + 81 * 4 - 100 * 3 + 10 * 2 + 60 * 40 + 14 * 50
527-
); // (42 + 81 * 4 - 100 * 3 + 10 * 2 + 60 * 40 + 55) is the price cumulative from the previous test and 14 * 49 (slot_gap) is the price cumulative from this test
555+
); // (42 + 81 * 4 - 100 * 3 + 10 * 2 + 60 * 40) is the price cumulative from the previous test and 14 * 50 (slot_gap) is the price cumulative from this test
528556
assert_eq!(
529557
price_data.price_cumulative.conf,
530558
2 * 5 + 5 + 40 * 4 + 6 * 50

0 commit comments

Comments
 (0)