Fix device ID construction in cross-version tests

This commit is contained in:
Alex Bakon
2025-06-13 17:24:01 -04:00
committed by GitHub
parent ba87b882ce
commit 3157a9be55
4 changed files with 13 additions and 7 deletions

View File

@@ -10,7 +10,7 @@ use libsignal_protocol_current::*;
use rand::{rng, Rng};
fn address(id: &str) -> ProtocolAddress {
ProtocolAddress::new(id.into(), 1.into())
ProtocolAddress::new(id.into(), DeviceId::new(1).unwrap())
}
pub struct LibSignalProtocolCurrent(InMemSignalProtocolStore);
@@ -58,7 +58,7 @@ impl super::LibSignalProtocolStore for LibSignalProtocolCurrent {
.calculate_signature(&signed_pq_pre_key_public, &mut csprng)
.expect("can sign");
let device_id: u32 = csprng.random();
let device_id: DeviceId = csprng.random();
let pre_key_id: u32 = csprng.random();
let signed_pre_key_id: u32 = csprng.random();
let kyber_pre_key_id: u32 = csprng.random();
@@ -69,7 +69,7 @@ impl super::LibSignalProtocolStore for LibSignalProtocolCurrent {
.now_or_never()
.expect("synchronous")
.expect("can fetch registration id"),
device_id.into(),
device_id,
Some((pre_key_id.into(), pre_key_pair.public_key)),
signed_pre_key_id.into(),
signed_pre_key_pair.public_key,

View File

@@ -58,7 +58,7 @@ impl super::LibSignalProtocolStore for LibSignalProtocolV70 {
.calculate_signature(&signed_pq_pre_key_public, &mut csprng)
.expect("can sign");
let device_id: u32 = csprng.gen();
let device_id: u32 = csprng.gen_range(1..=127);
let pre_key_id: u32 = csprng.gen();
let signed_pre_key_id: u32 = csprng.gen();
let kyber_pre_key_id: u32 = csprng.gen();
@@ -69,7 +69,7 @@ impl super::LibSignalProtocolStore for LibSignalProtocolV70 {
.now_or_never()
.expect("synchronous")
.expect("can fetch registration id"),
device_id.into(),
device_id.try_into().unwrap(),
Some((pre_key_id.into(), pre_key_pair.public_key.into_current())),
signed_pre_key_id.into(),
signed_pre_key_pair.public_key.into_current(),
@@ -264,7 +264,7 @@ macro_rules! impl_convert_version {
u32::from(current).into()
}
fn into_current(self) -> Self::Current {
u32::from(self).into()
u32::from(self).try_into().expect("valid range")
}
}
};