mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
run gosimple in gometalinter
This commit is contained in:
parent
286a51bcc0
commit
81974d30d6
13 changed files with 23 additions and 24 deletions
|
@ -9,11 +9,10 @@
|
|||
"deadcode",
|
||||
"goimports",
|
||||
"ineffassign",
|
||||
"megacheck",
|
||||
"misspell",
|
||||
"staticcheck",
|
||||
"structcheck",
|
||||
"unconvert",
|
||||
"unused",
|
||||
"varcheck",
|
||||
"vet"
|
||||
],
|
||||
|
|
|
@ -6,7 +6,7 @@ go get -t ./...
|
|||
if [ ${TESTMODE} == "lint" ]; then
|
||||
go get github.com/alecthomas/gometalinter
|
||||
gometalinter --install
|
||||
gometalinter --deadline=90s --tests ./...
|
||||
gometalinter --deadline=300s --tests ./...
|
||||
fi
|
||||
|
||||
if [ ${TESTMODE} == "unit" ]; then
|
||||
|
|
|
@ -817,8 +817,8 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
|
||||
// RTT is around 1h now.
|
||||
// The formula is (1+1/8) * RTT, so this should be around that number
|
||||
Expect(handler.lossTime.Sub(time.Now())).To(BeNumerically("~", time.Hour*9/8, time.Minute))
|
||||
Expect(handler.GetAlarmTimeout().Sub(time.Now())).To(BeNumerically("~", time.Hour*9/8, time.Minute))
|
||||
Expect(time.Until(handler.lossTime)).To(BeNumerically("~", time.Hour*9/8, time.Minute))
|
||||
Expect(time.Until(handler.GetAlarmTimeout())).To(BeNumerically("~", time.Hour*9/8, time.Minute))
|
||||
|
||||
handler.packetHistory.Front().Value.sendTime = time.Now().Add(-2 * time.Hour)
|
||||
handler.OnAlarm()
|
||||
|
@ -837,7 +837,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
err = handler.ReceivedAck(&wire.AckFrame{LargestAcked: 1, LowestAcked: 1}, 1, protocol.EncryptionUnencrypted, time.Now().Add(time.Hour))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.lossTime.IsZero()).To(BeTrue())
|
||||
Expect(handler.GetAlarmTimeout().Sub(time.Now())).To(BeNumerically("~", handler.computeRTOTimeout(), time.Minute))
|
||||
Expect(time.Until(handler.GetAlarmTimeout())).To(BeNumerically("~", handler.computeRTOTimeout(), time.Minute))
|
||||
|
||||
// This means RTO, so both packets should be lost
|
||||
handler.OnAlarm()
|
||||
|
@ -868,7 +868,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.lossTime.IsZero()).To(BeTrue())
|
||||
handshakeTimeout := handler.computeHandshakeTimeout()
|
||||
Expect(handler.GetAlarmTimeout().Sub(time.Now())).To(BeNumerically("~", handshakeTimeout, time.Minute))
|
||||
Expect(time.Until(handler.GetAlarmTimeout())).To(BeNumerically("~", handshakeTimeout, time.Minute))
|
||||
|
||||
handler.OnAlarm()
|
||||
p := handler.DequeuePacketForRetransmission()
|
||||
|
@ -894,7 +894,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
|
||||
handler.rttStats.UpdateRTT(time.Hour, 0, time.Now())
|
||||
Expect(handler.lossTime.IsZero()).To(BeTrue())
|
||||
Expect(handler.GetAlarmTimeout().Sub(time.Now())).To(BeNumerically("~", handler.computeRTOTimeout(), time.Minute))
|
||||
Expect(time.Until(handler.GetAlarmTimeout())).To(BeNumerically("~", handler.computeRTOTimeout(), time.Minute))
|
||||
|
||||
handler.OnAlarm()
|
||||
p := handler.DequeuePacketForRetransmission()
|
||||
|
|
|
@ -322,7 +322,7 @@ var _ = Describe("Server Crypto Setup", func() {
|
|||
for _, v := range supportedVersions {
|
||||
b := &bytes.Buffer{}
|
||||
utils.BigEndian.WriteUint32(b, uint32(v))
|
||||
Expect(message.Data[TagVER]).To(ContainSubstring(string(b.Bytes())))
|
||||
Expect(message.Data[TagVER]).To(ContainSubstring(b.String()))
|
||||
}
|
||||
Expect(checkedSecure).To(BeTrue())
|
||||
Expect(checkedForwardSecure).To(BeTrue())
|
||||
|
|
|
@ -31,7 +31,7 @@ func (t *Timer) Reset(deadline time.Time) {
|
|||
if !t.t.Stop() && !t.read {
|
||||
<-t.t.C
|
||||
}
|
||||
t.t.Reset(deadline.Sub(time.Now()))
|
||||
t.t.Reset(time.Until(deadline))
|
||||
|
||||
t.read = false
|
||||
t.deadline = deadline
|
||||
|
|
|
@ -243,14 +243,14 @@ var _ = Describe("Header", func() {
|
|||
(&Header{
|
||||
IsLongHeader: true,
|
||||
}).Log()
|
||||
Expect(string(buf.Bytes())).To(ContainSubstring("Long Header"))
|
||||
Expect(buf.String()).To(ContainSubstring("Long Header"))
|
||||
})
|
||||
|
||||
It("logs a Public Header", func() {
|
||||
(&Header{
|
||||
isPublicHeader: true,
|
||||
}).Log()
|
||||
Expect(string(buf.Bytes())).To(ContainSubstring("Public Header"))
|
||||
Expect(buf.String()).To(ContainSubstring("Public Header"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -393,7 +393,7 @@ var _ = Describe("IETF draft Header", func() {
|
|||
ConnectionID: 0xdeadbeef,
|
||||
Version: 0xfeed,
|
||||
}).logHeader()
|
||||
Expect(string(buf.Bytes())).To(ContainSubstring("Long Header{Type: Handshake, ConnectionID: 0xdeadbeef, PacketNumber: 0x1337, Version: 0xfeed}"))
|
||||
Expect(buf.String()).To(ContainSubstring("Long Header{Type: Handshake, ConnectionID: 0xdeadbeef, PacketNumber: 0x1337, Version: 0xfeed}"))
|
||||
})
|
||||
|
||||
It("logs Short Headers containing a connection ID", func() {
|
||||
|
@ -403,7 +403,7 @@ var _ = Describe("IETF draft Header", func() {
|
|||
PacketNumberLen: 4,
|
||||
ConnectionID: 0xdeadbeef,
|
||||
}).logHeader()
|
||||
Expect(string(buf.Bytes())).To(ContainSubstring("Short Header{ConnectionID: 0xdeadbeef, PacketNumber: 0x1337, PacketNumberLen: 4, KeyPhase: 1}"))
|
||||
Expect(buf.String()).To(ContainSubstring("Short Header{ConnectionID: 0xdeadbeef, PacketNumber: 0x1337, PacketNumberLen: 4, KeyPhase: 1}"))
|
||||
})
|
||||
|
||||
It("logs Short Headers with omitted connection ID", func() {
|
||||
|
@ -412,7 +412,7 @@ var _ = Describe("IETF draft Header", func() {
|
|||
PacketNumberLen: 1,
|
||||
OmitConnectionID: true,
|
||||
}).logHeader()
|
||||
Expect(string(buf.Bytes())).To(ContainSubstring("Short Header{ConnectionID: (omitted), PacketNumber: 0x12, PacketNumberLen: 1, KeyPhase: 0}"))
|
||||
Expect(buf.String()).To(ContainSubstring("Short Header{ConnectionID: (omitted), PacketNumber: 0x12, PacketNumberLen: 1, KeyPhase: 0}"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -236,7 +236,7 @@ func (h *Header) logPublicHeader() {
|
|||
}
|
||||
ver := "(unset)"
|
||||
if h.Version != 0 {
|
||||
ver = fmt.Sprintf("%s", h.Version)
|
||||
ver = h.Version.String()
|
||||
}
|
||||
utils.Debugf(" Public Header{ConnectionID: %s, PacketNumber: %#x, PacketNumberLen: %d, Version: %s, DiversificationNonce: %#v}", connID, h.PacketNumber, h.PacketNumberLen, ver, h.DiversificationNonce)
|
||||
}
|
||||
|
|
|
@ -504,7 +504,7 @@ var _ = Describe("Public Header", func() {
|
|||
PacketNumberLen: 6,
|
||||
Version: protocol.Version39,
|
||||
}).logPublicHeader()
|
||||
Expect(string(buf.Bytes())).To(ContainSubstring("Public Header{ConnectionID: 0xdecafbad, PacketNumber: 0x1337, PacketNumberLen: 6, Version: gQUIC 39"))
|
||||
Expect(buf.String()).To(ContainSubstring("Public Header{ConnectionID: 0xdecafbad, PacketNumber: 0x1337, PacketNumberLen: 6, Version: gQUIC 39"))
|
||||
})
|
||||
|
||||
It("logs a Public Header with omitted connection ID", func() {
|
||||
|
@ -514,7 +514,7 @@ var _ = Describe("Public Header", func() {
|
|||
PacketNumberLen: 6,
|
||||
Version: protocol.Version39,
|
||||
}).logPublicHeader()
|
||||
Expect(string(buf.Bytes())).To(ContainSubstring("Public Header{ConnectionID: (omitted)"))
|
||||
Expect(buf.String()).To(ContainSubstring("Public Header{ConnectionID: (omitted)"))
|
||||
})
|
||||
|
||||
It("logs a Public Header without a version", func() {
|
||||
|
@ -523,7 +523,7 @@ var _ = Describe("Public Header", func() {
|
|||
PacketNumber: 0x1337,
|
||||
PacketNumberLen: 6,
|
||||
}).logPublicHeader()
|
||||
Expect(string(buf.Bytes())).To(ContainSubstring("Version: (unset)"))
|
||||
Expect(buf.String()).To(ContainSubstring("Version: (unset)"))
|
||||
})
|
||||
|
||||
It("logs diversification nonces", func() {
|
||||
|
@ -531,7 +531,7 @@ var _ = Describe("Public Header", func() {
|
|||
ConnectionID: 0xdecafbad,
|
||||
DiversificationNonce: []byte{0xba, 0xdf, 0x00, 0x0d},
|
||||
}).logPublicHeader()
|
||||
Expect(string(buf.Bytes())).To(ContainSubstring("DiversificationNonce: []byte{0xba, 0xdf, 0x0, 0xd}"))
|
||||
Expect(buf.String()).To(ContainSubstring("DiversificationNonce: []byte{0xba, 0xdf, 0x0, 0xd}"))
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
@ -100,7 +100,7 @@ var _ = Describe("Packet packer", func() {
|
|||
b := &bytes.Buffer{}
|
||||
f.Write(b, packer.version)
|
||||
Expect(p.frames).To(Equal([]wire.Frame{f}))
|
||||
Expect(p.raw).To(ContainSubstring(string(b.Bytes())))
|
||||
Expect(p.raw).To(ContainSubstring(b.String()))
|
||||
})
|
||||
|
||||
It("stores the encryption level a packet was sealed with", func() {
|
||||
|
|
|
@ -124,7 +124,7 @@ func (s *receiveStream) Read(p []byte) (int, error) {
|
|||
} else {
|
||||
select {
|
||||
case <-s.readChan:
|
||||
case <-time.After(deadline.Sub(time.Now())):
|
||||
case <-time.After(time.Until(deadline)):
|
||||
}
|
||||
}
|
||||
s.mutex.Lock()
|
||||
|
|
|
@ -116,7 +116,7 @@ func (s *sendStream) Write(p []byte) (int, error) {
|
|||
} else {
|
||||
select {
|
||||
case <-s.writeChan:
|
||||
case <-time.After(deadline.Sub(time.Now())):
|
||||
case <-time.After(time.Until(deadline)):
|
||||
}
|
||||
}
|
||||
s.mutex.Lock()
|
||||
|
|
|
@ -483,7 +483,7 @@ var _ = Describe("Session", func() {
|
|||
buf := &bytes.Buffer{}
|
||||
err := (&wire.ConnectionCloseFrame{ErrorCode: qerr.PeerGoingAway}).Write(buf, sess.version)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(mconn.written).To(Receive(ContainSubstring(string(buf.Bytes()))))
|
||||
Expect(mconn.written).To(Receive(ContainSubstring(buf.String())))
|
||||
Expect(sess.Context().Done()).To(BeClosed())
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue