mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-26 09:45:16 +02:00
cross-version: Move some helpers into the library proper
...in preparation for more tests that are otherwise independent.
This commit is contained in:
@@ -5,50 +5,6 @@
|
||||
|
||||
use libsignal_protocol_cross_version_testing::*;
|
||||
|
||||
// Use this function to debug tests
|
||||
#[allow(dead_code)]
|
||||
fn init_logger() {
|
||||
let _ = env_logger::builder()
|
||||
.filter_level(log::LevelFilter::max())
|
||||
.is_test(true)
|
||||
.try_init();
|
||||
}
|
||||
|
||||
fn try_all_combinations(
|
||||
f: fn(&mut dyn LibSignalProtocolStore, &mut dyn LibSignalProtocolStore),
|
||||
make_previous: &[fn() -> Box<dyn LibSignalProtocolStore>],
|
||||
) {
|
||||
let run = |alice_store: &mut dyn LibSignalProtocolStore,
|
||||
bob_store: &mut dyn LibSignalProtocolStore| {
|
||||
log::info!(
|
||||
"alice: {}, bob: {}",
|
||||
alice_store.version(),
|
||||
bob_store.version()
|
||||
);
|
||||
f(alice_store, bob_store)
|
||||
};
|
||||
|
||||
// Current<->Current, to test that the test is correct.
|
||||
run(
|
||||
&mut LibSignalProtocolCurrent::new(),
|
||||
&mut LibSignalProtocolCurrent::new(),
|
||||
);
|
||||
|
||||
// Current<->Previous
|
||||
for bob_store_maker in make_previous {
|
||||
let mut alice_store = LibSignalProtocolCurrent::new();
|
||||
let mut bob_store = bob_store_maker();
|
||||
run(&mut alice_store, &mut *bob_store);
|
||||
}
|
||||
|
||||
// Previous<->Current
|
||||
for alice_store_maker in make_previous {
|
||||
let mut alice_store = alice_store_maker();
|
||||
let mut bob_store = LibSignalProtocolCurrent::new();
|
||||
run(&mut *alice_store, &mut bob_store);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_basic_prekey() {
|
||||
try_all_combinations(
|
||||
|
||||
Reference in New Issue
Block a user