fix: Promote confirmed DM paths

This commit is contained in:
Janez T
2026-04-03 10:27:06 +02:00
parent 3e8d4c2d11
commit 7c9dfd6f63
7 changed files with 52 additions and 13 deletions

View File

@@ -207,6 +207,42 @@ void main() {
},
);
test(
'confirmed direct delivery promotes an observed path to learned',
() async {
final service = PathHistoryService();
final contact = _buildContact(
seed: 4,
pathBytes: [0xAA, 0xBB],
hopCount: 2,
hashSize: 1,
);
await service.initialize();
await service.recordReceivedBytePath(contact.publicKeyHex, [
0xBB,
0xAA,
], 1);
await service.recordPathResult(
contact.publicKeyHex,
PathSelection(
mode: PathSelectionMode.directHistorical,
pathBytes: Uint8List.fromList([0xAA, 0xBB]),
hopCount: 2,
hashSize: 1,
),
success: true,
roundTripTimeMs: 150,
);
final history = service.historyFor(contact.publicKeyHex);
expect(history.directPaths, hasLength(1));
expect(history.directPaths.single.source, PathRecordSource.learned);
expect(history.directPaths.single.successCount, 1);
expect(history.directPaths.single.lastRoundTripTimeMs, 150);
},
);
test('clear history removes stored direct paths for one contact', () async {
final service = PathHistoryService();