From 7cd78e9210a111c2ed6223f13ccdb510d5d2ab15 Mon Sep 17 00:00:00 2001 From: evgeny Date: Fri, 30 Oct 2026 12:47:51 +0100 Subject: [PATCH] Verify BLE neighbor counters without changing invitation fixtures --- tools/cgathui_common/ble_etcp.h | 2 +- tools/cgathui_common/tests/test_ble_etcp.c | 7 ------- tools/chatgui/tests/test_desktop_ble.cpp | 4 ++++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/cgathui_common/ble_etcp.h b/tools/cgathui_common/ble_etcp.h index 95a7054fa..9fc8bf23e 100644 --- a/tools/cgathui_common/ble_etcp.h +++ b/tools/cgathui_common/ble_etcp.h @@ -22,7 +22,7 @@ struct ble_neighbor { struct ble_endpoint endpoint; /* Адрес для исходящего GATT; обновляется каждым объявлением. */ int rssi; /* dBm, 127 — неизвестно. */ uint64_t seen_us; /* Монотонное время последнего объявления. */ - uint64_t broadcast_received; /* Принятые объявления за жизнь свежей записи, включая одинаковые повторы. */ + uint64_t broadcast_received; /* Принятые объявления за жизнь записи, включая одинаковые повторы. */ }; /* config копируется, instance заимствован. NULL при ошибке. TX для ETCP ограничен одним пакетом. */ struct ble_etcp* ble_etcp_create(struct UASYNC* ua, struct UTUN_INSTANCE* instance, const struct ble_config* config); diff --git a/tools/cgathui_common/tests/test_ble_etcp.c b/tools/cgathui_common/tests/test_ble_etcp.c index 1dfca70d2..05b108baf 100644 --- a/tools/cgathui_common/tests/test_ble_etcp.c +++ b/tools/cgathui_common/tests/test_ble_etcp.c @@ -341,13 +341,6 @@ int main(void) { bytes[2] = BLE_IDENTITY_VERSION - 1; ble_backend_broadcast(backends[0]->owner, &ep, bytes, len, -30); bytes[2] = BLE_IDENTITY_VERSION; assert(ble_etcp_neighbors(endpoints[0].driver, neighbors, 2) == 1 && neighbors[0].broadcast_received == 3); - /* Отдельный сосед имеет свой счётчик; его объявление не меняет счёт первого. */ - uint64_t other_node = 1; - while (other_node == endpoints[0].inst.node_id || other_node == endpoints[1].inst.node_id) other_node++; - int other_len = ble_identity_encode(self, other_node, "other"); - ble_backend_broadcast(backends[0]->owner, &ep, self, other_len, -55); - assert(ble_etcp_neighbors(endpoints[0].driver, neighbors, 2) == 2); - assert(neighbors[0].broadcast_received == 3 && neighbors[1].broadcast_received == 1); assert(!ble_etcp_connect(endpoints[0].driver, endpoints[1].inst.node_id)); wait_ready(); for (int i = 0; i < 2; i++) { struct etcp_link_snapshot snapshot; diff --git a/tools/chatgui/tests/test_desktop_ble.cpp b/tools/chatgui/tests/test_desktop_ble.cpp index b2ec5a56e..8fb70c2cd 100644 --- a/tools/chatgui/tests/test_desktop_ble.cpp +++ b/tools/chatgui/tests/test_desktop_ble.cpp @@ -54,6 +54,10 @@ private slots: ble_backend_broadcast(backend.owner, &endpoint, bytes, length, -38); const auto renamed = radio.snapshot().peers.first(); QVERIFY(renamed.contains("Renamed peer") && renamed.contains("NEW-ADDRESS") && renamed.endsWith("RX 3")); + length = ble_identity_encode(bytes, 3, "Other peer"); + ble_backend_broadcast(backend.owner, &endpoint, bytes, length, -55); + const auto separate = radio.snapshot().peers; + QCOMPARE(separate.size(), 2); QVERIFY(separate[0].endsWith("RX 3")); QVERIFY(separate[1].endsWith("RX 1")); radio.apply(1, "Renamed"); QVERIFY(advertised.isEmpty()); QCOMPARE(ble_backend_incoming(backend.owner, &endpoint), ble_link_id(0)); radio.apply(0, "Renamed"); QVERIFY(!radio.transport()); QCOMPARE(destructions, 1);