diff options
author | Richard van der Hoff <richard@matrix.org> | 2016-10-24 10:06:06 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2016-10-24 10:06:06 +0100 |
commit | a7310c5821513d5c5b0609ec506dad1ae51603d3 (patch) | |
tree | 92b6d8031b53d3883e63ca39589c186909ba10f5 /tests/test_group_session.cpp | |
parent | d1a535861d02f5a5e049eb3654c8adf1d316bac8 (diff) |
Return the base64-encoded length of pickles
make olm_pickle_* return the lengths of the base64-encoded pickles, rather than
the raw pickle. (From the application's POV, the format of the pickle is
opaque: it doesn't even know that it is base64-encoded. So returning the length
of the raw pickle is particularly unhelpful.)
Diffstat (limited to 'tests/test_group_session.cpp')
-rw-r--r-- | tests/test_group_session.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/tests/test_group_session.cpp b/tests/test_group_session.cpp index df46f0e..ad67adb 100644 --- a/tests/test_group_session.cpp +++ b/tests/test_group_session.cpp @@ -28,23 +28,26 @@ int main() { 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); + size_t res = olm_pickle_outbound_group_session( + session, "secret_key", 10, pickle1, pickle_length + ); + assert_equals(pickle_length, res); + 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); + 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); + res = olm_pickle_outbound_group_session( + session2, "secret_key", 10, pickle2, pickle_length + ); + assert_equals(pickle_length, res); assert_equals(pickle1, pickle2, pickle_length); } @@ -59,23 +62,25 @@ int main() { size_t pickle_length = olm_pickle_inbound_group_session_length(session); uint8_t pickle1[pickle_length]; - olm_pickle_inbound_group_session(session, - "secret_key", 10, - pickle1, pickle_length); + size_t res = olm_pickle_inbound_group_session( + session, "secret_key", 10, pickle1, pickle_length + ); + assert_equals(pickle_length, res); + uint8_t pickle2[pickle_length]; memcpy(pickle2, pickle1, pickle_length); uint8_t buffer2[size]; OlmInboundGroupSession *session2 = olm_inbound_group_session(buffer2); - size_t res = olm_unpickle_inbound_group_session(session2, - "secret_key", 10, - pickle2, pickle_length); + res = olm_unpickle_inbound_group_session( + session2, "secret_key", 10, pickle2, pickle_length + ); assert_not_equals((size_t)-1, res); assert_equals(pickle_length, olm_pickle_inbound_group_session_length(session2)); - olm_pickle_inbound_group_session(session2, - "secret_key", 10, - pickle2, pickle_length); + res = olm_pickle_inbound_group_session( + session2, "secret_key", 10, pickle2, pickle_length + ); assert_equals(pickle1, pickle2, pickle_length); } |