From fa58f69fe117640e29cefb1b699bede4d045bc2f Mon Sep 17 00:00:00 2001 From: aunsane Date: Sat, 3 Mar 2018 16:35:09 +0300 Subject: Tox: - updated toxcore due to release v0.2 - removed message correction - reworked nodes update --- protocols/Tox/libtox/src/toxcore/util_test.cpp | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 protocols/Tox/libtox/src/toxcore/util_test.cpp (limited to 'protocols/Tox/libtox/src/toxcore/util_test.cpp') diff --git a/protocols/Tox/libtox/src/toxcore/util_test.cpp b/protocols/Tox/libtox/src/toxcore/util_test.cpp new file mode 100644 index 0000000000..8de6384848 --- /dev/null +++ b/protocols/Tox/libtox/src/toxcore/util_test.cpp @@ -0,0 +1,55 @@ +#include "util.h" + +#include "crypto_core.h" + +#include + +TEST(Util, UnixTimeIncreasesOverTime) +{ + unix_time_update(); + uint64_t const start = unix_time(); + + while (start == unix_time()) { + unix_time_update(); + } + + uint64_t const end = unix_time(); + EXPECT_GT(end, start); +} + +TEST(Util, IsTimeout) +{ + uint64_t const start = unix_time(); + EXPECT_FALSE(is_timeout(start, 1)); + + while (start == unix_time()) { + unix_time_update(); + } + + EXPECT_TRUE(is_timeout(start, 1)); +} + +TEST(Util, TwoRandomIdsAreNotEqual) +{ + uint8_t pk1[CRYPTO_PUBLIC_KEY_SIZE]; + uint8_t sk1[CRYPTO_SECRET_KEY_SIZE]; + uint8_t pk2[CRYPTO_PUBLIC_KEY_SIZE]; + uint8_t sk2[CRYPTO_SECRET_KEY_SIZE]; + + crypto_new_keypair(pk1, sk1); + crypto_new_keypair(pk2, sk2); + + EXPECT_FALSE(id_equal(pk1, pk2)); +} + +TEST(Util, IdCopyMakesKeysEqual) +{ + uint8_t pk1[CRYPTO_PUBLIC_KEY_SIZE]; + uint8_t sk1[CRYPTO_SECRET_KEY_SIZE]; + uint8_t pk2[CRYPTO_PUBLIC_KEY_SIZE] = {0}; + + crypto_new_keypair(pk1, sk1); + id_copy(pk2, pk1); + + EXPECT_TRUE(id_equal(pk1, pk2)); +} -- cgit v1.2.3