Add client core, handshake pending frames, and in-memory Conn tests

This commit is contained in:
robert
2026-01-04 20:39:38 +00:00
parent 786533bbfc
commit ac2d1887a9
5 changed files with 405 additions and 30 deletions

37
conn_test.go Normal file
View File

@@ -0,0 +1,37 @@
package ownwire_sdk_test
import "context"
// sdk_test_inmem_conn is a test-only in-memory Conn implementation.
// It lets tests drive protocol logic deterministically without a real websocket
// or a server.
type sdk_test_inmem_conn struct {
write_ch chan string
read_ch chan string
}
func sdk_test_new_inmem_conn() *sdk_test_inmem_conn {
return &sdk_test_inmem_conn{
write_ch: make(chan string, 16),
read_ch: make(chan string, 16),
}
}
func (c *sdk_test_inmem_conn) WriteText(ctx context.Context, s string) error {
select {
case c.write_ch <- s:
return nil
case <-ctx.Done():
return ctx.Err()
}
}
func (c *sdk_test_inmem_conn) ReadText(ctx context.Context) (string, error) {
select {
case s := <-c.read_ch:
return s, nil
case <-ctx.Done():
return "", ctx.Err()
}
}