Skip to content

Commit 7741202

Browse files
tomberganbradfitz
authored andcommitted
http2: nit in TestServer_Push_StateTransitions
Oops: forgot to git commit these nits locally before uploading https://go-review.googlesource.com/34984 Change-Id: I98995ea9f6ecdde731cd298ff54afe5047ae136e Reviewed-on: https://go-review.googlesource.com/34985 Run-TryBot: Tom Bergan <tombergan@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
1 parent 4aaac4b commit 7741202

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

http2/server_push_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ func TestServer_Push_RejectForbiddenHeader(t *testing.T) {
430430
func TestServer_Push_StateTransitions(t *testing.T) {
431431
const body = "foo"
432432

433-
startedPromise := make(chan bool)
434433
gotPromise := make(chan bool)
435434
finishedPush := make(chan bool)
436435

@@ -440,7 +439,6 @@ func TestServer_Push_StateTransitions(t *testing.T) {
440439
if err := w.(http.Pusher).Push("/pushed", nil); err != nil {
441440
t.Errorf("Push error: %v", err)
442441
}
443-
close(startedPromise)
444442
// Don't finish this request until the push finishes so we don't
445443
// nondeterministically interleave output frames with the push.
446444
<-finishedPush
@@ -462,11 +460,15 @@ func TestServer_Push_StateTransitions(t *testing.T) {
462460
t.Fatalf("streamState(2)=%v, want %v", got, want)
463461
}
464462
getSlash(st)
465-
<-startedPromise
463+
// After the PUSH_PROMISE is sent, the stream should be stateHalfClosedRemote.
466464
st.wantPushPromise()
467465
if got, want := st.streamState(2), stateHalfClosedRemote; got != want {
468466
t.Fatalf("streamState(2)=%v, want %v", got, want)
469467
}
468+
// We stall the HTTP handler for "/pushed" until the above check. If we don't
469+
// stall the handler, then the handler might write HEADERS and DATA and finish
470+
// the stream before we check st.streamState(2) -- should that happen, we'll
471+
// see stateClosed and fail the above check.
470472
close(gotPromise)
471473
st.wantHeaders()
472474
if df := st.wantData(); !df.StreamEnded() {

0 commit comments

Comments
 (0)