- Updated LoRa airtime calculations in `lora_airtime_test.dart` to reflect new reference values. - Introduced new tests for LDRO behavior and preamble symbol calculations. - Added `contact_path_width_test.dart` to validate path hash width handling in contacts. - Enhanced `model_changes_test.dart` to ensure legacy data migration works correctly. - Created `remote_node_stats_test.dart` to decode and validate remote node statistics. - Implemented `map_marker_parse_test.dart` for parsing marker text with coordinate validation. - Developed `map_tile_cache_key_test.dart` to ensure API keys are excluded from cache keys. - Added `message_retry_failure_test.dart` to test message retry service behavior on failures. - Extended `path_history_service_test.dart` to preserve learned state across path attempts. - Enhanced `received_image_store_test.dart` to handle concurrent writes and review fixes. - Implemented `repeater_command_service_test.dart` to validate command response handling. - Created `store_tolerant_parsing_test.dart` to ensure stores skip malformed records gracefully. - Cleared untranslated JSON file for localization updates.
67 lines
2.1 KiB
Dart
67 lines
2.1 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:meshcore_open/models/remote_node_stats.dart';
|
|
|
|
Uint8List _frame(int statsSize, void Function(ByteData stats) fill) {
|
|
final frame = Uint8List(RemoteNodeStats.payloadOffset + statsSize);
|
|
fill(ByteData.sublistView(frame, RemoteNodeStats.payloadOffset));
|
|
return frame;
|
|
}
|
|
|
|
void _fillCommon(ByteData d) {
|
|
d.setUint16(0, 4100, Endian.little);
|
|
d.setInt16(4, -110, Endian.little);
|
|
d.setUint32(16, 300, Endian.little);
|
|
d.setUint32(20, 3600, Endian.little);
|
|
d.setInt16(42, -22, Endian.little);
|
|
d.setUint16(46, 9, Endian.little);
|
|
}
|
|
|
|
void main() {
|
|
test('decodes repeater stats with rx airtime and recv errors', () {
|
|
final frame = _frame(56, (d) {
|
|
_fillCommon(d);
|
|
d.setUint32(48, 120, Endian.little);
|
|
d.setUint32(52, 7, Endian.little);
|
|
});
|
|
final stats = RemoteNodeStats.tryParse(frame, isRoom: false)!;
|
|
expect(stats.batteryMv, 4100);
|
|
expect(stats.noiseFloor, -110);
|
|
expect(stats.txAirSecs, 300);
|
|
expect(stats.uptimeSecs, 3600);
|
|
expect(stats.lastSnr, -5.5);
|
|
expect(stats.floodDups, 9);
|
|
expect(stats.rxAirSecs, 120);
|
|
expect(stats.recvErrors, 7);
|
|
expect(stats.posted, isNull);
|
|
});
|
|
|
|
test('older repeater frame without recv errors', () {
|
|
final frame = _frame(52, (d) {
|
|
_fillCommon(d);
|
|
d.setUint32(48, 120, Endian.little);
|
|
});
|
|
final stats = RemoteNodeStats.tryParse(frame, isRoom: false)!;
|
|
expect(stats.rxAirSecs, 120);
|
|
expect(stats.recvErrors, isNull);
|
|
});
|
|
|
|
test('decodes room server posted / pushed counters', () {
|
|
final frame = _frame(52, (d) {
|
|
_fillCommon(d);
|
|
d.setUint16(48, 42, Endian.little);
|
|
d.setUint16(50, 17, Endian.little);
|
|
});
|
|
final stats = RemoteNodeStats.tryParse(frame, isRoom: true)!;
|
|
expect(stats.posted, 42);
|
|
expect(stats.postPushes, 17);
|
|
expect(stats.rxAirSecs, isNull);
|
|
expect(stats.recvErrors, isNull);
|
|
});
|
|
|
|
test('rejects frames shorter than the common layout', () {
|
|
expect(RemoteNodeStats.tryParse(Uint8List(50), isRoom: false), isNull);
|
|
});
|
|
}
|