mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-11-22 08:17:28 +00:00
Inject the engine clock in the timeout-restore BLE test
With an unlosable responder deadline, the quarantine in timeoutRestoredSessionDefersQueueDrainUntilConvergence lasts until the test fires the timeout. On a slow runner the real 5 s capability-proof watchdog armed at the setup authentication can then expire inside the quarantine. Its drain takes the parked typed payload, cannot encrypt under a quarantined session and drops it, so the final drain yields two packets instead of three. That failed this branch's first CI run at BLEServiceCoreTests.swift:1022 (`drained`). The test now uses BLEEngineManualScheduler, the pattern this file already uses for engine deadlines, so the watchdog expires only where the test fires it. Verified: holding the quarantine open for 5.5 s reproduces the CI failure without the injected clock and passes with it, and the test still fails when the product ignores the deferral flag.
This commit is contained in:
parent
17477beaa5
commit
be857dec8e
@ -858,8 +858,16 @@ struct BLEServiceCoreTests {
|
||||
// The responder deadline also arms during the setup handshake below,
|
||||
// where a stalled runner would let a short one tear the half-open
|
||||
// responder down. It is unlosable here and fired explicitly.
|
||||
//
|
||||
// The engine clock is injected for the same reason. With an unlosable
|
||||
// deadline the quarantine lasts until this test fires it, and on a
|
||||
// slow runner the real 5s capability-proof watchdog armed at the
|
||||
// setup authentication can expire inside it. Its drain cannot
|
||||
// encrypt under a quarantined session and drops the parked payload,
|
||||
// so the final drain comes up one packet short.
|
||||
let ble = makeService(
|
||||
noiseResponderHandshakeTimeout: TestConstants.unlosableInterval
|
||||
noiseResponderHandshakeTimeout: TestConstants.unlosableInterval,
|
||||
engineScheduler: BLEEngineManualScheduler()
|
||||
)
|
||||
let alice = NoiseEncryptionService(keychain: MockKeychain())
|
||||
let mallory = NoiseEncryptionService(keychain: MockKeychain())
|
||||
@ -959,8 +967,8 @@ struct BLEServiceCoreTests {
|
||||
#expect(outbound.count(ofType: .noiseEncrypted) == 0)
|
||||
|
||||
// The capability-proof watchdog armed at the original authentication
|
||||
// is still live and can genuinely reach its real 5s deadline here on
|
||||
// a stalled CI runner. Fire it deterministically: its drain must
|
||||
// is still live, and on the injected clock it expires only when
|
||||
// fired. Fire it here, while the restore is current: its drain must
|
||||
// respect the deferred-until-convergence state instead of encrypting
|
||||
// the parked queues under the restored keys (the exact silent loss
|
||||
// the defer path exists to prevent). The retry below then still
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user