mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
feat: Improve live traffic packet help #0
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_sar_app/models/channel.dart';
|
||||
import 'package:meshcore_sar_app/providers/channels_provider.dart';
|
||||
|
||||
void main() {
|
||||
@@ -22,4 +23,38 @@ void main() {
|
||||
expect(provider.selectedChannel, isNull);
|
||||
});
|
||||
});
|
||||
|
||||
group('ChannelsProvider mesh hash lookup', () {
|
||||
test('resolves a unique channel display name by hash byte', () {
|
||||
final provider = ChannelsProvider();
|
||||
final channel = Channel.create(index: 3, name: '#ops');
|
||||
|
||||
provider.addOrUpdateChannelObject(channel);
|
||||
|
||||
expect(
|
||||
provider.getUniqueChannelDisplayNameByHashByte(channel.hashByte),
|
||||
'#ops',
|
||||
);
|
||||
});
|
||||
|
||||
test('does not resolve ambiguous hash matches', () {
|
||||
final provider = ChannelsProvider();
|
||||
final secret = Uint8List.fromList(List<int>.filled(16, 7));
|
||||
final firstChannel = Channel.create(
|
||||
index: 1,
|
||||
name: 'Ops 1',
|
||||
explicitSecret: secret,
|
||||
);
|
||||
|
||||
provider.addOrUpdateChannelObject(firstChannel);
|
||||
provider.addOrUpdateChannelObject(
|
||||
Channel.create(index: 2, name: 'Ops 2', explicitSecret: secret),
|
||||
);
|
||||
|
||||
expect(
|
||||
provider.getUniqueChannelDisplayNameByHashByte(firstChannel.hashByte),
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user