mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-06-18 00:55:31 +02:00
First wave of work
This commit is contained in:
@@ -60,6 +60,10 @@ describe('parsePathHops', () => {
|
||||
expect(parsePathHops('1A2B3C')).toEqual(['1A', '2B', '3C']);
|
||||
});
|
||||
|
||||
it('parses multi-byte hops when path length is provided', () => {
|
||||
expect(parsePathHops('1A2B3C4D', 2)).toEqual(['1A2B', '3C4D']);
|
||||
});
|
||||
|
||||
it('converts to uppercase', () => {
|
||||
expect(parsePathHops('1a2b')).toEqual(['1A', '2B']);
|
||||
});
|
||||
@@ -197,6 +201,29 @@ describe('resolvePath', () => {
|
||||
expect(result.receiver.prefix).toBe('FF');
|
||||
});
|
||||
|
||||
it('resolves multi-byte hop prefixes when path length is provided', () => {
|
||||
const wideContacts = [
|
||||
createContact({
|
||||
public_key: '1A2B' + 'A'.repeat(60),
|
||||
name: 'WideRepeater1',
|
||||
type: CONTACT_TYPE_REPEATER,
|
||||
}),
|
||||
createContact({
|
||||
public_key: '3C4D' + 'B'.repeat(60),
|
||||
name: 'WideRepeater2',
|
||||
type: CONTACT_TYPE_REPEATER,
|
||||
}),
|
||||
];
|
||||
|
||||
const result = resolvePath('1A2B3C4D', sender, wideContacts, config, 2);
|
||||
|
||||
expect(result.hops).toHaveLength(2);
|
||||
expect(result.hops[0].prefix).toBe('1A2B');
|
||||
expect(result.hops[0].matches[0].name).toBe('WideRepeater1');
|
||||
expect(result.hops[1].prefix).toBe('3C4D');
|
||||
expect(result.hops[1].matches[0].name).toBe('WideRepeater2');
|
||||
});
|
||||
|
||||
it('handles unknown repeaters (no matches)', () => {
|
||||
const result = resolvePath('XX', sender, contacts, config);
|
||||
|
||||
@@ -545,6 +572,15 @@ describe('formatHopCounts', () => {
|
||||
expect(result.hasMultiple).toBe(false);
|
||||
});
|
||||
|
||||
it('uses explicit path_len for multi-byte hop counts', () => {
|
||||
const result = formatHopCounts([
|
||||
{ path: '1A2B3C4D', path_len: 2, received_at: 1700000000 },
|
||||
]);
|
||||
expect(result.display).toBe('2');
|
||||
expect(result.allDirect).toBe(false);
|
||||
expect(result.hasMultiple).toBe(false);
|
||||
});
|
||||
|
||||
it('formats multiple paths sorted by hop count', () => {
|
||||
const result = formatHopCounts([
|
||||
{ path: '1A2B3C', received_at: 1700000000 }, // 3 hops
|
||||
|
||||
Reference in New Issue
Block a user