summaryrefslogtreecommitdiff
path: root/toxcore/util_test.cc
blob: ff57f3fb75518df5aa299a1d5c113466ab054eff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#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