X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=test%2Fbasic.c;h=bf8ff772af73db120cadbc2d54403fb36b512d26;hb=4ac017d4c4424a1a3c5c1b1c641cf1c29bd13e44;hp=46f86960cab377bb97f7517191560ec9c3258eb6;hpb=be83b0af60449c7b35d17d97f2e6dc12f611e831;p=meshlink diff --git a/test/basic.c b/test/basic.c index 46f86960..bf8ff772 100644 --- a/test/basic.c +++ b/test/basic.c @@ -37,18 +37,31 @@ int main() { assert(self); assert(!strcmp(self->name, "foo")); - // Check that we are reachable. + // Check that we are not reachable. - assert(meshlink_get_node_reachability(mesh, self, NULL, NULL)); + time_t last_reachable; + time_t last_unreachable; + assert(!meshlink_get_node_reachability(mesh, self, &last_reachable, &last_unreachable)); + assert(!last_reachable); + assert(!last_unreachable); // Start and stop the mesh. assert(meshlink_start(mesh)); + + // Check that we are now reachable + + assert(meshlink_get_node_reachability(mesh, self, &last_reachable, &last_unreachable)); + assert(last_reachable); + assert(!last_unreachable); + meshlink_stop(mesh); - // Check that we are still reachable. + // Check that we are no longer reachable. - assert(meshlink_get_node_reachability(mesh, self, NULL, NULL)); + assert(!meshlink_get_node_reachability(mesh, self, &last_reachable, &last_unreachable)); + assert(last_reachable); + assert(last_unreachable); // Make sure we can start and stop the mesh again. @@ -63,6 +76,15 @@ int main() { mesh = meshlink_open("basic_conf", "bar", "basic", DEV_CLASS_BACKBONE); assert(mesh); + self = meshlink_get_self(mesh); + assert(self); + + // Check that we remembered we were reachable + + assert(!meshlink_get_node_reachability(mesh, self, &last_reachable, &last_unreachable)); + assert(last_reachable); + assert(last_unreachable); + // Check that the name is ignored now, and that we still are "foo". assert(!meshlink_get_node(mesh, "bar"));