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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xfj1sxKH9VBPqpcAni8Jry
This commit is contained in:
Krzysztof Rudnicki 2026-10-16 14:55:26 +02:00
parent 7e40bb138c
commit 2e594f041d
2 changed files with 8 additions and 3 deletions

View File

@ -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<void> stageLocalSettings(AlarmSyncService service) async {
Future<void> stageLocalSettings(
AlarmSyncService service, {
DateTime Function()? now,
}) async {
final tags = await RoomProofSettings.load();
await stageField(
service,
@ -72,7 +75,7 @@ Future<void> 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.

View File

@ -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)!;