forked from Green-Sky/tomato
Squashed 'external/toxcore/c-toxcore/' content from commit 67badf69
git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 67badf69416a74e74f6d7eb51dd96f37282b8455
This commit is contained in:
38
toxcore/util_test.cc
Normal file
38
toxcore/util_test.cc
Normal file
@ -0,0 +1,38 @@
|
||||
#include "util.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "crypto_core.h"
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(Util, TwoRandomIdsAreNotEqual)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
ASSERT_NE(rng, nullptr);
|
||||
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(rng, pk1, sk1);
|
||||
crypto_new_keypair(rng, pk2, sk2);
|
||||
|
||||
EXPECT_FALSE(pk_equal(pk1, pk2));
|
||||
}
|
||||
|
||||
TEST(Util, IdCopyMakesKeysEqual)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
ASSERT_NE(rng, nullptr);
|
||||
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(rng, pk1, sk1);
|
||||
pk_copy(pk2, pk1);
|
||||
|
||||
EXPECT_TRUE(pk_equal(pk1, pk2));
|
||||
}
|
||||
|
||||
} // namespace
|
Reference in New Issue
Block a user