diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-08 08:47:21 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-08 08:47:21 +0200 |
| commit | c67887f9abbfb726d20d1fa67dca0041a97398bc (patch) | |
| tree | 406696a8d6a86961b993da6612866e816b724925 /internal/eventloop_error_handling_test.go | |
| parent | eca6d22322f99556c77867c11fd5205167af8d98 (diff) | |
task(ior): harden malformed raw-event decoding (task ed7a7a3f)
Diffstat (limited to 'internal/eventloop_error_handling_test.go')
| -rw-r--r-- | internal/eventloop_error_handling_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/eventloop_error_handling_test.go b/internal/eventloop_error_handling_test.go index 8361dea..7f2c572 100644 --- a/internal/eventloop_error_handling_test.go +++ b/internal/eventloop_error_handling_test.go @@ -113,3 +113,34 @@ func TestProcessRawEventUnknownTypeDoesNotPanicAndNotifies(t *testing.T) { t.Fatalf("expected warning notification") } } + +func TestProcessRawEventMalformedKnownTypeDoesNotPanicAndNotifies(t *testing.T) { + el := mustNewEventLoop(t, eventLoopConfig{}) + warnings := make(chan string, 1) + el.warningCb = func(message string) { warnings <- message } + + pairCh := make(chan *event.Pair, 1) + + defer func() { + if r := recover(); r != nil { + t.Fatalf("processRawEvent panicked: %v", r) + } + }() + + el.processRawEvent([]byte{byte(types.ENTER_OPEN_EVENT)}, pairCh) + + select { + case ep := <-pairCh: + t.Fatalf("unexpected event produced: %v", ep) + default: + } + + select { + case msg := <-warnings: + if msg == "" { + t.Fatalf("expected non-empty warning message") + } + default: + t.Fatalf("expected warning notification") + } +} |
