Exemple #1
0
void test_addto_lists_good(DHT            *dht,
                           Client_data    *list,
                           uint32_t        length,
                           IP_Port        *ip_port,
                           const uint8_t  *comp_client_id)
{
    uint8_t client_id[CLIENT_ID_SIZE];
    uint8_t ipv6 = ip_port->ip.family == AF_INET6 ? 1 : 0;

    mark_all_good(list, length, ipv6);

    // check "good" client id replacement
    do {
        randombytes(client_id, sizeof(client_id));
    } while (is_furthest(comp_client_id, list, length, client_id));

    ip_port->port += 1;
    addto_lists(dht, *ip_port, client_id);
    ck_assert_msg(client_in_list(list, length, client_id) >= 0, "Good client id is not in the list");

    // check "good" client id skip
    do {
        randombytes(client_id, sizeof(client_id));
    } while (!is_furthest(comp_client_id, list, length, client_id));

    ip_port->port += 1;
    addto_lists(dht, *ip_port, client_id);
    ck_assert_msg(client_in_list(list, length, client_id) == -1, "Good client id is in the list");
}
Exemple #2
0
void test_addto_lists_good(DHT            *dht,
                           Client_data    *list,
                           uint32_t        length,
                           IP_Port        *ip_port,
                           const uint8_t  *comp_client_id)
{
    uint8_t public_key[crypto_box_PUBLICKEYBYTES];
    uint8_t ipv6 = ip_port->ip.family == AF_INET6 ? 1 : 0;

    mark_all_good(list, length, ipv6);

    // check "good" client id replacement
    do {
        randombytes(public_key, sizeof(public_key));
    } while (is_furthest(comp_client_id, list, length, public_key));

    ip_port->port += 1;
    addto_lists(dht, *ip_port, public_key);
    ck_assert_msg(client_in_list(list, length, public_key) >= 0, "Good client id is not in the list");

    // check "good" client id skip
    do {
        randombytes(public_key, sizeof(public_key));
    } while (!is_furthest(comp_client_id, list, length, public_key));

    ip_port->port += 1;
    addto_lists(dht, *ip_port, public_key);
    ck_assert_msg(client_in_list(list, length, public_key) == -1, "Good client id is in the list");
}