From e1835ba48996bb10534496b2c4222df0e0973f7e Mon Sep 17 00:00:00 2001 From: nav Date: Thu, 9 Apr 2026 01:32:49 +0000 Subject: [PATCH] test: extend failure-path recovery coverage --- TASKLIST.md | 10 ++++++++-- Yonexus.Client | 2 +- Yonexus.Server | 2 +- tests/failure-path/MATRIX.md | 10 +++++----- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/TASKLIST.md b/TASKLIST.md index cf1205c..6063424 100644 --- a/TASKLIST.md +++ b/TASKLIST.md @@ -1093,7 +1093,7 @@ ### YNX-1105 编写失败路径测试矩阵 **状态** -- [x] 部分关键路径已完成,仍有少量尾项(2026-04-09) +- [x] 持续补齐中,关键路径已覆盖并新增恢复场景(2026-04-09) **目标** - 系统性覆盖 pairing/auth 失败路径 @@ -1144,11 +1144,17 @@ - CF-06:未认证 rule message 会关闭连接 - HF-03:认证前心跳会返回 `AUTH_FAILED` - HF-04:无会话心跳会返回 `AUTH_FAILED` +- 已新增 `Yonexus.Server/tests/state-recovery.test.ts` + - SR-01 / PF-09:server restart with pending pairing,验证 pending pairing 与 pairing code 在重启后保留,hello 重新进入 `waiting_pair_confirm` + - SR-05:损坏的 server store 会抛出 `YonexusServerStoreCorruptionError` +- 已扩展 `Yonexus.Client/tests/state-and-rules.test.ts` + - SR-06:损坏的 client state 会抛出 `YonexusClientStateCorruptionError` +- 已同步更新 `tests/failure-path/MATRIX.md`,标记 PF-09、SR-01、SR-05、SR-06 为已覆盖 **待完成** - AF-04:当前实现未单独暴露 `invalid_secret` 分支,需先决定是否保留该错误码语义 - RP 其余触发场景 -- CF / HF / SR 其余边界场景测试(除 CF-06、HF-03、HF-04) +- CF / HF / SR 其余边界场景测试(例如 duplicate connection、version mismatch、server/client restart with active session 等) --- diff --git a/Yonexus.Client b/Yonexus.Client index 65c1f92..93e0987 160000 --- a/Yonexus.Client +++ b/Yonexus.Client @@ -1 +1 @@ -Subproject commit 65c1f92cc13a45f8cd3c03abd46a9d35ec83add0 +Subproject commit 93e09875ecad2a1b9fae9b11ca4fd569710f81af diff --git a/Yonexus.Server b/Yonexus.Server index 3c760fc..5bda184 160000 --- a/Yonexus.Server +++ b/Yonexus.Server @@ -1 +1 @@ -Subproject commit 3c760fc0f42d2a22634f0f84aa5cf493a546185f +Subproject commit 5bda184a8fc50fb5db3c07cc77d6106205315e20 diff --git a/tests/failure-path/MATRIX.md b/tests/failure-path/MATRIX.md index 5f39f95..50ec7d9 100644 --- a/tests/failure-path/MATRIX.md +++ b/tests/failure-path/MATRIX.md @@ -23,7 +23,7 @@ This document defines the systematic test coverage for pairing and authenticatio | PF-06 | Malformed pair_confirm payload | Missing required fields | Protocol error, no state change | ✅ | | PF-07 | Double pairing attempt | Client calls pair_confirm twice | Second attempt rejected if already paired | ✅ | | PF-08 | Pairing during active session | Paired client tries to pair again | Reject, maintain existing trust | ⬜ | -| PF-09 | Server restart during pairing | Server restarts before confirm | Pairing state preserved, code still valid | ⬜ | +| PF-09 | Server restart during pairing | Server restarts before confirm | Pairing state preserved, code still valid | ✅ | | PF-10 | Client restart during pairing | Client restarts before submit | Client must restart pairing flow | ⬜ | --- @@ -86,12 +86,12 @@ 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-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-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 | Clear state, start fresh | ⬜ | -| SR-06 | Corrupted client state | File unreadable | Reset to initial state | ⬜ | +| SR-05 | Corrupted server store | File unreadable | Surface corruption error clearly for operator handling | ✅ | +| SR-06 | Corrupted client state | File unreadable | Surface corruption error clearly for operator handling | ✅ | --- @@ -133,7 +133,7 @@ npm test -- failure-paths ### Current Notes - AF-04 (`invalid_secret`) 仍未单独覆盖:现有实现把“错误 secret 导致的验签失败”统一落到 `invalid_signature`,是否拆分错误码仍待确认。 -- 本轮已补齐 AF-01/02/03/05/06/09/10/11、RP-01、HF-01/02。 +- 本轮已补齐 AF-01/02/03/05/06/09/10/11、RP-01、HF-01/02、PF-09、SR-01、SR-05、SR-06。 ### Adding New Test Cases