Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions sdk/bittensor-core/src/timelock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,21 +378,19 @@ mod tests {

#[test]
fn inner_ciphertext_unwraps_user_data_envelope() {
let message = b"chain submit bytes";
let reveal_round = 30_000_000;
let (envelope, round) =
encrypt_at_round(message, reveal_round).expect("Encryption should succeed");
assert_eq!(round, reveal_round);

let inner = inner_ciphertext(&envelope).expect("envelope should unwrap");
assert_ne!(inner, envelope);
assert!(inner.len() < envelope.len());

let mut envelope_with_trailing_data = envelope;
envelope_with_trailing_data.push(0);
let expected = b"chain submit bytes".to_vec();
let mut envelope = UserData {
encrypted_data: expected.clone(),
reveal_round: 30_000_000,
}
.encode();

assert_eq!(inner_ciphertext(&envelope).unwrap(), expected);

envelope.push(0);
assert!(
inner_ciphertext(&envelope_with_trailing_data).is_err(),
"a UserData envelope must consume all input bytes"
inner_ciphertext(&envelope).is_err(),
"trailing bytes must be rejected"
);
}

Expand Down
Loading