mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: Accurately display outgoing diagnostic packets (#4569)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
6a244316b2
commit
c690ddc7ea
18 changed files with 922 additions and 381 deletions
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package com.geeksville.mesh.service
|
||||
|
||||
import io.mockk.coVerify
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
|
|
@ -26,6 +27,7 @@ import kotlinx.coroutines.test.runTest
|
|||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.meshtastic.core.data.repository.MeshLogRepository
|
||||
import org.meshtastic.core.database.entity.MeshLog
|
||||
import org.meshtastic.core.service.ServiceRepository
|
||||
import org.meshtastic.proto.Data
|
||||
import org.meshtastic.proto.MeshPacket
|
||||
|
|
@ -88,4 +90,33 @@ class MeshMessageProcessorTest {
|
|||
|
||||
verify(exactly = 1) { dataHandler.handleReceivedData(match { it.id == 456 }, any(), any(), any()) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `packets from local node are logged with NODE_NUM_LOCAL`() = runTest(testDispatcher) {
|
||||
val myNodeNum = 1234
|
||||
val packet = MeshPacket(from = myNodeNum, id = 789, decoded = Data(portnum = PortNum.TEXT_MESSAGE_APP))
|
||||
|
||||
isNodeDbReady.value = true
|
||||
testScheduler.runCurrent()
|
||||
|
||||
processor.handleReceivedMeshPacket(packet, myNodeNum)
|
||||
testScheduler.runCurrent() // wait for log insert job
|
||||
|
||||
coVerify { meshLogRepository.insert(match { log -> log.fromNum == MeshLog.NODE_NUM_LOCAL }) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `packets from remote nodes are logged with their node number`() = runTest(testDispatcher) {
|
||||
val myNodeNum = 1234
|
||||
val remoteNodeNum = 5678
|
||||
val packet = MeshPacket(from = remoteNodeNum, id = 789, decoded = Data(portnum = PortNum.TEXT_MESSAGE_APP))
|
||||
|
||||
isNodeDbReady.value = true
|
||||
testScheduler.runCurrent()
|
||||
|
||||
processor.handleReceivedMeshPacket(packet, myNodeNum)
|
||||
testScheduler.runCurrent()
|
||||
|
||||
coVerify { meshLogRepository.insert(match { log -> log.fromNum == remoteNodeNum }) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package com.geeksville.mesh.service
|
||||
|
||||
import com.geeksville.mesh.repository.radio.RadioInterfaceService
|
||||
import io.mockk.coVerify
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
|
|
@ -28,8 +29,11 @@ import org.junit.Before
|
|||
import org.junit.Test
|
||||
import org.meshtastic.core.data.repository.MeshLogRepository
|
||||
import org.meshtastic.core.data.repository.PacketRepository
|
||||
import org.meshtastic.core.database.entity.MeshLog
|
||||
import org.meshtastic.core.service.ConnectionState
|
||||
import org.meshtastic.proto.Data
|
||||
import org.meshtastic.proto.MeshPacket
|
||||
import org.meshtastic.proto.PortNum
|
||||
import org.meshtastic.proto.QueueStatus
|
||||
import org.meshtastic.proto.ToRadio
|
||||
|
||||
|
|
@ -97,4 +101,15 @@ class PacketHandlerTest {
|
|||
handler.handleQueueStatus(status)
|
||||
testScheduler.runCurrent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `outgoing packets are logged with NODE_NUM_LOCAL`() = runTest(testDispatcher) {
|
||||
val packet = MeshPacket(id = 123, decoded = Data(portnum = PortNum.TEXT_MESSAGE_APP))
|
||||
val toRadio = ToRadio(packet = packet)
|
||||
|
||||
handler.sendToRadio(toRadio)
|
||||
testScheduler.runCurrent()
|
||||
|
||||
coVerify { meshLogRepository.insert(match { log -> log.fromNum == MeshLog.NODE_NUM_LOCAL }) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue