mirror of https://github.com/status-im/nim-eth.git
fix XDeclaredButNotUsed warnings in tests/ (#645)
This commit is contained in:
parent
4b00b230d0
commit
957d8491af
|
@ -17,7 +17,7 @@ p2pProtocol eth(version = 63,
|
||||||
let
|
let
|
||||||
network = peer.network
|
network = peer.network
|
||||||
|
|
||||||
let m = await peer.status(63,
|
discard await peer.status(63,
|
||||||
network.networkId,
|
network.networkId,
|
||||||
0.u256,
|
0.u256,
|
||||||
Hash256(),
|
Hash256(),
|
||||||
|
|
|
@ -13,7 +13,7 @@ import
|
||||||
|
|
||||||
suite "Discovery v5 Tests":
|
suite "Discovery v5 Tests":
|
||||||
setup:
|
setup:
|
||||||
let rng = newRng()
|
let rng {.used.} = newRng()
|
||||||
|
|
||||||
asyncTest "GetNode":
|
asyncTest "GetNode":
|
||||||
# TODO: This could be tested in just a routing table only context
|
# TODO: This could be tested in just a routing table only context
|
||||||
|
|
|
@ -400,9 +400,9 @@ procSuite "Utp protocol over udp tests":
|
||||||
let bytesToTransfer2 = rng[].generateBytes(1000)
|
let bytesToTransfer2 = rng[].generateBytes(1000)
|
||||||
let bytesToTransfer3 = rng[].generateBytes(1000)
|
let bytesToTransfer3 = rng[].generateBytes(1000)
|
||||||
|
|
||||||
let w1 = await s.clientSocket.write(bytesToTransfer1)
|
discard await s.clientSocket.write(bytesToTransfer1)
|
||||||
let w2 = await s.clientSocket.write(bytesToTransfer2)
|
discard await s.clientSocket.write(bytesToTransfer2)
|
||||||
let w3 = await s.clientSocket.write(bytesToTransfer3)
|
discard await s.clientSocket.write(bytesToTransfer3)
|
||||||
await s.clientSocket.closeWait()
|
await s.clientSocket.closeWait()
|
||||||
|
|
||||||
let readData = await s.serverSocket.read()
|
let readData = await s.serverSocket.read()
|
||||||
|
|
|
@ -194,7 +194,7 @@ procSuite "Utp protocol over udp tests with loss and delays":
|
||||||
let smallBytes = 10
|
let smallBytes = 10
|
||||||
let smallBytesToTransfer = rng[].generateBytes(smallBytes)
|
let smallBytesToTransfer = rng[].generateBytes(smallBytes)
|
||||||
# first transfer and read to make server socket connected
|
# first transfer and read to make server socket connected
|
||||||
let write1 = await clientSocket.write(smallBytesToTransfer)
|
discard await clientSocket.write(smallBytesToTransfer)
|
||||||
let read1 = await serverSocket.read(smallBytes)
|
let read1 = await serverSocket.read(smallBytes)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
|
|
@ -270,7 +270,7 @@ procSuite "Utp router unit tests":
|
||||||
let router = UtpRouter[int].new(registerIncomingSocketCallback(q), SocketConfig.init(), rng)
|
let router = UtpRouter[int].new(registerIncomingSocketCallback(q), SocketConfig.init(), rng)
|
||||||
router.sendCb = initTestSnd(pq)
|
router.sendCb = initTestSnd(pq)
|
||||||
|
|
||||||
let (outgoingSocket, initialSyn) = router.connectOutgoing(testSender2, pq, 30'u16)
|
let (outgoingSocket, _) = router.connectOutgoing(testSender2, pq, 30'u16)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
outgoingSocket.isConnected()
|
outgoingSocket.isConnected()
|
||||||
|
@ -286,7 +286,7 @@ procSuite "Utp router unit tests":
|
||||||
let requestedConnectionId = 1'u16
|
let requestedConnectionId = 1'u16
|
||||||
let connectFuture = router.connectTo(testSender2, requestedConnectionId)
|
let connectFuture = router.connectTo(testSender2, requestedConnectionId)
|
||||||
|
|
||||||
let (initialPacket, sender) = await pq.get()
|
let (initialPacket, _) = await pq.get()
|
||||||
|
|
||||||
check:
|
check:
|
||||||
initialPacket.header.pType == ST_SYN
|
initialPacket.header.pType == ST_SYN
|
||||||
|
@ -324,7 +324,7 @@ procSuite "Utp router unit tests":
|
||||||
|
|
||||||
let connectFuture = router.connectTo(testSender2)
|
let connectFuture = router.connectTo(testSender2)
|
||||||
|
|
||||||
let (initialPacket, sender) = await pq.get()
|
let (initialPacket, _) = await pq.get()
|
||||||
|
|
||||||
check:
|
check:
|
||||||
initialPacket.header.pType == ST_SYN
|
initialPacket.header.pType == ST_SYN
|
||||||
|
@ -346,7 +346,7 @@ procSuite "Utp router unit tests":
|
||||||
|
|
||||||
let connectFuture = router.connectTo(testSender2)
|
let connectFuture = router.connectTo(testSender2)
|
||||||
|
|
||||||
let (initialPacket, sender) = await pq.get()
|
let (initialPacket, _) = await pq.get()
|
||||||
|
|
||||||
check:
|
check:
|
||||||
initialPacket.header.pType == ST_SYN
|
initialPacket.header.pType == ST_SYN
|
||||||
|
@ -361,7 +361,6 @@ procSuite "Utp router unit tests":
|
||||||
|
|
||||||
asyncTest "Router should clear all resources and handle error while sending syn packet":
|
asyncTest "Router should clear all resources and handle error while sending syn packet":
|
||||||
let q = newAsyncQueue[UtpSocket[int]]()
|
let q = newAsyncQueue[UtpSocket[int]]()
|
||||||
let pq = newAsyncQueue[(Packet, int)]()
|
|
||||||
let router = UtpRouter[int].new(registerIncomingSocketCallback(q), SocketConfig.init(milliseconds(500)), rng)
|
let router = UtpRouter[int].new(registerIncomingSocketCallback(q), SocketConfig.init(milliseconds(500)), rng)
|
||||||
router.sendCb =
|
router.sendCb =
|
||||||
proc (to: int, data: seq[byte]): Future[void] =
|
proc (to: int, data: seq[byte]): Future[void] =
|
||||||
|
@ -385,7 +384,7 @@ procSuite "Utp router unit tests":
|
||||||
let router = UtpRouter[int].new(registerIncomingSocketCallback(q), SocketConfig.init(), rng)
|
let router = UtpRouter[int].new(registerIncomingSocketCallback(q), SocketConfig.init(), rng)
|
||||||
router.sendCb = initTestSnd(pq)
|
router.sendCb = initTestSnd(pq)
|
||||||
|
|
||||||
let (outgoingSocket, initialSyn) = router.connectOutgoing(testSender2, pq, 30'u16)
|
let (outgoingSocket, _) = router.connectOutgoing(testSender2, pq, 30'u16)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
outgoingSocket.isConnected()
|
outgoingSocket.isConnected()
|
||||||
|
|
|
@ -88,7 +88,7 @@ procSuite "uTP socket tests":
|
||||||
let q = newAsyncQueue[Packet]()
|
let q = newAsyncQueue[Packet]()
|
||||||
let initialRemoteSeq = 10'u16
|
let initialRemoteSeq = 10'u16
|
||||||
|
|
||||||
let (socket, packet) = connectOutGoingSocket(initialRemoteSeq, q)
|
let (socket, _) = connectOutGoingSocket(initialRemoteSeq, q)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
socket.isConnected()
|
socket.isConnected()
|
||||||
|
@ -381,7 +381,7 @@ procSuite "uTP socket tests":
|
||||||
|
|
||||||
# lot of data which will generate at least 5 packets
|
# lot of data which will generate at least 5 packets
|
||||||
let bigDataTowWrite = rng[].generateBytes(10000)
|
let bigDataTowWrite = rng[].generateBytes(10000)
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q)
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeq, q)
|
||||||
|
|
||||||
let acker = outgoingSocket.ackAllPacket(q, initialRemoteSeq)
|
let acker = outgoingSocket.ackAllPacket(q, initialRemoteSeq)
|
||||||
let bytesWritten = await outgoingSocket.write(bigDataTowWrite)
|
let bytesWritten = await outgoingSocket.write(bigDataTowWrite)
|
||||||
|
@ -430,7 +430,7 @@ procSuite "uTP socket tests":
|
||||||
let dataToWrite1 = @[0'u8]
|
let dataToWrite1 = @[0'u8]
|
||||||
let dataToWrite2 = @[1'u8]
|
let dataToWrite2 = @[1'u8]
|
||||||
|
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q, cfg = SocketConfig.init(optSndBuffer = 0))
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeq, q, cfg = SocketConfig.init(optSndBuffer = 0))
|
||||||
|
|
||||||
let writeFut1 = outgoingSocket.write(dataToWrite1)
|
let writeFut1 = outgoingSocket.write(dataToWrite1)
|
||||||
let writeFut2 = outgoingSocket.write(dataToWrite2)
|
let writeFut2 = outgoingSocket.write(dataToWrite2)
|
||||||
|
@ -738,7 +738,7 @@ procSuite "uTP socket tests":
|
||||||
let q = newAsyncQueue[Packet]()
|
let q = newAsyncQueue[Packet]()
|
||||||
let initialRemoteSeq = 10'u16
|
let initialRemoteSeq = 10'u16
|
||||||
|
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q)
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeq, q)
|
||||||
|
|
||||||
outgoingSocket.close()
|
outgoingSocket.close()
|
||||||
|
|
||||||
|
@ -784,7 +784,7 @@ procSuite "uTP socket tests":
|
||||||
let q = newAsyncQueue[Packet]()
|
let q = newAsyncQueue[Packet]()
|
||||||
let initialRemoteSeq = 10'u16
|
let initialRemoteSeq = 10'u16
|
||||||
|
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q)
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeq, q)
|
||||||
|
|
||||||
await outgoingSocket.destroyWait()
|
await outgoingSocket.destroyWait()
|
||||||
|
|
||||||
|
@ -803,7 +803,7 @@ procSuite "uTP socket tests":
|
||||||
let q = newAsyncQueue[Packet]()
|
let q = newAsyncQueue[Packet]()
|
||||||
let initialRemoteSeq = 10'u16
|
let initialRemoteSeq = 10'u16
|
||||||
|
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q)
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeq, q)
|
||||||
|
|
||||||
outgoingSocket.close()
|
outgoingSocket.close()
|
||||||
|
|
||||||
|
@ -846,7 +846,7 @@ procSuite "uTP socket tests":
|
||||||
ack1.header.ackNr == initialRemoteSeqNr
|
ack1.header.ackNr == initialRemoteSeqNr
|
||||||
ack1.header.wndSize == initialRcvBufferSize - uint32(len(data))
|
ack1.header.wndSize == initialRcvBufferSize - uint32(len(data))
|
||||||
|
|
||||||
let written = await outgoingSocket.write(data)
|
discard await outgoingSocket.write(data)
|
||||||
|
|
||||||
let sentData = await q.get()
|
let sentData = await q.get()
|
||||||
|
|
||||||
|
@ -966,7 +966,7 @@ procSuite "uTP socket tests":
|
||||||
|
|
||||||
let dataToWrite = @[1'u8, 2, 3, 4, 5]
|
let dataToWrite = @[1'u8, 2, 3, 4, 5]
|
||||||
|
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q)
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeq, q)
|
||||||
|
|
||||||
discard await outgoingSocket.write(dataToWrite)
|
discard await outgoingSocket.write(dataToWrite)
|
||||||
|
|
||||||
|
@ -1027,7 +1027,7 @@ procSuite "uTP socket tests":
|
||||||
let dataToWrite = @[1'u8, 2, 3]
|
let dataToWrite = @[1'u8, 2, 3]
|
||||||
let dataToWrite1 = @[6'u8, 7, 8, 9, 10]
|
let dataToWrite1 = @[6'u8, 7, 8, 9, 10]
|
||||||
|
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q)
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeq, q)
|
||||||
|
|
||||||
discard await outgoingSocket.write(dataToWrite)
|
discard await outgoingSocket.write(dataToWrite)
|
||||||
|
|
||||||
|
@ -1036,10 +1036,9 @@ procSuite "uTP socket tests":
|
||||||
check:
|
check:
|
||||||
int(outgoingSocket.numOfBytesInFlight) == len(dataToWrite)
|
int(outgoingSocket.numOfBytesInFlight) == len(dataToWrite)
|
||||||
|
|
||||||
|
|
||||||
discard await outgoingSocket.write(dataToWrite1)
|
discard await outgoingSocket.write(dataToWrite1)
|
||||||
|
|
||||||
let sentPacket1 = await q.get()
|
discard await q.get()
|
||||||
|
|
||||||
check:
|
check:
|
||||||
int(outgoingSocket.numOfBytesInFlight) == len(dataToWrite) + len(dataToWrite1)
|
int(outgoingSocket.numOfBytesInFlight) == len(dataToWrite) + len(dataToWrite1)
|
||||||
|
@ -1101,7 +1100,7 @@ procSuite "uTP socket tests":
|
||||||
|
|
||||||
let dataToWrite = 1160
|
let dataToWrite = 1160
|
||||||
# remote is initialized with buffer to small to handle whole payload
|
# remote is initialized with buffer to small to handle whole payload
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q, cfg = SocketConfig.init(optSndBuffer = 1160))
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeq, q, cfg = SocketConfig.init(optSndBuffer = 1160))
|
||||||
|
|
||||||
let twoPacketData = rng[].generateBytes(int(dataToWrite))
|
let twoPacketData = rng[].generateBytes(int(dataToWrite))
|
||||||
|
|
||||||
|
@ -1125,8 +1124,6 @@ procSuite "uTP socket tests":
|
||||||
let q = newAsyncQueue[Packet]()
|
let q = newAsyncQueue[Packet]()
|
||||||
let initialRemoteSeq = 10'u16
|
let initialRemoteSeq = 10'u16
|
||||||
|
|
||||||
let dataToWrite = @[1'u8, 2, 3, 4, 5]
|
|
||||||
|
|
||||||
# remote is initialized with buffer to small to handle whole payload
|
# remote is initialized with buffer to small to handle whole payload
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q)
|
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q)
|
||||||
let remoteRcvWindowSize = uint32(outgoingSocket.getPacketSize())
|
let remoteRcvWindowSize = uint32(outgoingSocket.getPacketSize())
|
||||||
|
@ -1184,7 +1181,7 @@ procSuite "uTP socket tests":
|
||||||
let q = newAsyncQueue[Packet]()
|
let q = newAsyncQueue[Packet]()
|
||||||
let initialRemoteSeq = 10'u16
|
let initialRemoteSeq = 10'u16
|
||||||
let someData = @[1'u8]
|
let someData = @[1'u8]
|
||||||
let (outgoingSocket, packet) =
|
let (outgoingSocket, _) =
|
||||||
connectOutGoingSocket(
|
connectOutGoingSocket(
|
||||||
initialRemoteSeq,
|
initialRemoteSeq,
|
||||||
q,
|
q,
|
||||||
|
@ -1227,7 +1224,7 @@ procSuite "uTP socket tests":
|
||||||
outgoingSocket.isConnected()
|
outgoingSocket.isConnected()
|
||||||
|
|
||||||
# snd buffer got 1 byte of space so this future should finish
|
# snd buffer got 1 byte of space so this future should finish
|
||||||
let write1 = await outgoingSocket.write(someData1)
|
discard await outgoingSocket.write(someData1)
|
||||||
|
|
||||||
let writeFut2 = outgoingSocket.write(someData2)
|
let writeFut2 = outgoingSocket.write(someData2)
|
||||||
|
|
||||||
|
@ -1327,7 +1324,7 @@ procSuite "uTP socket tests":
|
||||||
|
|
||||||
await outgoingSocket.processPacket(dataP1)
|
await outgoingSocket.processPacket(dataP1)
|
||||||
|
|
||||||
let fastResend = await q.get()
|
discard await q.get()
|
||||||
|
|
||||||
let ack = await q.get()
|
let ack = await q.get()
|
||||||
|
|
||||||
|
@ -1474,7 +1471,7 @@ procSuite "uTP socket tests":
|
||||||
|
|
||||||
let dataToWrite = @[1'u8]
|
let dataToWrite = @[1'u8]
|
||||||
let customCfg = SocketConfig.init(dataResendsBeforeFailure = 2, optSndBuffer = 1)
|
let customCfg = SocketConfig.init(dataResendsBeforeFailure = 2, optSndBuffer = 1)
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeq, q, cfg = customCfg)
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeq, q, cfg = customCfg)
|
||||||
|
|
||||||
let bytesWritten = await outgoingSocket.write(dataToWrite)
|
let bytesWritten = await outgoingSocket.write(dataToWrite)
|
||||||
# this future will never finish as there is not place in write buffer
|
# this future will never finish as there is not place in write buffer
|
||||||
|
@ -1484,7 +1481,7 @@ procSuite "uTP socket tests":
|
||||||
check:
|
check:
|
||||||
bytesWritten.get() == len(dataToWrite)
|
bytesWritten.get() == len(dataToWrite)
|
||||||
|
|
||||||
let sentPacket = await q.get()
|
discard await q.get()
|
||||||
# wait for failure and cleanup of all resources
|
# wait for failure and cleanup of all resources
|
||||||
await waitUntil(proc (): bool = outgoingSocket.isClosedAndCleanedUpAllResources())
|
await waitUntil(proc (): bool = outgoingSocket.isClosedAndCleanedUpAllResources())
|
||||||
check:
|
check:
|
||||||
|
@ -1535,7 +1532,7 @@ procSuite "uTP socket tests":
|
||||||
let maxPayloadSize = 800'u32
|
let maxPayloadSize = 800'u32
|
||||||
let config = SocketConfig.init(payloadSize = maxPayloadSize)
|
let config = SocketConfig.init(payloadSize = maxPayloadSize)
|
||||||
|
|
||||||
let (outgoingSocket, initialPacket) = connectOutGoingSocket(initialRemoteSeqNr, q, cfg = config)
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeqNr, q, cfg = config)
|
||||||
|
|
||||||
let wr = await outgoingSocket.write(d)
|
let wr = await outgoingSocket.write(d)
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ procSuite "Utp socket selective acks unit test":
|
||||||
let q = newAsyncQueue[Packet]()
|
let q = newAsyncQueue[Packet]()
|
||||||
let initialRemoteSeq = 10'u16
|
let initialRemoteSeq = 10'u16
|
||||||
|
|
||||||
let (outgoingSocket, packet) = connectOutGoingSocket(initialRemoteSeq, q)
|
let (outgoingSocket, _) = connectOutGoingSocket(initialRemoteSeq, q)
|
||||||
|
|
||||||
let extArray = outgoingSocket.generateSelectiveAckBitMask()
|
let extArray = outgoingSocket.generateSelectiveAckBitMask()
|
||||||
|
|
||||||
|
@ -217,7 +217,6 @@ procSuite "Utp socket selective acks unit test":
|
||||||
await incomingSocket.destroyWait()
|
await incomingSocket.destroyWait()
|
||||||
|
|
||||||
asyncTest "Socket should ack packets based on selective ack packet":
|
asyncTest "Socket should ack packets based on selective ack packet":
|
||||||
let dataSize = 10
|
|
||||||
let initialRemoteSeq = 10'u16
|
let initialRemoteSeq = 10'u16
|
||||||
let smallData = rng[].generateBytes(10)
|
let smallData = rng[].generateBytes(10)
|
||||||
|
|
||||||
|
@ -275,7 +274,6 @@ procSuite "Utp socket selective acks unit test":
|
||||||
]
|
]
|
||||||
|
|
||||||
asyncTest "Socket should re-send packets when there are at least 3 packets acked ahead":
|
asyncTest "Socket should re-send packets when there are at least 3 packets acked ahead":
|
||||||
let dataSize = 10
|
|
||||||
let initialRemoteSeq = 10'u16
|
let initialRemoteSeq = 10'u16
|
||||||
let smallData = rng[].generateBytes(10)
|
let smallData = rng[].generateBytes(10)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue