test(chat): distinguish route event deletion flag from routing API
This commit is contained in:
1 parent
33556fefea
commit
cb9c04ff61
1 file changed
+5
-5
@@ -22,7 +22,7 @@ static sqlite3* reader;
|
||||
static struct nodeinfo_cbk_entry* preserved_callback;
|
||||
static unsigned ready;
|
||||
static uint64_t route_group;
|
||||
static int route_delete, route_inspect;
|
||||
static int delete_from_route_event, route_inspect;
|
||||
static unsigned route_seen, route_events;
|
||||
extern int __real_member_sync_add_props_cbk(struct UTUN_INSTANCE*, node_props_changed_fn, void*);
|
||||
int __wrap_member_sync_add_props_cbk(struct UTUN_INSTANCE* inst, node_props_changed_fn callback, void* arg) {
|
||||
@@ -104,7 +104,7 @@ static void event(struct UTUN_INSTANCE* inst, int type, const uint8_t* data, int
|
||||
char ch[21]; memcpy(ch, data + 1, data[0]); ch[data[0]] = 0;
|
||||
if (strtoull(ch, NULL, 10) == route_group) {
|
||||
route_events++;
|
||||
if (route_delete) { route_delete = 0; chat_core_delete_channel(inst, ch); }
|
||||
if (delete_from_route_event) { delete_from_route_event = 0; chat_core_delete_channel(inst, ch); }
|
||||
}
|
||||
}
|
||||
if (type != CHAT_EVT_DB_READY && type != CHAT_EVT_MY_NODE_ID) return;
|
||||
@@ -222,11 +222,11 @@ static void route_notifications(struct UTUN_INSTANCE* inst, struct UASYNC* ua) {
|
||||
ready = 0; assert(!chat_service_start(inst) && ready == 2);
|
||||
route_group = chat_core_create_channel_auto(inst, "delete after route dispatch"); assert(route_group); uasync_poll(ua, 0);
|
||||
struct TOPO_GROUP* group = topo_groups_find(inst->topo_groups, route_group); assert(group && group->local_node);
|
||||
route_seen = route_events = 0; route_inspect = route_delete = 1;
|
||||
route_seen = route_events = 0; route_inspect = delete_from_route_event = 1;
|
||||
topo_fire_nodeinfo_cbk(inst, group, group->local_node);
|
||||
assert(group->local_node->node_id == inst->node_id && route_seen == 1 && route_delete && !route_events);
|
||||
assert(group->local_node->node_id == inst->node_id && route_seen == 1 && delete_from_route_event && !route_events);
|
||||
route_inspect = 0; uasync_poll(ua, 0);
|
||||
assert(!route_delete && route_events == 1 && !topo_groups_find(inst->topo_groups, route_group));
|
||||
assert(!delete_from_route_event && route_events == 1 && !topo_groups_find(inst->topo_groups, route_group));
|
||||
route_group = 0; chat_service_stop(inst);
|
||||
puts("PASS lifecycle:route observers and caller retain live group/node until dispatch returns;deferred event may delete channel");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user