quic: limits on the number of open streams

Honor the peer's max stream limit. New stream creation blocks
until stream quota is available.

Enforce the number of open streams created by the peer.
Send updated stream quota as streams are closed locally.

Remove streams from the conn's set when they are fully closed.

For golang/go#58547

Change-Id: Iff969c5cb8e8e0c6ad91d217a92c38bceabef8ee
Reviewed-on: https://go-review.googlesource.com/c/net/+/524036
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/internal/quic/config_test.go b/internal/quic/config_test.go
index cec57c5..8d67ef0 100644
--- a/internal/quic/config_test.go
+++ b/internal/quic/config_test.go
@@ -10,9 +10,13 @@
 
 func TestConfigTransportParameters(t *testing.T) {
 	const (
-		wantInitialMaxStreamData = int64(2)
+		wantInitialMaxStreamData  = int64(2)
+		wantInitialMaxStreamsBidi = int64(3)
+		wantInitialMaxStreamsUni  = int64(4)
 	)
 	tc := newTestConn(t, clientSide, func(c *Config) {
+		c.MaxBidiRemoteStreams = wantInitialMaxStreamsBidi
+		c.MaxUniRemoteStreams = wantInitialMaxStreamsUni
 		c.StreamReadBufferSize = wantInitialMaxStreamData
 	})
 	tc.handshake()
@@ -29,4 +33,10 @@
 	if got, want := p.initialMaxStreamDataUni, wantInitialMaxStreamData; got != want {
 		t.Errorf("initial_max_stream_data_uni = %v, want %v", got, want)
 	}
+	if got, want := p.initialMaxStreamsBidi, wantInitialMaxStreamsBidi; got != want {
+		t.Errorf("initial_max_stream_data_uni = %v, want %v", got, want)
+	}
+	if got, want := p.initialMaxStreamsUni, wantInitialMaxStreamsUni; got != want {
+		t.Errorf("initial_max_stream_data_uni = %v, want %v", got, want)
+	}
 }