aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-05-24 17:52:35 +0100
committerRichard van der Hoff <richard@matrix.org>2016-05-24 17:52:35 +0100
commit01ea3d4b9a3c6f3e0303c2d421a248715a96af99 (patch)
tree553ba1b809d0cc44e96e3860cee28f9aac4f4802 /tests
parent1f31427139acdef00f24aac13b67224fa915f9e7 (diff)
Fix handling of integer wraparound in megolm.c
Diffstat (limited to 'tests')
-rw-r--r--tests/test_megolm.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_megolm.cpp b/tests/test_megolm.cpp
index 871de36..bf53346 100644
--- a/tests/test_megolm.cpp
+++ b/tests/test_megolm.cpp
@@ -82,4 +82,20 @@ std::uint8_t random_bytes[] =
assert_equals(expected3, megolm_get_data(&mr), MEGOLM_RATCHET_LENGTH);
}
+{
+ TestCase test_case("Megolm::advance wraparound");
+
+ Megolm mr1, mr2;
+
+ megolm_init(&mr1, random_bytes, 0xffffffffUL);
+ megolm_advance_to(&mr1, 0x1000000);
+ assert_equals(0x1000000U, mr1.counter);
+
+ megolm_init(&mr2, random_bytes, 0);
+ megolm_advance_to(&mr2, 0x2000000);
+ assert_equals(0x2000000U, mr2.counter);
+
+ assert_equals(megolm_get_data(&mr2), megolm_get_data(&mr1), MEGOLM_RATCHET_LENGTH);
+}
+
}