From 2e594f041dac472cb4cd7bc339b308d6736fd547 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Fri, 16 Oct 2026 14:55:26 +0200 Subject: [PATCH] phone: pin the clock in the stageLocalSettings enforcement test The test staged a 2026-10-01 event through stageLocalSettings, which called stageEnforcementData on the real clock; on 2026-10-16 the event aged past boundEvents' 14-day window and the test went red for everyone. stageLocalSettings now forwards an optional `now` to stageEnforcementData (callers unchanged), and the test passes its fixed clock. phone_app suite: 402 passed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Xfj1sxKH9VBPqpcAni8Jry --- phone_app/lib/services/settings_sync.dart | 7 +++++-- phone_app/test/services/enforcement_sync_test.dart | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/phone_app/lib/services/settings_sync.dart b/phone_app/lib/services/settings_sync.dart index 7028a8a..6b4d529 100644 --- a/phone_app/lib/services/settings_sync.dart +++ b/phone_app/lib/services/settings_sync.dart @@ -53,7 +53,10 @@ String stampOf(Hlc hlc) => DateTime.fromMillisecondsSinceEpoch( /// unless it holds a value from before stamps existed, which goes in at /// [_legacyMs] so it is kept when nothing else is known and loses to any /// stamped peer. -Future stageLocalSettings(AlarmSyncService service) async { +Future stageLocalSettings( + AlarmSyncService service, { + DateTime Function()? now, +}) async { final tags = await RoomProofSettings.load(); await stageField( service, @@ -72,7 +75,7 @@ Future stageLocalSettings(AlarmSyncService service) async { ); await _stageEarned(service); await stageSessionData(service); - await stageEnforcementData(service); + await stageEnforcementData(service, now: now); } /// Pushes the union of the local and logged earned dates when it is new. diff --git a/phone_app/test/services/enforcement_sync_test.dart b/phone_app/test/services/enforcement_sync_test.dart index fa41579..f6867f7 100644 --- a/phone_app/test/services/enforcement_sync_test.dart +++ b/phone_app/test/services/enforcement_sync_test.dart @@ -73,7 +73,9 @@ void main() { ..events.add(_event(DateTime(2026, 10, 1, 7, 15), 'lockdown_sent')); final service = await _open(); - await stageLocalSettings(service); + // The clock is pinned: on the real one the 2026-10-01 event aged past + // boundEvents' 14-day window on 2026-10-16 and the test went red. + await stageLocalSettings(service, now: () => now); expect(service.field(ringStartedField)?.$1, ring); final escapes = service.field(escapesField)!;