aboutsummaryrefslogtreecommitdiff
path: root/tests/test_olm.cpp
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-10-24 10:06:06 +0100
committerRichard van der Hoff <richard@matrix.org>2016-10-24 10:06:06 +0100
commita7310c5821513d5c5b0609ec506dad1ae51603d3 (patch)
tree92b6d8031b53d3883e63ca39589c186909ba10f5 /tests/test_olm.cpp
parentd1a535861d02f5a5e049eb3654c8adf1d316bac8 (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_olm.cpp')
-rw-r--r--tests/test_olm.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/test_olm.cpp b/tests/test_olm.cpp
index af2c9f7..4619558 100644
--- a/tests/test_olm.cpp
+++ b/tests/test_olm.cpp
@@ -49,7 +49,9 @@ mock_random(ot_random, sizeof(ot_random));
std::size_t pickle_length = ::olm_pickle_account_length(account);
std::uint8_t pickle1[pickle_length];
-::olm_pickle_account(account, "secret_key", 10, pickle1, pickle_length);
+std::size_t res = ::olm_pickle_account(account, "secret_key", 10, pickle1, pickle_length);
+assert_equals(pickle_length, res);
+
std::uint8_t pickle2[pickle_length];
std::memcpy(pickle2, pickle1, pickle_length);
@@ -59,10 +61,10 @@ assert_not_equals(std::size_t(-1), ::olm_unpickle_account(
account2, "secret_key", 10, pickle2, pickle_length
));
assert_equals(pickle_length, ::olm_pickle_account_length(account2));
-::olm_pickle_account(account2, "secret_key", 10, pickle2, pickle_length);
+res = ::olm_pickle_account(account2, "secret_key", 10, pickle2, pickle_length);
+assert_equals(pickle_length, res);
assert_equals(pickle1, pickle2, pickle_length);
-
}
@@ -122,7 +124,9 @@ mock_random(random2, sizeof(random2));
std::size_t pickle_length = ::olm_pickle_session_length(session);
std::uint8_t pickle1[pickle_length];
-::olm_pickle_session(session, "secret_key", 10, pickle1, pickle_length);
+std::size_t res = ::olm_pickle_session(session, "secret_key", 10, pickle1, pickle_length);
+assert_equals(pickle_length, res);
+
std::uint8_t pickle2[pickle_length];
std::memcpy(pickle2, pickle1, pickle_length);
@@ -132,10 +136,10 @@ assert_not_equals(std::size_t(-1), ::olm_unpickle_session(
session2, "secret_key", 10, pickle2, pickle_length
));
assert_equals(pickle_length, ::olm_pickle_session_length(session2));
-::olm_pickle_session(session2, "secret_key", 10, pickle2, pickle_length);
+res = ::olm_pickle_session(session2, "secret_key", 10, pickle2, pickle_length);
+assert_equals(pickle_length, res);
assert_equals(pickle1, pickle2, pickle_length);
-
}
{ /** Loopback test */