|
|
|
@ -14,7 +14,6 @@ static int tests_passed = 0, tests_total = 0; |
|
|
|
static struct SC_MYKEYS s_keys, c_keys; |
|
|
|
static struct SC_MYKEYS s_keys, c_keys; |
|
|
|
static int test_failed = 0; |
|
|
|
static int test_failed = 0; |
|
|
|
|
|
|
|
|
|
|
|
#define BASE_PORT 24567 |
|
|
|
|
|
|
|
#define TASSERT(cond) do { \ |
|
|
|
#define TASSERT(cond) do { \ |
|
|
|
if (!(cond)) { DEBUG_ERROR(DEBUG_CATEGORY_GENERAL, " FAIL: %s", #cond); test_failed = 1; return test_failed; } \
|
|
|
|
if (!(cond)) { DEBUG_ERROR(DEBUG_CATEGORY_GENERAL, " FAIL: %s", #cond); test_failed = 1; return test_failed; } \
|
|
|
|
} while(0) |
|
|
|
} while(0) |
|
|
|
@ -45,11 +44,11 @@ static int test1_basic(void) { |
|
|
|
|
|
|
|
|
|
|
|
struct stcp_link_config cfg = {.inst = inst, .listen_family = AF_INET}; |
|
|
|
struct stcp_link_config cfg = {.inst = inst, .listen_family = AF_INET}; |
|
|
|
g_on_srv_link = NULL; |
|
|
|
g_on_srv_link = NULL; |
|
|
|
struct stcp_server *ss = stcp_server_listen(&cfg, BASE_PORT + 1, on_srv_link, NULL); |
|
|
|
struct stcp_server *ss = stcp_server_listen(&cfg, 0, on_srv_link, NULL); |
|
|
|
TASSERT(ss); |
|
|
|
TASSERT(ss); |
|
|
|
|
|
|
|
|
|
|
|
int cli_ready = 0; |
|
|
|
int cli_ready = 0; |
|
|
|
struct stcp_client *sc = stcp_client_connect(ua, "127.0.0.1", BASE_PORT + 1, &c_keys, |
|
|
|
struct stcp_client *sc = stcp_client_connect(ua, "127.0.0.1", stcp_link_server_get_port(ss), &c_keys, |
|
|
|
s_keys.public_key, NULL, |
|
|
|
s_keys.public_key, NULL, |
|
|
|
0, NULL, |
|
|
|
0, NULL, |
|
|
|
0, 200, 0, on_cli_ready, &cli_ready, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL); |
|
|
|
0, 200, 0, on_cli_ready, &cli_ready, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL); |
|
|
|
@ -73,12 +72,12 @@ static int test2_wrong_key(void) { |
|
|
|
|
|
|
|
|
|
|
|
struct stcp_link_config cfg = {.inst = inst, .listen_family = AF_INET}; |
|
|
|
struct stcp_link_config cfg = {.inst = inst, .listen_family = AF_INET}; |
|
|
|
g_on_srv_link = NULL; |
|
|
|
g_on_srv_link = NULL; |
|
|
|
struct stcp_server *ss = stcp_server_listen(&cfg, BASE_PORT + 2, on_srv_link, NULL); |
|
|
|
struct stcp_server *ss = stcp_server_listen(&cfg, 0, on_srv_link, NULL); |
|
|
|
TASSERT(ss); |
|
|
|
TASSERT(ss); |
|
|
|
|
|
|
|
|
|
|
|
struct SC_MYKEYS rogue; TASSERT(sc_generate_keypair(&rogue) == SC_OK); |
|
|
|
struct SC_MYKEYS rogue; TASSERT(sc_generate_keypair(&rogue) == SC_OK); |
|
|
|
int cli_ready = 0; |
|
|
|
int cli_ready = 0; |
|
|
|
struct stcp_client *sc = stcp_client_connect(ua, "127.0.0.1", BASE_PORT + 2, &c_keys, |
|
|
|
struct stcp_client *sc = stcp_client_connect(ua, "127.0.0.1", stcp_link_server_get_port(ss), &c_keys, |
|
|
|
rogue.public_key, NULL, |
|
|
|
rogue.public_key, NULL, |
|
|
|
0, NULL, |
|
|
|
0, NULL, |
|
|
|
0, 200, 0, on_cli_ready, &cli_ready, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL); |
|
|
|
0, 200, 0, on_cli_ready, &cli_ready, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL); |
|
|
|
|