예제 #1
0
        public async Task RemoteGoAwayReasonShouldBeGettableFromTask(
            uint lastStreamId, ErrorCode errc, string debugString)
        {
            var inPipe  = new BufferedPipe(1024);
            var outPipe = new BufferedPipe(1024);

            var res = await ServerStreamTests.StreamCreator.CreateConnectionAndStream(
                StreamState.Open, loggerProvider, inPipe, outPipe);

            var debugData = Encoding.ASCII.GetBytes(debugString);
            await inPipe.WriteGoAway(lastStreamId, errc, debugData);

            var readGoAwayTask = res.conn.RemoteGoAwayReason;

            Assert.True(
                readGoAwayTask == await Task.WhenAny(readGoAwayTask, Task.Delay(200)),
                "Expected to read GoAway data");

            var reason = await readGoAwayTask;

            Assert.Equal(lastStreamId, reason.LastStreamId);
            Assert.Equal(errc, reason.ErrorCode);
            Assert.Equal(debugString,
                         Encoding.ASCII.GetString(
                             reason.DebugData.Array,
                             reason.DebugData.Offset,
                             reason.DebugData.Count));
        }
예제 #2
0
        public async Task ASecondRemoteGoAwayShouldBeIgnored()
        {
            var inPipe  = new BufferedPipe(1024);
            var outPipe = new BufferedPipe(1024);

            var res = await ServerStreamTests.StreamCreator.CreateConnectionAndStream(
                StreamState.Open, loggerProvider, inPipe, outPipe);

            await inPipe.WriteGoAway(0u, ErrorCode.NoError, null);

            await inPipe.WriteGoAway(2u, ErrorCode.InadequateSecurity, null);

            var readGoAwayTask = res.conn.RemoteGoAwayReason;

            Assert.True(
                readGoAwayTask == await Task.WhenAny(readGoAwayTask, Task.Delay(200)),
                "Expected to read GoAway data");

            var reason = await readGoAwayTask;

            Assert.Equal(0u, reason.LastStreamId);
            Assert.Equal(ErrorCode.NoError, reason.ErrorCode);
        }