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:
Zach committed 2026-09-25 10:01:18 -07:00
1 parent d5f54dfa11
commit d74587c167
105 files changed
+6419 -2072

No files matched your search

+1 -2
View File
@@ -40,7 +40,7 @@ class PathHelper {
) {
if (pathBytes.isEmpty) return const [];
final width = hashByteWidth.clamp(1, 4).toInt();
final width = hashByteWidth.clamp(1, 3).toInt();
final hops = <Uint8List>[];
for (int i = 0; i < pathBytes.length; i += width) {
final endIdx = (i + width).clamp(0, pathBytes.length).toInt();
@@ -58,7 +58,6 @@ class PathHelper {
/// - 1: Single byte per hop (256 unique nodes)
/// - 2: Two bytes per hop (65K unique nodes)
/// - 3: Three bytes per hop (16M unique nodes)
/// - 4: Four bytes per hop (4.3G unique nodes)
static String resolvePathNames(
List<int> pathBytes,
List<Contact> allContacts,
+1 -1
View File
@@ -14,7 +14,7 @@ class PathHopResolver {
bool resolveFromEnd = false,
int pathHashByteWidth = 1,
}) {
final width = pathHashByteWidth.clamp(1, 4).toInt();
final width = pathHashByteWidth.clamp(1, 3).toInt();
final candidatesByPrefix = <String, List<Contact>>{};
for (final contact in contacts) {
if (contact.publicKey.length < width) continue;
+46 -24
View File
@@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:characters/characters.dart';
import 'package:flutter/services.dart';
class Utf8LengthLimitingTextInputFormatter extends TextInputFormatter {
@@ -19,34 +20,55 @@ class Utf8LengthLimitingTextInputFormatter extends TextInputFormatter {
TextEditingValue newValue,
) {
if (maxBytes <= 0) return oldValue;
if (_effectiveByteLength(newValue.text) <= maxBytes) return newValue;
final newBytes = _effectiveByteLength(newValue.text);
if (newBytes <= maxBytes ||
newBytes <= _effectiveByteLength(oldValue.text)) {
return newValue;
}
final truncated = _truncateToMaxBytes(newValue.text, maxBytes);
final oldText = oldValue.text;
final newText = newValue.text;
var prefix = 0;
while (prefix < oldText.length &&
prefix < newText.length &&
oldText.codeUnitAt(prefix) == newText.codeUnitAt(prefix)) {
prefix++;
}
if (prefix > 0 &&
prefix < newText.length &&
_isLowSurrogate(newText.codeUnitAt(prefix))) {
prefix--;
}
var suffix = 0;
while (suffix < oldText.length - prefix &&
suffix < newText.length - prefix &&
oldText.codeUnitAt(oldText.length - 1 - suffix) ==
newText.codeUnitAt(newText.length - 1 - suffix)) {
suffix++;
}
final suffixStart = newText.length - suffix;
if (suffix > 0 && _isLowSurrogate(newText.codeUnitAt(suffixStart))) {
suffix--;
}
final head = newText.substring(0, prefix);
final tail = newText.substring(newText.length - suffix);
final inserted = newText.substring(prefix, newText.length - suffix);
final kept = StringBuffer();
for (final char in inserted.characters) {
if (_effectiveByteLength('$head$kept$char$tail') > maxBytes) break;
kept.write(char);
}
final cursor = head.length + kept.length;
return TextEditingValue(
text: truncated,
selection: TextSelection.collapsed(offset: truncated.length),
text: '$head$kept$tail',
selection: TextSelection.collapsed(offset: cursor),
composing: TextRange.empty,
);
}
String _truncateToMaxBytes(String text, int limit) {
if (encoder != null) {
final runes = text.runes.toList();
while (runes.isNotEmpty &&
_effectiveByteLength(String.fromCharCodes(runes)) > maxBytes) {
runes.removeLast();
}
return String.fromCharCodes(runes);
}
final buffer = StringBuffer();
var used = 0;
for (final rune in text.runes) {
final char = String.fromCharCode(rune);
final charBytes = utf8.encode(char).length;
if (used + charBytes > limit) break;
buffer.write(char);
used += charBytes;
}
return buffer.toString();
}
bool _isLowSurrogate(int codeUnit) =>
codeUnit >= 0xDC00 && codeUnit <= 0xDFFF;
}