Commit 2f8ef5b
authored
fix: deflake //rs/registry/canister:registry_canister_integration_test_tests/rate_limits (#9172)
## Root Cause
The test uses `.with_current_time()` to set the state machine's clock to
`SystemTime::now()` at build time. However, `prepare_add_node_payload`
generates TLS certificates using the real system clock (via
`generate_node_keys_once`). The CSP vault sets the certificate's
`notBefore` to `system_time - 2_minutes`.
As the test runs its loop of 70 add/remove node iterations (~2 minutes
of wall-clock time), the real system time advances while the state
machine's time drifts behind. When the registry canister validates the
TLS certificate, it compares the cert's `notBefore` against the state
machine's time. If the state machine's time has fallen far enough behind
the system time that `system_time - 2min > state_machine_time`, the
validation fails with:
```
invalid TLS certificate: notBefore date is in the future compared to current time
```
All 11 flaky failures in the past week show this exact pattern — the
`notBefore` is 1–5 seconds ahead of the state machine's clock.
## Fix
Call `env.set_time(SystemTime::now())` before each `add_node` call to
resync the state machine's clock with the system clock. This is a
well-established pattern used in other state machine tests (e.g.,
`gtc.rs`, `node_provider_remuneration.rs`).
---
This PR was created following the steps in
`.claude/skills/fix-flaky-tests/SKILL.md`.1 parent 66db527 commit 2f8ef5b
1 file changed
+7
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
73 | 79 | | |
74 | 80 | | |
75 | 81 | | |
| |||
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| 103 | + | |
97 | 104 | | |
98 | 105 | | |
99 | 106 | | |
| |||
0 commit comments