Refactor LoRa airtime tests and add new functionality
- 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.
This commit is contained in:
1 parent
d5f54dfa11
commit
d74587c167
105 files changed
+6419
-2072
No files matched your search
@@ -1,6 +1,35 @@
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/connector/meshcore_connector.dart';
|
||||
import 'package:meshcore_open/models/contact.dart';
|
||||
import 'package:meshcore_open/models/path_selection.dart';
|
||||
import 'package:meshcore_open/services/repeater_command_service.dart';
|
||||
|
||||
class _FakeConnector extends MeshCoreConnector {
|
||||
@override
|
||||
Future<PathSelection> preparePathForContactSend(Contact contact) async =>
|
||||
const PathSelection(pathBytes: [], hopCount: -1, useFlood: true);
|
||||
|
||||
@override
|
||||
Future<void> sendFrame(
|
||||
Uint8List data, {
|
||||
String? channelSendQueueId,
|
||||
bool expectsGenericAck = false,
|
||||
bool waitForGenericAck = false,
|
||||
}) async {}
|
||||
}
|
||||
|
||||
Contact _repeater(int seed) => Contact(
|
||||
publicKey: Uint8List.fromList(List<int>.generate(32, (i) => seed + i)),
|
||||
name: 'R$seed',
|
||||
type: 2,
|
||||
pathLength: -1,
|
||||
path: Uint8List(0),
|
||||
lastSeen: DateTime.now(),
|
||||
);
|
||||
|
||||
void main() {
|
||||
group('normalizeRepeaterClockSyncCommand', () {
|
||||
test('translates "clock sync" to explicit time command', () {
|
||||
@@ -19,7 +48,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('passes other commands through unchanged', () {
|
||||
expect(normalizeRepeaterClockSyncCommand('clock', nowSeconds: 1), 'clock');
|
||||
expect(
|
||||
normalizeRepeaterClockSyncCommand('clock', nowSeconds: 1),
|
||||
'clock',
|
||||
);
|
||||
expect(
|
||||
normalizeRepeaterClockSyncCommand('get radio', nowSeconds: 1),
|
||||
'get radio',
|
||||
@@ -40,4 +72,50 @@ void main() {
|
||||
expect(epoch, inInclusiveRange(before, after));
|
||||
});
|
||||
});
|
||||
|
||||
group('RepeaterCommandService.handleResponse', () {
|
||||
late RepeaterCommandService service;
|
||||
|
||||
setUp(() => service = RepeaterCommandService(_FakeConnector()));
|
||||
tearDown(() => service.dispose());
|
||||
|
||||
test('unknown prefix does not complete the pending command', () async {
|
||||
final repeater = _repeater(1);
|
||||
String? result;
|
||||
unawaited(
|
||||
service
|
||||
.sendCommand(repeater, 'ver', retries: 1)
|
||||
.then((r) => result = r, onError: (_) {}),
|
||||
);
|
||||
await pumpEventQueue();
|
||||
|
||||
service.handleResponse(repeater, 'FE|late reply');
|
||||
await pumpEventQueue();
|
||||
expect(result, isNull);
|
||||
|
||||
service.handleResponse(repeater, '00|v1.0');
|
||||
await pumpEventQueue();
|
||||
expect(result, 'v1.0');
|
||||
});
|
||||
|
||||
test('prefix owned by another repeater is ignored', () async {
|
||||
final a = _repeater(1);
|
||||
final b = _repeater(100);
|
||||
String? result;
|
||||
unawaited(
|
||||
service
|
||||
.sendCommand(a, 'ver', retries: 1)
|
||||
.then((r) => result = r, onError: (_) {}),
|
||||
);
|
||||
await pumpEventQueue();
|
||||
|
||||
service.handleResponse(b, '00|wrong');
|
||||
await pumpEventQueue();
|
||||
expect(result, isNull);
|
||||
|
||||
service.handleResponse(a, 'unprefixed');
|
||||
await pumpEventQueue();
|
||||
expect(result, 'unprefixed');
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user