diff options
| author | frosty <frostinator33@airmail.cc> | 2026-10-26 10:21:57 -0400 |
|---|---|---|
| committer | frosty <frostinator33@airmail.cc> | 2026-10-26 10:21:57 -0400 |
| commit | 74aecd8b0986d07b50b7ce310d64e645b8b54e38 (patch) | |
| tree | 560e6434f183eb54cd779936f3a4c9575146a066 /libdino/tests/common.vala | |
| parent | 3d7e90d401da02d430a87db0ec7e1db3a6f1a68f (diff) | |
| parent | 4436001bb361ad4f9e4e05819214ecf0ea77c063 (diff) | |
Merge 'upstream/master'
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"); } } |
