-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest_address.c
34 lines (28 loc) · 1.35 KB
/
test_address.c
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
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <stdint.h>
#include <stdbool.h>
#include <cmocka.h>
#include "ergo/address.h"
static void test_ergo_address_from_pubkey(void **state) {
(void) state;
uint8_t network = 0;
const uint8_t public_key[65] = {
0x04, 0x8b, 0x9f, 0xf8, 0x5d, 0xdd, 0x9f, 0x1e, 0x22, 0x88, 0xfc, 0x53, 0x9d,
0x39, 0xc7, 0xc4, 0xee, 0xb7, 0xa5, 0x56, 0xf4, 0xd8, 0x11, 0xcb, 0x73, 0x99,
0x64, 0x18, 0xde, 0x5a, 0xbd, 0xcb, 0x2a, 0xfa, 0x2d, 0x53, 0x17, 0x16, 0x0a,
0x59, 0x50, 0x0f, 0x5d, 0x31, 0xfa, 0xe8, 0x6b, 0xce, 0xe9, 0xab, 0x1a, 0x60,
0x53, 0xa1, 0x1d, 0x53, 0x5d, 0x2d, 0x04, 0x3c, 0xe5, 0xcf, 0xf1, 0x0a, 0xe7};
uint8_t address[38];
uint8_t expected[38] = {0x01, 0x03, 0x8b, 0x9f, 0xf8, 0x5d, 0xdd, 0x9f, 0x1e, 0x22,
0x88, 0xfc, 0x53, 0x9d, 0x39, 0xc7, 0xc4, 0xee, 0xb7, 0xa5,
0x56, 0xf4, 0xd8, 0x11, 0xcb, 0x73, 0x99, 0x64, 0x18, 0xde,
0x5a, 0xbd, 0xcb, 0x2a, 0xb5, 0x2d, 0xca, 0xce};
assert_true(ergo_address_from_pubkey(network, public_key, address));
assert_memory_equal(address, expected, sizeof(expected));
}
int main() {
const struct CMUnitTest tests[] = {cmocka_unit_test(test_ergo_address_from_pubkey)};
return cmocka_run_group_tests(tests, NULL, NULL);
}