mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-12 11:52:07 +10:00
multi-byte paths
This commit is contained in:
@@ -22,15 +22,52 @@ Contact _contact({
|
||||
}
|
||||
|
||||
void main() {
|
||||
test('resolvePathNames ignores chat nodes and keeps repeater/room nodes', () {
|
||||
test('resolvePathNames ignores chat nodes and keeps repeater/room nodes with 1-byte paths', () {
|
||||
final contacts = [
|
||||
_contact(firstByte: 0xF2, name: 'MunTui', type: advTypeChat),
|
||||
_contact(firstByte: 0x7E, name: 'zrepeater', type: advTypeRepeater),
|
||||
_contact(firstByte: 0xBA, name: 'USS Ronald Reagan', type: advTypeRoom),
|
||||
];
|
||||
|
||||
final resolved = PathHelper.resolvePathNames([0xF2, 0x7E, 0xBA], contacts);
|
||||
final resolved = PathHelper.resolvePathNames(
|
||||
[0xF2, 0x7E, 0xBA],
|
||||
contacts,
|
||||
1, // 1-byte hash width
|
||||
);
|
||||
|
||||
expect(resolved, equals('F2 → zrepeater → USS Ronald Reagan'));
|
||||
});
|
||||
|
||||
test('resolvePathNames supports multi-byte paths', () {
|
||||
final contacts = [
|
||||
_contact(firstByte: 0xA1, name: 'Repeater1', type: advTypeRepeater),
|
||||
_contact(firstByte: 0xC1, name: 'Room42', type: advTypeRoom),
|
||||
];
|
||||
|
||||
// Contacts with 2-byte public keys
|
||||
contacts[0] = Contact(
|
||||
publicKey: Uint8List.fromList([0xA1, 0xA2, ...List.filled(30, 0)]),
|
||||
name: 'Repeater1',
|
||||
type: advTypeRepeater,
|
||||
pathLength: 0,
|
||||
path: Uint8List(0),
|
||||
lastSeen: DateTime.now(),
|
||||
);
|
||||
contacts[1] = Contact(
|
||||
publicKey: Uint8List.fromList([0xC1, 0xC2, ...List.filled(30, 0)]),
|
||||
name: 'Room42',
|
||||
type: advTypeRoom,
|
||||
pathLength: 0,
|
||||
path: Uint8List(0),
|
||||
lastSeen: DateTime.now(),
|
||||
);
|
||||
|
||||
final resolved = PathHelper.resolvePathNames(
|
||||
[0xA1, 0xA2, 0xC1, 0xC2],
|
||||
contacts,
|
||||
2, // 2-byte hash width
|
||||
);
|
||||
|
||||
expect(resolved, equals('Repeater1 → Room42'));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user