Skip to content

Commit

Permalink
channel_test: update oversize message test.
Browse files Browse the repository at this point in the history
Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Aug 21, 2024
1 parent 798813b commit e67f276
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,19 @@ func TestReadWriteMessage(t *testing.T) {

func TestMessageOversize(t *testing.T) {
var (
w, r = net.Pipe()
wch, rch = newChannel(w), newChannel(r)
msg = bytes.Repeat([]byte("a message of massive length"), 512<<10)
errs = make(chan error, 1)
w, _ = net.Pipe()
wch = newChannel(w)
msg = bytes.Repeat([]byte("a message of massive length"), 512<<10)
errs = make(chan error, 1)
)

go func() {
if err := wch.send(1, 1, 0, msg); err != nil {
errs <- err
}
errs <- wch.send(1, 1, 0, msg)
}()

_, _, err := rch.recv()
err := <-errs
if err == nil {
t.Fatalf("error expected reading with small buffer")
t.Fatalf("sending oversized message expected to fail")
}

status, ok := status.FromError(err)
Expand All @@ -114,12 +112,4 @@ func TestMessageOversize(t *testing.T) {
if status.Code() != codes.ResourceExhausted {
t.Fatalf("expected grpc status code: %v != %v", status.Code(), codes.ResourceExhausted)
}

select {
case err := <-errs:
if err != nil {
t.Fatal(err)
}
default:
}
}

0 comments on commit e67f276

Please sign in to comment.