From 12224c761ff32f01752330b8c23e73740cf618d3 Mon Sep 17 00:00:00 2001 From: nav Date: Thu, 9 Apr 2026 03:33:09 +0000 Subject: [PATCH] test: expand failure and recovery coverage --- TASKLIST.md | 14 +++++++++++--- Yonexus.Client | 2 +- Yonexus.Server | 2 +- tests/failure-path/MATRIX.md | 8 ++++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/TASKLIST.md b/TASKLIST.md index 2161eb5..516a816 100644 --- a/TASKLIST.md +++ b/TASKLIST.md @@ -1109,7 +1109,7 @@ ### YNX-1105 编写失败路径测试矩阵 **状态** -- [x] 持续补齐中,关键路径已覆盖并继续收尾连接/恢复场景(2026-04-09) +- [x] 持续补齐中,关键路径已覆盖并继续收尾剩余少量边界场景(2026-04-09) **进展补充(2026-04-09)** - 基于本轮锁定的 v1 边界,`AF-04` 暂保持未覆盖并标记为“语义待确认”,因为当前实现仍把错误 secret 统一归入 `invalid_signature` @@ -1117,6 +1117,8 @@ - 已补充 `CF-05`:`hello` 缺失 payload 时返回 `MALFORMED_MESSAGE` 且保持连接可继续诊断 - 已补充 `SR-04`:Client 首次运行/无凭证状态会自动补 keypair,并在 `hello_ack(pair_required)` 后进入完整配对流,不需要手工预置 state - 已同步将 `CF-07`(保留字 rule 注册拒绝)在失败路径矩阵里标记为已覆盖,和现有 Client/Server rule registry 测试保持一致 +- 本轮新增 `CF-01` / `CF-02`:补齐 client transport 在网络分区与首次建连失败时的指数退避重连测试 +- 本轮新增 `SR-02`:补齐 server restart 后 active session 不恢复、但 durable trust record 保留且客户端需要重新 hello/auth 的恢复测试 **目标** - 系统性覆盖 pairing/auth 失败路径 @@ -1184,16 +1186,22 @@ - 已新增 `Yonexus.Client/tests/runtime-flow.test.ts`: - SR-04:客户端在无 secret/首次运行状态下启动后可自动进入 `pair_required`,无需手工 bootstrap 本地 state - 已同步更新 `tests/failure-path/MATRIX.md`,标记 CF-05、CF-07、SR-04 为已覆盖 +- 已新增 `Yonexus.Client/tests/transport-reconnect.test.ts` + - CF-02:首次连接失败时按 1s → 2s 指数退避继续重试,成功后恢复 connected + - CF-01:已建立连接在异常 close(network partition)后会按退避策略发起重连 +- 已扩展 `Yonexus.Server/tests/state-recovery.test.ts` + - SR-02:server restart 后不恢复内存 session,保留 durable paired trust,并要求 client 重新 `hello` 后进入 `auth_required` +- 已同步更新 `tests/failure-path/MATRIX.md`,标记 CF-01、CF-02、SR-02 为已覆盖 **当前剩余未覆盖重点** - AF-04:当前实现未单独暴露 `invalid_secret` 分支,需先决定是否保留该错误码语义 - RP-03 / RP-04:管理员主动撤销与 key rotation 语义仍未实现 -- PF-08 / PF-10、CF-01 / CF-02、SR-02 等剩余连接/恢复边界场景测试 +- PF-08 / PF-10 以及少量连接/恢复边界场景仍待补齐 **待完成** - AF-04:当前实现未单独暴露 `invalid_secret` 分支,需先决定是否保留该错误码语义 - RP-03 / RP-04:管理员主动撤销与 key rotation 语义仍未实现 -- PF-08 / PF-10、CF-01 / CF-02 / CF-07、SR-02 / SR-04 等剩余边界场景测试 +- PF-08 / PF-10 等剩余边界场景测试 --- diff --git a/Yonexus.Client b/Yonexus.Client index 9fd9b50..b10ebc5 160000 --- a/Yonexus.Client +++ b/Yonexus.Client @@ -1 +1 @@ -Subproject commit 9fd9b50842080550b93874a8dd2d61afeea49e2a +Subproject commit b10ebc541e874306ec05575ce100c53f017634e1 diff --git a/Yonexus.Server b/Yonexus.Server index e038fb7..b67166f 160000 --- a/Yonexus.Server +++ b/Yonexus.Server @@ -1 +1 @@ -Subproject commit e038fb766680a766446420f44798c04e2b10709e +Subproject commit b67166fd121218f082f8e630d1ed30972cdb9ab6 diff --git a/tests/failure-path/MATRIX.md b/tests/failure-path/MATRIX.md index c48fc92..0e2662b 100644 --- a/tests/failure-path/MATRIX.md +++ b/tests/failure-path/MATRIX.md @@ -61,8 +61,8 @@ This document defines the systematic test coverage for pairing and authenticatio | ID | Scenario | Trigger | Expected Behavior | Status | |----|----------|---------|-------------------|--------| -| CF-01 | Network partition | Connection drops mid-auth | Client retries with backoff | ⬜ | -| CF-02 | Server unreachable | Initial connect fails | Exponential backoff retry | ⬜ | +| CF-01 | Network partition | Connection drops mid-auth | Client retries with backoff | ✅ | +| CF-02 | Server unreachable | Initial connect fails | Exponential backoff retry | ✅ | | CF-03 | Duplicate connection | Same ID connects twice | Old connection closed, new accepted | ✅ | | CF-04 | Protocol version mismatch | Unsupported version | Connection rejected with error | ✅ | | CF-05 | Malformed hello | Invalid payload / missing required hello fields | Error response, connection maintained | ✅ | @@ -87,7 +87,7 @@ This document defines the systematic test coverage for pairing and authenticatio | ID | Scenario | Condition | Expected Recovery | Status | |----|----------|-----------|-------------------|--------| | SR-01 | Server restart with pending pairing | Pairing in progress | Preserve pairing state, code valid | ✅ | -| SR-02 | Server restart with active sessions | Online clients | All marked offline, reconnect required | ⬜ | +| SR-02 | Server restart with active sessions | Online clients | All marked offline, reconnect required | ✅ | | SR-03 | Client restart with credentials | Has secret + keys | Resume with auth, no re-pairing | ✅ | | SR-04 | Client restart without credentials | First run | Full pairing flow required | ✅ | | SR-05 | Corrupted server store | File unreadable | Surface corruption error clearly for operator handling | ✅ | @@ -134,7 +134,7 @@ npm test -- failure-paths - AF-04 (`invalid_secret`) 仍未单独覆盖:现有实现把“错误 secret 导致的验签失败”统一落到 `invalid_signature`,是否拆分错误码仍待确认。 - RP-04(key rotation)当前仍视为 v2+ 议题;v1 尚未承诺“无重配对换 key”语义,因此暂不强行补测试。 -- 本轮已补齐 AF-01/02/03/05/06/09/10/11、RP-01/02、CF-03/04/05/07、HF-01/02、PF-09、SR-01/03/04/05/06。 +- 本轮已补齐 AF-01/02/03/05/06/09/10/11、RP-01/02、CF-01/02/03/04/05/07、HF-01/02、PF-09、SR-01/02/03/04/05/06。 ### Adding New Test Cases