fixed peer learning from first package (race condition)
This commit is contained in:
@@ -188,6 +188,19 @@ void main() {
|
||||
transport.dispose();
|
||||
});
|
||||
|
||||
test(
|
||||
'falls back to the default mLRS bridge IP when neither a host is '
|
||||
'configured nor a gateway address is reported',
|
||||
() async {
|
||||
final fake = FakeMlrsNetworkController();
|
||||
final transport = await connectWithFake(fake);
|
||||
|
||||
expect(transport.peerDescription, startsWith('192.168.4.55'));
|
||||
|
||||
transport.dispose();
|
||||
},
|
||||
);
|
||||
|
||||
test('a configured host overrides the reported gateway address', () async {
|
||||
final fake = FakeMlrsNetworkController();
|
||||
final transport = await connectWithFake(
|
||||
@@ -223,9 +236,17 @@ void main() {
|
||||
transport.dispose();
|
||||
});
|
||||
|
||||
test('send() without a known peer throws LinkConnectException', () async {
|
||||
test('send() before the socket is open throws LinkConnectException',
|
||||
() async {
|
||||
final fake = FakeMlrsNetworkController();
|
||||
final transport = await connectWithFake(fake);
|
||||
final transport = UdpTransport(
|
||||
getHost: () async => null,
|
||||
getPort: () async => 0,
|
||||
getSsidPrefix: () async => 'mLRS-',
|
||||
getRememberedSsid: () async => null,
|
||||
rememberSsid: (_) async {},
|
||||
networkController: fake,
|
||||
);
|
||||
|
||||
expect(
|
||||
() => transport.send(Uint8List.fromList([1])),
|
||||
@@ -235,6 +256,22 @@ void main() {
|
||||
transport.dispose();
|
||||
});
|
||||
|
||||
test(
|
||||
'send() works with the default mLRS bridge IP even before any packet '
|
||||
'has been received',
|
||||
() async {
|
||||
final fake = FakeMlrsNetworkController();
|
||||
final transport = await connectWithFake(fake);
|
||||
|
||||
await transport.send(Uint8List.fromList([1, 2, 3]));
|
||||
|
||||
expect(fake.sentPackets, hasLength(1));
|
||||
expect(fake.sentPackets.single.host, '192.168.4.55');
|
||||
|
||||
transport.dispose();
|
||||
},
|
||||
);
|
||||
|
||||
test('send() forwards bytes to the learned peer via the native socket',
|
||||
() async {
|
||||
final fake = FakeMlrsNetworkController();
|
||||
|
||||
Reference in New Issue
Block a user