Remove duplication in test

This commit is contained in:
Mark Spanbroek 2020-10-27 08:45:55 +01:00 committed by markspanbroek
parent dece29fdfa
commit c1d8950ba3
1 changed files with 7 additions and 12 deletions

View File

@ -15,7 +15,7 @@ suite "connection":
datagramLength = 0
ecn = ECN.default
test "performs handshake":
proc performHandshake: tuple[client, server: Connection] =
let client = newClientConnection(zeroAddress, zeroAddress)
datagramLength = client.write(datagram, ecn)
@ -28,21 +28,16 @@ suite "connection":
datagramLength = client.write(datagram, ecn)
server.read(datagram[0..<datagramLength], ecn)
(client, server)
test "performs handshake":
let (client, server) = performHandshake()
check client.isHandshakeCompleted
check server.isHandshakeCompleted
test "opens uni-directional streams":
let client = newClientConnection(zeroAddress, zeroAddress)
datagramLength = client.write(datagram, ecn)
let server = newServerConnection(zeroAddress, zeroAddress, datagram)
server.read(datagram[0..<datagramLength], ecn)
datagramLength = server.write(datagram, ecn)
client.read(datagram[0..<datagramLength], ecn)
datagramLength = client.write(datagram, ecn)
server.read(datagram[0..<datagramLength], ecn)
let (client, _) = performHandshake()
check client.openStream() != client.openStream()