test(bond/server): покрыть reorder, pending drain, lane churn

Добавляет server_test.go с 6 юнит-тестами для registry bond-сервера: reorder
data-фреймов не по порядку в backend, drain pending-map при приходе пропущенного
seq, round-robin запись по lane, lane churn (сбойный lane выкинут, выживший
продолжает), all-lanes-fail возвращает исходную ошибку, dedup + cleanup registry.

Вводит небольшой интерфейс laneStream (io.Reader+Writer+SetDeadline) на
serverLane, чтобы тесты инжектили in-memory фейки без запуска реальной
smux-сессии. *smux.Stream его удовлетворяет, так что HandleStreamAfterMagic и
on-wire поведение не изменены.
This commit is contained in:
samosvalishe committed 2026-05-19 16:14:40 +03:00
1 parent dc2e4135aa
commit 75471c6fdc
2 files changed
+283 -1

No files matched your search

+10 -1
View File
@@ -16,6 +16,15 @@ import (
"github.com/xtaci/smux"
)
// laneStream is the subset of *smux.Stream that serverLane needs. Defined as
// an interface so unit tests can inject in-memory pipes without spinning up a
// real smux session.
type laneStream interface {
io.Reader
io.Writer
SetDeadline(time.Time) error
}
// Deps groups host-process dependencies needed by the bond server.
type Deps struct {
Debug bool
@@ -107,7 +116,7 @@ func (r *Registry) get(ctx context.Context, id uint64, connectAddr string) *serv
type serverLane struct {
index uint16
stream *smux.Stream
stream laneStream
mu sync.Mutex
}