diff options
author | Richard van der Hoff <richard@matrix.org> | 2016-05-17 18:53:00 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2016-05-24 13:39:34 +0100 |
commit | c058554132a0f97e8e8ae3a402605220f8fdaed4 (patch) | |
tree | a838740b55b86933875c6535b79d436ee6860bd0 /tests | |
parent | caaed796ad54de3f8ee1e56123973ae9ace346b9 (diff) |
Implement pickling/unpickling for outbound group sessions
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_group_session.cpp | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/tests/test_group_session.cpp b/tests/test_group_session.cpp index 9081293..b9fe1ef 100644 --- a/tests/test_group_session.cpp +++ b/tests/test_group_session.cpp @@ -18,16 +18,50 @@ int main() { -uint8_t random_bytes[] = - "0123456789ABDEF0123456789ABCDEF" - "0123456789ABDEF0123456789ABCDEF" - "0123456789ABDEF0123456789ABCDEF" - "0123456789ABDEF0123456789ABCDEF" - "0123456789ABDEF0123456789ABCDEF"; +{ + + TestCase test_case("Pickle outbound group"); + + size_t size = olm_outbound_group_session_size(); + void *memory = alloca(size); + OlmOutboundGroupSession *session = olm_outbound_group_session(memory); + + size_t pickle_length = olm_pickle_outbound_group_session_length(session); + uint8_t pickle1[pickle_length]; + olm_pickle_outbound_group_session(session, + "secret_key", 10, + pickle1, pickle_length); + uint8_t pickle2[pickle_length]; + memcpy(pickle2, pickle1, pickle_length); + + uint8_t buffer2[size]; + OlmOutboundGroupSession *session2 = olm_outbound_group_session(buffer2); + size_t res = olm_unpickle_outbound_group_session(session2, + "secret_key", 10, + pickle2, pickle_length); + assert_not_equals((size_t)-1, res); + assert_equals(pickle_length, + olm_pickle_outbound_group_session_length(session2)); + olm_pickle_outbound_group_session(session2, + "secret_key", 10, + pickle2, pickle_length); + + assert_equals(pickle1, pickle2, pickle_length); +} + { TestCase test_case("Group message send/receive"); + uint8_t random_bytes[] = + "0123456789ABDEF0123456789ABCDEF" + "0123456789ABDEF0123456789ABCDEF" + "0123456789ABDEF0123456789ABCDEF" + "0123456789ABDEF0123456789ABCDEF" + "0123456789ABDEF0123456789ABCDEF"; + + + size_t size = olm_outbound_group_session_size(); void *memory = alloca(size); OlmOutboundGroupSession *session = olm_outbound_group_session(memory); |