Coverage Report

Created: 2026-10-24 08:16

/work/auto_tests/scenarios/scenario_bootstrap_test.c
Line
Count
Source (jump to first uncovered line)
1
#include "framework/framework.h"
2
#include <stdio.h>
3
4
static void alice_script(ToxNode *self, void *ctx)
5
2
{
6
2
    ToxScenario *s = tox_node_get_scenario(self);
7
2
    ToxNode *bob = tox_scenario_get_node(s, 1);
8
    // Alice just waits for Bob to finish his bootstrap test
9
2
    WAIT_UNTIL(tox_node_is_finished(bob));
10
2
}
11
12
static void bob_script(ToxNode *self, void *ctx)
13
6
{
14
6
    tox_node_log(self, "Waiting for DHT connection...");
15
6
    WAIT_UNTIL(tox_node_is_self_connected(self));
16
6
    tox_node_log(self, "Connected to DHT!");
17
6
}
18
19
int main(int argc, char *argv[])
20
4
{
21
4
    ToxScenario *s = tox_scenario_new(argc, argv, 30000);
22
23
4
    ToxNode *alice = tox_scenario_add_node(s, "Alice", alice_script, nullptr, 0);
24
4
    ToxNode *bob = tox_scenario_add_node(s, "Bob", bob_script, nullptr, 0);
25
26
4
    tox_node_bootstrap(bob, alice);
27
28
4
    ToxScenarioStatus res = tox_scenario_run(s);
29
30
4
    if (res == TOX_SCENARIO_DONE) {
31
4
        tox_scenario_log(s, "Scenario completed successfully!");
32
4
    } else {
33
0
        tox_scenario_log(s, "Scenario failed with status: %u", res);
34
0
    }
35
36
4
    tox_scenario_free(s);
37
4
    return (res == TOX_SCENARIO_DONE) ? 0 : 1;
38
4
}