aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-05-18 18:03:59 +0100
committerRichard van der Hoff <richard@matrix.org>2016-05-24 13:40:21 +0100
commita073d12d8367d27db97751d46b766e8480fd39e4 (patch)
tree52c1e0ca74c817f70cd1f0e6afd44b8e975bed5f /tests
parent39ad75314b9e28053f568ed6a4109f5d3a9468fe (diff)
Support for pickling inbound group sessions
Diffstat (limited to 'tests')
-rw-r--r--tests/test_group_session.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/test_group_session.cpp b/tests/test_group_session.cpp
index 5bbdc9d..4a82154 100644
--- a/tests/test_group_session.cpp
+++ b/tests/test_group_session.cpp
@@ -20,7 +20,7 @@
int main() {
{
- TestCase test_case("Pickle outbound group");
+ TestCase test_case("Pickle outbound group session");
size_t size = olm_outbound_group_session_size();
uint8_t memory[size];
@@ -51,6 +51,37 @@ int main() {
{
+ TestCase test_case("Pickle inbound group session");
+
+ size_t size = olm_inbound_group_session_size();
+ uint8_t memory[size];
+ OlmInboundGroupSession *session = olm_inbound_group_session(memory);
+
+ 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);
+ 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);
+ 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);
+
+ assert_equals(pickle1, pickle2, pickle_length);
+}
+
+
+{
TestCase test_case("Group message send/receive");
uint8_t random_bytes[] =