Skip to content

Commit

Permalink
internal/jsonrpc2_test: add jsonrpc result no pending[id]
Browse files Browse the repository at this point in the history
  • Loading branch information
a-wing committed Sep 16, 2019
1 parent 87b3d0a commit edbd8c9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions internal/jsonrpc2/jsonrpc2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,32 @@ func TestHeaderCall(t *testing.T) {
}
}

func TestResultsNoPendingID(t *testing.T) {
ctx := context.Background()
result := `{"jsonrpc":"2.0","result":["test"],"id":1}`

aR, bW := io.Pipe()
bR, aW := io.Pipe()

stream := jsonrpc2.NewStream(aR, aW)
run(ctx, t, false, bR, bW)

ch := make(chan int)

go func() {
stream.Write(ctx, []byte(result))
stream.Write(ctx, []byte(result))

ch <- 0
}()

select {
case <-ch:
case <-time.After(time.Second * 1):
t.Fatalf("NoPendingID Blocking")
}
}

func prepare(ctx context.Context, t *testing.T, withHeaders bool) (*jsonrpc2.Conn, *jsonrpc2.Conn) {
aR, bW := io.Pipe()
bR, aW := io.Pipe()
Expand Down

0 comments on commit edbd8c9

Please sign in to comment.