mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
Bump iOS project version
This commit is contained in:
31
test/providers/app_provider_channel_info_test.dart
Normal file
31
test/providers/app_provider_channel_info_test.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_sar_app/providers/app_provider.dart';
|
||||
|
||||
void main() {
|
||||
group('AppProvider channel info handling', () {
|
||||
test('treats zeroed unnamed non-public channel as deleted', () {
|
||||
expect(
|
||||
AppProvider.isDeletedChannelInfo(2, '', Uint8List(16)),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps unnamed non-public channel when secret is configured', () {
|
||||
final secret = Uint8List.fromList([
|
||||
1,
|
||||
...List<int>.filled(15, 0),
|
||||
]);
|
||||
|
||||
expect(
|
||||
AppProvider.isDeletedChannelInfo(2, '', secret),
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
AppProvider.channelContactName(2, ''),
|
||||
'Channel 2',
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
21
test/providers/connection_provider_channel_slot_test.dart
Normal file
21
test/providers/connection_provider_channel_slot_test.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_sar_app/providers/connection_provider.dart';
|
||||
|
||||
void main() {
|
||||
group('ConnectionProvider channel slot occupancy', () {
|
||||
test('treats non-zero secret as configured', () {
|
||||
expect(
|
||||
ConnectionProvider.channelHasConfiguredSecret(Uint8List(16)),
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
ConnectionProvider.channelHasConfiguredSecret(
|
||||
Uint8List.fromList([1, ...List<int>.filled(15, 0)]),
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -39,6 +39,46 @@ Message _buildDirectMessage(String id) {
|
||||
);
|
||||
}
|
||||
|
||||
Message _buildSentChannelMessage({
|
||||
required String id,
|
||||
required int senderTimestamp,
|
||||
String text = 'broadcast',
|
||||
int channelIdx = 0,
|
||||
}) {
|
||||
return Message(
|
||||
id: id,
|
||||
messageType: MessageType.channel,
|
||||
senderPublicKeyPrefix: Uint8List.fromList([0, 1, 2, 3, 4, 5]),
|
||||
channelIdx: channelIdx,
|
||||
pathLen: 0,
|
||||
textType: MessageTextType.plain,
|
||||
senderTimestamp: senderTimestamp,
|
||||
text: text,
|
||||
receivedAt: DateTime.now(),
|
||||
deliveryStatus: MessageDeliveryStatus.sending,
|
||||
);
|
||||
}
|
||||
|
||||
Message _buildReceivedChannelReplay({
|
||||
required String id,
|
||||
required int senderTimestamp,
|
||||
String text = 'broadcast',
|
||||
int channelIdx = 0,
|
||||
String senderName = 'Radio Alpha',
|
||||
}) {
|
||||
return Message(
|
||||
id: id,
|
||||
messageType: MessageType.channel,
|
||||
channelIdx: channelIdx,
|
||||
pathLen: 1,
|
||||
textType: MessageTextType.plain,
|
||||
senderTimestamp: senderTimestamp,
|
||||
text: text,
|
||||
senderName: senderName,
|
||||
receivedAt: DateTime.now(),
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
@@ -124,18 +164,7 @@ void main() {
|
||||
test('channel messages are marked sent immediately', () {
|
||||
final provider = MessagesProvider();
|
||||
provider.addSentMessage(
|
||||
Message(
|
||||
id: 'c1',
|
||||
messageType: MessageType.channel,
|
||||
senderPublicKeyPrefix: Uint8List.fromList([0, 1, 2, 3, 4, 5]),
|
||||
channelIdx: 0,
|
||||
pathLen: 0,
|
||||
textType: MessageTextType.plain,
|
||||
senderTimestamp: 1700000000,
|
||||
text: 'broadcast',
|
||||
receivedAt: DateTime.now(),
|
||||
deliveryStatus: MessageDeliveryStatus.sending,
|
||||
),
|
||||
_buildSentChannelMessage(id: 'c1', senderTimestamp: 1700000000),
|
||||
);
|
||||
|
||||
provider.markMessageSent('c1', 0, 0);
|
||||
@@ -146,6 +175,51 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'channel replay is deduped after raw echo detection confirms our send',
|
||||
() {
|
||||
final provider = MessagesProvider();
|
||||
provider.addSentMessage(
|
||||
_buildSentChannelMessage(id: 'c-echo', senderTimestamp: 1700000100),
|
||||
);
|
||||
provider.markMessageSent('c-echo', 0, 0);
|
||||
provider.handleMessageEcho('c-echo', 1, 12, -90);
|
||||
|
||||
provider.addMessage(
|
||||
_buildReceivedChannelReplay(
|
||||
id: 'c-echo-incoming',
|
||||
senderTimestamp: 1700000100,
|
||||
),
|
||||
);
|
||||
|
||||
expect(provider.messages, hasLength(1));
|
||||
expect(provider.messages.single.id, equals('c-echo'));
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'channel replay is not deduped before raw echo detection confirms it',
|
||||
() {
|
||||
final provider = MessagesProvider();
|
||||
provider.addSentMessage(
|
||||
_buildSentChannelMessage(
|
||||
id: 'c-no-echo',
|
||||
senderTimestamp: 1700000200,
|
||||
),
|
||||
);
|
||||
provider.markMessageSent('c-no-echo', 0, 0);
|
||||
|
||||
provider.addMessage(
|
||||
_buildReceivedChannelReplay(
|
||||
id: 'c-no-echo-incoming',
|
||||
senderTimestamp: 1700000200,
|
||||
),
|
||||
);
|
||||
|
||||
expect(provider.messages, hasLength(2));
|
||||
},
|
||||
);
|
||||
|
||||
test('missing ACK schedules a delayed retransmission', () {
|
||||
fakeAsync((async) {
|
||||
final provider = MessagesProvider();
|
||||
|
||||
@@ -89,7 +89,7 @@ void main() {
|
||||
unreadCount: 0,
|
||||
unreadCountsByPublicKey: const {},
|
||||
showAllOption: false,
|
||||
onSelect: (_, __) {},
|
||||
onSelect: (selectedRecipient, draftMessage) {},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user