mirror of
https://github.com/TokTok/c-toxcore
synced 2026-06-07 13:12:53 +00:00
abc17b0f89
It turns out, `unix_time` is also monotonic, and is used as such, so I've renamed the new functions to `mono_time_*`. 2018-07-08: ``` 00:01 <@irungentoo> the idea used to be that the unix_time() function could go backward in time but I think I might have started using it like if it could not after I changed it so that it would never go back in time ```
33 lines
650 B
C++
33 lines
650 B
C++
#include "util.h"
|
|
|
|
#include "crypto_core.h"
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace {
|
|
|
|
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));
|
|
}
|
|
|
|
} // namespace
|