remove unneeded testutils.ComposeAckFrame helper function

This commit is contained in:
Marten Seemann 2021-03-20 09:55:26 +08:00
parent 81d16a9903
commit 7d6be20fdc
3 changed files with 4 additions and 16 deletions

View file

@ -328,8 +328,8 @@ var _ = Describe("MITM test", func() {
// expects hdr from an Initial packet intercepted from client
sendForgedInitialPacketWithAck := func(conn net.PacketConn, remoteAddr net.Addr, hdr *wire.Header) {
// Fake Initial with ACK for packet 2 (unsent)
ackFrame := testutils.ComposeAckFrame(2, 2)
initialPacket := testutils.ComposeInitialPacket(hdr.DestConnectionID, hdr.SrcConnectionID, hdr.Version, hdr.DestConnectionID, []wire.Frame{ackFrame})
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 2, Largest: 2}}}
initialPacket := testutils.ComposeInitialPacket(hdr.DestConnectionID, hdr.SrcConnectionID, hdr.Version, hdr.DestConnectionID, []wire.Frame{ack})
_, err := conn.WriteTo(initialPacket, remoteAddr)
Expect(err).ToNot(HaveOccurred())
}

View file

@ -50,18 +50,6 @@ func ComposeConnCloseFrame() *wire.ConnectionCloseFrame {
}
}
// ComposeAckFrame returns a new Ack Frame that acknowledges all packets between smallest and largest
func ComposeAckFrame(smallest protocol.PacketNumber, largest protocol.PacketNumber) *wire.AckFrame {
ackRange := wire.AckRange{
Smallest: smallest,
Largest: largest,
}
return &wire.AckFrame{
AckRanges: []wire.AckRange{ackRange},
DelayTime: 0,
}
}
// ComposeInitialPacket returns an Initial packet encrypted under key
// (the original destination connection ID) containing specified frames
func ComposeInitialPacket(srcConnID protocol.ConnectionID, destConnID protocol.ConnectionID, version protocol.VersionNumber, key protocol.ConnectionID, frames []wire.Frame) []byte {

View file

@ -2956,8 +2956,8 @@ var _ = Describe("Client Session", func() {
// Illustrates that an injected Initial with an ACK frame for an unsent packet causes
// the connection to immediately break down
It("fails on Initial-level ACK for unsent packet", func() {
ackFrame := testutils.ComposeAckFrame(0, 0)
initialPacket := testutils.ComposeInitialPacket(destConnID, srcConnID, sess.version, destConnID, []wire.Frame{ackFrame})
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 2, Largest: 2}}}
initialPacket := testutils.ComposeInitialPacket(destConnID, srcConnID, sess.version, destConnID, []wire.Frame{ack})
tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any())
Expect(sess.handlePacketImpl(wrapPacket(initialPacket))).To(BeFalse())
})