This repository was archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 289
/
Copy pathcrypto_tests.cpp
48 lines (40 loc) · 2.27 KB
/
crypto_tests.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* @file
* @copyright defined in eosio.cdt/LICENSE.txt
*/
#include <eosio/tester.hpp>
#include <eosio/crypto.hpp>
using eosio::public_key;
using eosio::signature;
// Definitions in `eosio.cdt/libraries/eosio/crypto.hpp`
EOSIO_TEST_BEGIN(public_key_type_test)
// -----------------------------------------------------
// bool operator==(const public_key&, const public_key&)
CHECK_EQUAL( (public_key(std::in_place_index<0>, std::array<char, 33>{}) == public_key(std::in_place_index<0>, std::array<char, 33>{})), true )
CHECK_EQUAL( (public_key(std::in_place_index<0>, std::array<char, 33>{1}) == public_key(std::in_place_index<0>, std::array<char, 33>{})), false )
// -----------------------------------------------------
// bool operator!=(const public_key&, const public_key&)
CHECK_EQUAL( (public_key(std::in_place_index<0>, std::array<char, 33>{}) != public_key(std::in_place_index<0>, std::array<char, 33>{})), false )
CHECK_EQUAL( (public_key(std::in_place_index<0>, std::array<char, 33>{1}) != public_key(std::in_place_index<0>, std::array<char, 33>{})), true )
EOSIO_TEST_END
// Definitions in `eosio.cdt/libraries/eosio/crypto.hpp`
EOSIO_TEST_BEGIN(signature_type_test)
// ---------------------------------------------------
// bool operator==(const signature&, const signature&)
CHECK_EQUAL( (signature(std::in_place_index<0>, std::array<char, 65>{}) == signature(std::in_place_index<0>, std::array<char, 65>{})), true )
CHECK_EQUAL( (signature(std::in_place_index<0>, std::array<char, 65>{1}) == signature(std::in_place_index<0>, std::array<char, 65>{})), false )
// ---------------------------------------------------
// bool operator!=(const signature&, const signature&)
CHECK_EQUAL( (signature(std::in_place_index<0>, std::array<char, 65>{1}) != signature(std::in_place_index<0>, std::array<char, 65>{})), true )
CHECK_EQUAL( (signature(std::in_place_index<0>, std::array<char, 65>{}) != signature(std::in_place_index<0>, std::array<char, 65>{})), false )
EOSIO_TEST_END
int main(int argc, char* argv[]) {
bool verbose = false;
if( argc >= 2 && std::strcmp( argv[1], "-v" ) == 0 ) {
verbose = true;
}
silence_output(!verbose);
EOSIO_TEST(public_key_type_test)
EOSIO_TEST(signature_type_test)
return has_failed();
}