rttstats: don't set initial RTT after having obtained a measurement (#3852)

This commit is contained in:
Marten Seemann 2023-05-28 15:09:25 +03:00 committed by GitHub
parent cb3453db25
commit 02013caaa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -154,4 +154,14 @@ var _ = Describe("RTT stats", func() {
Expect(rttStats.SmoothedRTT()).To(Equal(200 * time.Millisecond))
Expect(rttStats.MeanDeviation()).To(Equal(100 * time.Millisecond))
})
It("doesn't restore the RTT if we already have a measurement", func() {
const rtt = 10 * time.Millisecond
rttStats.UpdateRTT(rtt, 0, time.Now())
Expect(rttStats.LatestRTT()).To(Equal(rtt))
Expect(rttStats.SmoothedRTT()).To(Equal(rtt))
rttStats.SetInitialRTT(time.Minute)
Expect(rttStats.LatestRTT()).To(Equal(rtt))
Expect(rttStats.SmoothedRTT()).To(Equal(rtt))
})
})