diff options
| author | Marvin W <git@larma.de> | 2026-10-04 14:42:16 +0200 |
|---|---|---|
| committer | Marvin W <git@larma.de> | 2026-10-23 16:59:59 +0200 |
| commit | dba577f39c489b9db29960f2bf5cc78ac4f29d7b (patch) | |
| tree | a8354c9fc328c1442d5e8c5c2adec4b428c92f44 /libdino/tests/common.vala | |
| parent | 2413442905e31f34cb0f77c9167003b3725760fe (diff) | |
Move OMEMO, OpenPGP and RTP plugins into main/libdino
Diffstat (limited to 'libdino/tests/common.vala')
| -rw-r--r-- | libdino/tests/common.vala | 29 |
1 files changed, 27 insertions, 2 deletions
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"); } } |
