Review fixes: - Keep stored message history beyond the 200-message window; stop messages leaking between radios; reset link/session state on disconnect - Accept firmware's 176-byte RX frames over USB/TCP - Hold APP_START during contact sync; contact-sync watchdog; replay DMs from not-yet-known senders; tombstone late command replies; finish channel sync on ERR_NOT_FOUND; fail region-scoped sends cleanly - DM retry watchdog when RESP_CODE_SENT never arrives; late repeater CLI replies; ACK hash collisions; UTF-8-safe name truncation - Image pipeline: delete-during-decode, lifecycle cancels, decoder memory release, entry cap, dead worker recovery, atomic model writes - Storage: deterministic reaction hash across web/native, Smaz double-decode, per-entry parsing, per-radio path history and regions, review-mode data isolation - UI: safe channel slot selection, byte-length name limits, double-send guard, mounted checks, localized hardcoded strings - Skip persisted-store reload on repeat SELF_INFO Features: - Radio default flood scope (firmware ver 11+) and explicit unscoped sends (ver 12+) - Scan for nearby nodes (#570) - Optional distinct first-hop repeater counting for channel resend (#589) - Optional region next to hop count (#580) Issues: - Message text follows system font size (#569) - Repeater/room password field accepts 20 chars (#576) - TCP auto-reconnect and keepalive (#571) - Order feeds by local receive time; flag future timestamps (#584) - Coding rate help text (#568), French "Favoris" (#575) - iOS/macOS app badge now clears Translations for all new strings in every locale.
143 lines
3.6 KiB
Dart
143 lines
3.6 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:meshcore_open/helpers/channel_resend_coverage.dart';
|
|
import 'package:meshcore_open/models/app_settings.dart';
|
|
import 'package:meshcore_open/models/channel_message.dart';
|
|
|
|
ChannelMessage _echoed(
|
|
List<List<int>> paths, {
|
|
int width = 1,
|
|
int? pathLength,
|
|
}) {
|
|
final variants = [for (final p in paths) Uint8List.fromList(p)];
|
|
return ChannelMessage(
|
|
senderName: 'me',
|
|
text: 'hello',
|
|
timestamp: DateTime(2026, 10, 11),
|
|
isOutgoing: true,
|
|
pathHashWidth: width,
|
|
pathLength:
|
|
pathLength ??
|
|
variants.fold<int>(
|
|
0,
|
|
(m, p) => p.length ~/ width > m ? p.length ~/ width : m,
|
|
),
|
|
pathBytes: variants.isEmpty ? null : variants.first,
|
|
pathVariants: variants,
|
|
);
|
|
}
|
|
|
|
void main() {
|
|
group('channelResendSatisfied', () {
|
|
test('two distinct first-hop repeaters satisfy N=2 only when on', () {
|
|
final message = _echoed([
|
|
[0xAA],
|
|
[0xBB],
|
|
]);
|
|
expect(
|
|
channelResendSatisfied(
|
|
message,
|
|
minHops: 2,
|
|
countDistinctRepeaters: false,
|
|
),
|
|
isFalse,
|
|
);
|
|
expect(
|
|
channelResendSatisfied(
|
|
message,
|
|
minHops: 2,
|
|
countDistinctRepeaters: true,
|
|
),
|
|
isTrue,
|
|
);
|
|
});
|
|
|
|
test('the same repeater heard twice does not count twice', () {
|
|
final message = _echoed([
|
|
[0xAA],
|
|
[0xAA],
|
|
]);
|
|
expect(distinctFirstHopRepeaters(message), {'aa'});
|
|
expect(
|
|
channelResendSatisfied(
|
|
message,
|
|
minHops: 2,
|
|
countDistinctRepeaters: true,
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
|
|
test('consecutive hops still satisfy with the toggle off', () {
|
|
final message = _echoed([
|
|
[0xAA, 0xCC],
|
|
]);
|
|
expect(
|
|
channelResendSatisfied(
|
|
message,
|
|
minHops: 2,
|
|
countDistinctRepeaters: false,
|
|
),
|
|
isTrue,
|
|
);
|
|
});
|
|
|
|
test('first hop uses the path hash width', () {
|
|
// Same first byte, different 2-byte hashes: two distinct repeaters.
|
|
final message = _echoed([
|
|
[0xAA, 0x01],
|
|
[0xAA, 0x02],
|
|
], width: 2);
|
|
expect(distinctFirstHopRepeaters(message), {'aa01', 'aa02'});
|
|
});
|
|
|
|
test('our own key prefix and zero-hop echoes are ignored', () {
|
|
final self = Uint8List.fromList(List.filled(32, 0x11));
|
|
final message = _echoed([
|
|
[0x11],
|
|
[0xAA],
|
|
[],
|
|
], pathLength: 1);
|
|
expect(distinctFirstHopRepeaters(message, selfPublicKey: self), {'aa'});
|
|
expect(
|
|
channelResendSatisfied(
|
|
message,
|
|
minHops: 2,
|
|
countDistinctRepeaters: true,
|
|
selfPublicKey: self,
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
|
|
test('an unechoed message is not satisfied', () {
|
|
final message = _echoed([]);
|
|
expect(
|
|
channelResendSatisfied(
|
|
message,
|
|
minHops: 1,
|
|
countDistinctRepeaters: true,
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
});
|
|
|
|
group('channelMinHopsCountRepeaters setting', () {
|
|
test('defaults off, including for old saved settings', () {
|
|
expect(AppSettings().channelMinHopsCountRepeaters, isFalse);
|
|
expect(AppSettings.fromJson({}).channelMinHopsCountRepeaters, isFalse);
|
|
});
|
|
|
|
test('round-trips through JSON and copyWith', () {
|
|
final on = AppSettings().copyWith(channelMinHopsCountRepeaters: true);
|
|
expect(on.channelMinHopsCountRepeaters, isTrue);
|
|
expect(
|
|
AppSettings.fromJson(on.toJson()).channelMinHopsCountRepeaters,
|
|
isTrue,
|
|
);
|
|
});
|
|
});
|
|
}
|