Skip to content

Commit 8043020

Browse files
committed
fix: add bad stake parameters
1 parent 4977752 commit 8043020

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

runtime/src/bank/pyth_accumulator_tests.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,9 @@ fn test_publisher_stake_caps() {
10041004
publishers_with_expected_caps[2].0,
10051005
],
10061006
),
1007+
generate_price(&bank, b"seeds_5", false, &[]),
1008+
1009+
10071010
];
10081011

10091012
// Publishers are sorted in the publisher stake caps message so we sort them here too
@@ -1019,7 +1022,7 @@ fn test_publisher_stake_caps() {
10191022
.sorted_unstable()
10201023
.dedup()
10211024
.collect::<Vec<_>>();
1022-
assert_eq!(messages.len(), 8);
1025+
assert_eq!(messages.len(), 10);
10231026

10241027
// We turn on the feature to add publisher stake caps to the accumulator but it won't be active until next epoch
10251028
activate_feature(
@@ -1054,7 +1057,7 @@ fn test_publisher_stake_caps() {
10541057

10551058
// Now the messages contain the publisher caps message
10561059
messages.push(&publisher_caps_message);
1057-
assert_eq!(messages.len(), 9);
1060+
assert_eq!(messages.len(), 11);
10581061

10591062
let sequence_tracker_before_bank_freeze = get_acc_sequence_tracker(&bank);
10601063
bank.freeze();
@@ -1066,6 +1069,24 @@ fn test_publisher_stake_caps() {
10661069

10671070
bank = new_from_parent(&Arc::new(bank));
10681071

1072+
// We add some badly formatted stake cap parameters
1073+
let mut stake_cap_parameters_account =
1074+
AccountSharedData::new(42, size_of::<StakeCapParameters>(), &ORACLE_PID);
1075+
stake_cap_parameters_account.set_data(
1076+
vec![1,2,3,4],
1077+
);
1078+
bank.store_account(&STAKE_CAPS_PARAMETERS_ADDR, &stake_cap_parameters_account);
1079+
1080+
// Nothing should change as the stake cap parameters are invalid
1081+
let sequence_tracker_before_bank_freeze = get_acc_sequence_tracker(&bank);
1082+
bank.freeze();
1083+
check_accumulator_state_matches_messages(
1084+
&bank,
1085+
&sequence_tracker_before_bank_freeze,
1086+
&messages,
1087+
);
1088+
bank = new_from_parent(&Arc::new(bank));
1089+
10691090
// Now we update the stake cap parameters
10701091
let mut stake_cap_parameters_account =
10711092
AccountSharedData::new(42, size_of::<StakeCapParameters>(), &ORACLE_PID);
@@ -1095,7 +1116,7 @@ fn test_publisher_stake_caps() {
10951116
// Update the publisher caps message in the message arrays to match the new parameters
10961117
let last_element_index = messages.len() - 1;
10971118
messages[last_element_index] = &publisher_caps_message_with_new_parameters;
1098-
assert_eq!(messages.len(), 9);
1119+
assert_eq!(messages.len(), 11);
10991120

11001121
let sequence_tracker_before_bank_freeze = get_acc_sequence_tracker(&bank);
11011122
bank.freeze();

0 commit comments

Comments
 (0)