Skip to content

Commit

Permalink
add at max tests
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Feb 26, 2025
1 parent 709f719 commit e09372d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions anchor/common/ssv_types/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,24 @@ mod tests {
}
}

/// Checks that having exactly MAX_SIGNATURES operator IDs doesn't triggers `TooManyOperatorIDs`.
#[test]
fn test_signed_ssv_message_max_operator_ids() {
let ssv_msg = valid_ssv_message();
// create MAX_SIGNATURES distinct operator IDs
let ops = (1..=MAX_SIGNATURES)
.map(|id| OperatorId(id as u64))
.collect();
let sigs = vec![valid_signature(); MAX_SIGNATURES];

let result = SignedSSVMessage::new(sigs, ops, ssv_msg, vec![]);

match result {
Ok(_) => (),
other => panic!("Expected Ok(_), got {:?}", other),
}
}

/// Checks that `full_data` exceeding the limit triggers `FullDataTooLong`.
#[test]
fn test_signed_ssv_message_full_data_too_long() {
Expand All @@ -735,6 +753,21 @@ mod tests {
}
}

#[test]
fn test_signed_ssv_message_full_data_max_length() {
let ssv_msg = valid_ssv_message();
let full_data = vec![0u8; MAX_FULL_DATA_SIZE];
let sigs = vec![valid_signature()];
let operator_ids = vec![OperatorId(1)];

let signed_msg = SignedSSVMessage::new(sigs, operator_ids, ssv_msg, full_data.clone());

match signed_msg {
Ok(msg) => assert_eq!(msg.full_data(), &full_data),
other => panic!("Expected SignedSSVMessage, got {:?}", other),
}
}

/// Checks that providing zero operator IDs triggers `NoSigners`.
#[test]
fn test_signed_ssv_message_no_signers() {
Expand Down

0 comments on commit e09372d

Please sign in to comment.