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
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
import '../models/delivery_observation.dart';
|
||||
import '../models/path_history.dart';
|
||||
import '../storage/prefs_manager.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
|
||||
class StorageService {
|
||||
static const String _pathHistoryPrefix = 'path_history_';
|
||||
@@ -11,6 +12,14 @@ class StorageService {
|
||||
'repeater_auto_clock_sync_after_login';
|
||||
static const String _deliveryObservationsKey = 'delivery_observations';
|
||||
|
||||
String _publicKeyHex = '';
|
||||
set setPublicKeyHex(String value) =>
|
||||
_publicKeyHex = value.length > 10 ? value.substring(0, 10) : '';
|
||||
|
||||
String _pathHistoryKey(String contactPubKeyHex) => _publicKeyHex.isEmpty
|
||||
? '$_pathHistoryPrefix$contactPubKeyHex'
|
||||
: '$_pathHistoryPrefix${_publicKeyHex}_$contactPubKeyHex';
|
||||
|
||||
Future<Map<String, bool>> _loadRepeaterAutoClockSyncAfterLogin() async {
|
||||
final prefs = PrefsManager.instance;
|
||||
final jsonStr = prefs.getString(_repeaterAutoClockSyncAfterLoginKey);
|
||||
@@ -48,15 +57,18 @@ class StorageService {
|
||||
ContactPathHistory history,
|
||||
) async {
|
||||
final prefs = PrefsManager.instance;
|
||||
final key = '$_pathHistoryPrefix$contactPubKeyHex';
|
||||
final key = _pathHistoryKey(contactPubKeyHex);
|
||||
final jsonStr = jsonEncode(history.toJson());
|
||||
await prefs.setString(key, jsonStr);
|
||||
}
|
||||
|
||||
Future<ContactPathHistory?> loadPathHistory(String contactPubKeyHex) async {
|
||||
final prefs = PrefsManager.instance;
|
||||
final key = '$_pathHistoryPrefix$contactPubKeyHex';
|
||||
final jsonStr = prefs.getString(key);
|
||||
final key = _pathHistoryKey(contactPubKeyHex);
|
||||
// Fall back to the pre-scoping key so learned routes survive the upgrade.
|
||||
final jsonStr =
|
||||
prefs.getString(key) ??
|
||||
prefs.getString('$_pathHistoryPrefix$contactPubKeyHex');
|
||||
|
||||
if (jsonStr == null) return null;
|
||||
|
||||
@@ -70,8 +82,8 @@ class StorageService {
|
||||
|
||||
Future<void> clearPathHistory(String contactPubKeyHex) async {
|
||||
final prefs = PrefsManager.instance;
|
||||
final key = '$_pathHistoryPrefix$contactPubKeyHex';
|
||||
await prefs.remove(key);
|
||||
await prefs.remove(_pathHistoryKey(contactPubKeyHex));
|
||||
await prefs.remove('$_pathHistoryPrefix$contactPubKeyHex');
|
||||
}
|
||||
|
||||
Future<void> clearAllPathHistories() async {
|
||||
@@ -173,14 +185,24 @@ class StorageService {
|
||||
|
||||
if (jsonStr == null) return [];
|
||||
|
||||
final List<dynamic> list;
|
||||
try {
|
||||
final list = jsonDecode(jsonStr) as List;
|
||||
return list
|
||||
.map((e) => DeliveryObservation.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
list = jsonDecode(jsonStr) as List<dynamic>;
|
||||
} catch (e) {
|
||||
appLogger.warn('Stored delivery observations are unreadable: $e');
|
||||
return [];
|
||||
}
|
||||
final observations = <DeliveryObservation>[];
|
||||
for (final e in list) {
|
||||
try {
|
||||
observations.add(
|
||||
DeliveryObservation.fromJson(e as Map<String, dynamic>),
|
||||
);
|
||||
} catch (err) {
|
||||
appLogger.warn('Skipping malformed delivery observation: $err');
|
||||
}
|
||||
}
|
||||
return observations;
|
||||
}
|
||||
|
||||
Future<void> clearDeliveryObservations() async {
|
||||
|
||||
Reference in new issue
Block a user