Verify BLE neighbor counters without changing invitation fixtures

This commit is contained in:
evgeny committed 2026-10-30 12:47:51 +01:00
1 parent 184b02b342
commit 7cd78e9210
3 files changed
+5 -8

No files matched your search

+1 -1
View File
@@ -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);
@@ -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;
+4
View File
@@ -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);