Routing - Auto routing picks routes by Thompson sampling over faded delivery stats (24 h half-life, capped evidence), weighted by what the radio currently hears; retries prefer a different route; last attempt floods. - Route failures are held until a message's fate is known, so an offline contact no longer wrecks its route history; failing routes are only deleted after a week without a delivery. - Direct (zero-hop) path is a rotation candidate (#643) and a new Direct mode in the routing sheet; history routes are used for repeater logins. - Remove the route-weight sliders the new chooser no longer uses. Chats - Bulk selection in channel chats (spam / not spam / delete / copy) and in the Filtered messages list. - Tapping a search result jumps to the message. - Swipe-to-reply ignores vertical scrolls. - Active conversation follows route lifecycle, so covered chats count unread again. Notifications - Tapping a notification opens its conversation. - Per-conversation coalescing and one alert per queued-message sync. - Monochrome status-bar icon; background service stops when the app is swiped away; stale notifications cleared on radio or slot change. Other - Online map: opaque links and painted dots for dense areas to avoid an Impeller GPU crash; expandable hop list on path maps. - Contact share: clipboard import of shared contacts, "Add again". - Android: enableEdgeToEdge and scrolling-screenshot support. - Translations for all new strings; fix mistranslated routing labels.
79 lines
2.6 KiB
Dart
79 lines
2.6 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:meshcore_open/helpers/contact_share_message.dart';
|
|
|
|
const _hex = '50ba28f599799142622d188469a63f3890d495cdcedd24239052abd364c0283d';
|
|
|
|
void main() {
|
|
test('parses the official example', () {
|
|
final s = parseContactShare('<$_hex:1:CC>')!;
|
|
expect(s.publicKeyHex, _hex);
|
|
expect(s.type, 1);
|
|
expect(s.name, 'CC');
|
|
expect(s.publicKey.length, 32);
|
|
expect(s.shortKey, '50ba28...c0283d');
|
|
final scanned = s.toScannedContact();
|
|
expect(scanned.publicKey, s.publicKey);
|
|
expect(scanned.type, 1);
|
|
expect(scanned.name, 'CC');
|
|
});
|
|
|
|
test('round trip', () {
|
|
final key = Uint8List.fromList(List.generate(32, (i) => i * 7 % 256));
|
|
final text = encodeContactShare(publicKey: key, type: 2, name: ' Hill ');
|
|
final s = parseContactShare(text)!;
|
|
expect(s.publicKey, key);
|
|
expect(s.type, 2);
|
|
expect(s.name, 'Hill');
|
|
});
|
|
|
|
test('encode strips angle brackets and newlines', () {
|
|
final text = encodeContactShare(
|
|
publicKey: Uint8List(32),
|
|
type: 1,
|
|
name: '<a>\nb\r',
|
|
);
|
|
expect(parseContactShare(text)!.name, 'ab');
|
|
});
|
|
|
|
test('uppercase hex is accepted and lowercased', () {
|
|
final s = parseContactShare('<${_hex.toUpperCase()}:3:Room>')!;
|
|
expect(s.publicKeyHex, _hex);
|
|
});
|
|
|
|
test('name may contain colons', () {
|
|
expect(parseContactShare('<$_hex:1:a:b:c>')!.name, 'a:b:c');
|
|
});
|
|
|
|
test('surrounding whitespace is ignored', () {
|
|
expect(parseContactShare(' \n<$_hex:4:S>\n ')!.type, 4);
|
|
});
|
|
|
|
test('rejects bad length, hex, type', () {
|
|
expect(parseContactShare('<${_hex.substring(2)}:1:x>'), isNull);
|
|
expect(parseContactShare('<${_hex}00:1:x>'), isNull);
|
|
expect(parseContactShare('<${"zz${_hex.substring(2)}"}:1:x>'), isNull);
|
|
expect(parseContactShare('<$_hex:0:x>'), isNull);
|
|
expect(parseContactShare('<$_hex:5:x>'), isNull);
|
|
expect(parseContactShare('<$_hex:12:x>'), isNull);
|
|
expect(parseContactShare('<$_hex:a:x>'), isNull);
|
|
});
|
|
|
|
test('token among other words is not a share', () {
|
|
expect(parseContactShare('look <$_hex:1:CC> here'), isNull);
|
|
expect(parseContactShare('<$_hex:1:CC> hi'), isNull);
|
|
expect(parseContactShare('hello'), isNull);
|
|
});
|
|
|
|
test('findContactShare locates a token inside copied text', () {
|
|
final s = findContactShare('Alice: <$_hex:2:Hilltop Rpt>')!;
|
|
expect(s.publicKeyHex, _hex);
|
|
expect(s.type, 2);
|
|
expect(s.name, 'Hilltop Rpt');
|
|
expect(findContactShare('look <$_hex:1:CC> here')!.name, 'CC');
|
|
expect(findContactShare('meshcore://abcdef'), isNull);
|
|
expect(findContactShare('<$_hex:9:x>'), isNull);
|
|
});
|
|
}
|