Merge pull request #639 from lucas-clemente/improve-drop-tests

Improve drop test scopes
This commit is contained in:
Lucas Clemente
2017-06-06 13:16:05 +02:00
committed by GitHub

View File

@@ -49,22 +49,25 @@ var _ = Describe("Drop Proxy", func() {
Expect(proxy.Close()).To(Succeed()) Expect(proxy.Close()).To(Succeed())
}) })
for i := range protocol.SupportedVersions { Context("after the crypto handshake", func() {
version := protocol.SupportedVersions[i] for i := range protocol.SupportedVersions {
version := protocol.SupportedVersions[i]
Context(fmt.Sprintf("with quic version %d", version), func() { Context(fmt.Sprintf("with quic version %d", version), func() {
dropTests(4, 1, runDropTest, version) dropTests("dropping every 4th packet", 4, 1, runDropTest, version)
dropTests(100, 10, runDropTest, version) dropTests("dropping 10 packets every 100 packets", 100, 10, runDropTest, version)
}) })
} }
})
}) })
func dropTests( func dropTests(
context string,
interval protocol.PacketNumber, interval protocol.PacketNumber,
dropInARow protocol.PacketNumber, dropInARow protocol.PacketNumber,
runDropTest func(dropCallback quicproxy.DropCallback, version protocol.VersionNumber), runDropTest func(dropCallback quicproxy.DropCallback, version protocol.VersionNumber),
version protocol.VersionNumber) { version protocol.VersionNumber) {
Context("dropping multiple packets after the crypto handshake", func() { Context(context, func() {
dropper := func(p protocol.PacketNumber) bool { dropper := func(p protocol.PacketNumber) bool {
if p <= 10 { // don't interfere with the crypto handshake if p <= 10 { // don't interfere with the crypto handshake
return false return false
@@ -77,6 +80,7 @@ func dropTests(
return d == quicproxy.DirectionOutgoing && dropper(p) return d == quicproxy.DirectionOutgoing && dropper(p)
}, version) }, version)
}) })
It("gets a file when many incoming packets are dropped", func() { It("gets a file when many incoming packets are dropped", func() {
runDropTest(func(d quicproxy.Direction, p protocol.PacketNumber) bool { runDropTest(func(d quicproxy.Direction, p protocol.PacketNumber) bool {
return d == quicproxy.DirectionIncoming && dropper(p) return d == quicproxy.DirectionIncoming && dropper(p)