From dba577f39c489b9db29960f2bf5cc78ac4f29d7b Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 4 Oct 2026 14:42:16 +0200 Subject: Move OMEMO, OpenPGP and RTP plugins into main/libdino --- libdino/tests/common.vala | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'libdino/tests/common.vala') diff --git a/libdino/tests/common.vala b/libdino/tests/common.vala index 2a0b189b..d443e214 100644 --- a/libdino/tests/common.vala +++ b/libdino/tests/common.vala @@ -3,10 +3,35 @@ namespace Dino.Test { int main(string[] args) { GLib.Test.init(ref args); GLib.Test.set_nonfatal_assertions(); - TestSuite.get_root().add_suite(new WeakMapTest().get_suite()); + TestSuite.get_root().add_suite(new Curve25519().get_suite()); + TestSuite.get_root().add_suite(new SessionBuilderTest().get_suite()); + TestSuite.get_root().add_suite(new HKDF().get_suite()); return GLib.Test.run(); } +Dino.Crypto.Omemo.Store setup_test_store_context(Dino.Crypto.Omemo.Context global_context) { + Dino.Crypto.Omemo.Store store = global_context.create_store(); + try { + store.identity_key_store.local_registration_id = (Random.next_int() % 16380) + 1; + + Omemo.ECKeyPair key_pair = global_context.generate_key_pair(); + store.identity_key_store.identity_key_private = new Bytes(key_pair.private.serialize()); + store.identity_key_store.identity_key_public = new Bytes(key_pair.public.serialize()); + } catch (Error e) { + fail_if_reached(); + } + return store; +} + +Omemo.ECPublicKey? create_test_ec_public_key(Dino.Crypto.Omemo.Context context) { + try { + return context.generate_key_pair().public; + } catch (Error e) { + fail_if_reached(); + return null; + } +} + bool fail_if(bool exp, string? reason = null) { if (exp) { if (reason != null) GLib.Test.message(reason); @@ -27,7 +52,7 @@ void fail_if_not_error_code(ErrorFunc func, int expectedCode, string? reason = n func(); fail_if_reached(@"$(reason + ": " ?? "")no error thrown"); } catch (Error e) { - fail_if_not_eq_int(e.code, expectedCode, @"$(reason + ": " ?? "")catched unexpected error"); + fail_if_not_eq_int(e.code, expectedCode, @"$(reason + ": " ?? "")caught unexpected error"); } } -- cgit v1.3