aboutsummaryrefslogtreecommitdiff
path: root/tests/test_message.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_message.cpp')
-rw-r--r--tests/test_message.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/test_message.cpp b/tests/test_message.cpp
index ca36ff5..9c0ab4a 100644
--- a/tests/test_message.cpp
+++ b/tests/test_message.cpp
@@ -27,9 +27,9 @@ std::uint8_t hmacsha2[9] = "hmacsha2";
TestCase test_case("Message decode test");
-axolotl::MessageReader reader(axolotl::decode_message(message1, 35, 8));
+axolotl::MessageReader reader;
+axolotl::decode_message(reader, message1, 35, 8);
-assert_equals(std::size_t(27), reader.body_length);
assert_equals(std::uint8_t(3), reader.version);
assert_equals(std::uint32_t(1), reader.counter);
assert_equals(std::size_t(10), reader.ratchet_key_length);
@@ -37,7 +37,6 @@ assert_equals(std::size_t(10), reader.ciphertext_length);
assert_equals(ratchetkey, reader.ratchet_key, 10);
assert_equals(ciphertext, reader.ciphertext, 10);
-assert_equals(hmacsha2, reader.mac, 8);
} /* Message decode test */
@@ -51,12 +50,12 @@ assert_equals(std::size_t(35), length);
std::uint8_t output[length];
-axolotl::MessageWriter writer(axolotl::encode_message(3, 1, 10, 10, output));
-assert_equals(std::size_t(27), writer.body_length);
+axolotl::MessageWriter writer;
+axolotl::encode_message(writer, 3, 1, 10, 10, output);
std::memcpy(writer.ratchet_key, ratchetkey, 10);
std::memcpy(writer.ciphertext, ciphertext, 10);
-std::memcpy(writer.mac, hmacsha2, 8);
+std::memcpy(output + length - 8, hmacsha2, 8);
assert_equals(message2, output, 35);