Clean-up of several compiler warnings (#519)

This commit is contained in:
Kim De Mey 2022-07-09 10:55:15 +02:00 committed by GitHub
parent 7cc3c59ff1
commit 9d7e4b031a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 31 deletions

View File

@ -5,7 +5,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms.
import
std/[options, math, sugar]
std/[options, math]
export options
@ -64,8 +64,8 @@ proc calculateNextMask(currentMask: uint32, index:uint32): uint32 =
# Increase mask,so that index will fit in buffer size i.e mask + 1
if currentMask == uint32.high:
return currentMask
var newSize = currentMask + 1
var newSize = currentMask + 1
while true:
newSize = newSize * 2
if newSize == 0 or index < newSize:

View File

@ -7,10 +7,9 @@
{.push raises: [Defect].}
import
std/[monotimes],
faststreams,
chronos,
stew/[endians2, results, objects, arrayops],
stew/[endians2, results, objects],
../p2p/discoveryv5/random2
export results, random2

View File

@ -48,7 +48,7 @@ proc hash(x: UtpSocketKey[NodeAddress]): Hash =
func `$`*(x: UtpSocketKey[NodeAddress]): string =
"(remoteId: " & $x.remoteAddress.nodeId &
", remoteAddress: " & $x.remoteAddress.address &
", rcvId: "& $x.rcvId &
", rcvId: " & $x.rcvId &
")"
proc talkReqDirect(p: protocol.Protocol, n: NodeAddress, protocol, request: seq[byte]): Future[void] =

View File

@ -7,7 +7,7 @@
{.push raises: [Defect].}
import
std/[tables, options, hashes, sugar, math],
std/[tables, options, hashes, math],
chronos, chronicles,
./utp_router,
../keys

View File

@ -120,10 +120,10 @@ suite "Routing Table Tests":
table.replaceNode(table.nodeToRevalidate())
block:
# Should return the last node of the replacement cache successfully.
let result = table.getNode(lastNode.id)
let res = table.getNode(lastNode.id)
check:
result.isSome()
result.get() == lastNode
res.isSome()
res.get() == lastNode
block:
# This node should be removed
check (table.getNode(bucketNodes[bucketNodes.high].id)).isNone()
@ -186,10 +186,10 @@ suite "Routing Table Tests":
for n in 0..<BUCKET_SIZE:
table.replaceNode(table.nodeToRevalidate())
let result = table.getNode(doubleNode.id)
let res = table.getNode(doubleNode.id)
check:
result.isSome()
result.get() == doubleNode
res.isSome()
res.get() == doubleNode
table.len == 1
test "Double replacement add":
@ -212,10 +212,10 @@ suite "Routing Table Tests":
table.replaceNode(table.nodeToRevalidate())
block:
# Should return the last node of the replacement cache successfully.
let result = table.getNode(replacementNodes[0].id)
let res = table.getNode(replacementNodes[0].id)
check:
result.isSome()
result.get() == replacementNodes[0]
res.isSome()
res.get() == replacementNodes[0]
block:
# This node should be removed
check (table.getNode(bucketNodes[bucketNodes.high].id)).isNone()
@ -258,16 +258,16 @@ suite "Routing Table Tests":
table.setJustSeen(replacementNodes[i])
for n in replacementNodes:
let result = table.getNode(n.id)
let res = table.getNode(n.id)
check:
result.isSome()
result.get() == n
res.isSome()
res.get() == n
for i in 0..<int(BUCKET_SIZE/2):
let result = table.getNode(bucketNodes[i].id)
let res = table.getNode(bucketNodes[i].id)
check:
result.isSome()
result.get() == bucketNodes[i]
res.isSome()
res.get() == bucketNodes[i]
test "Ip limits on bucket":
let node = generateNode(PrivateKey.random(rng[]))

View File

@ -12,7 +12,7 @@ suite "binary trie":
test "different order insert":
randomize()
var kv_pairs = randKVPair()
var result = zeroHash
var res = zeroHash
for _ in 0..<1: # repeat 3 times
var db = newMemoryDB()
var trie = initBinaryTrie(db)
@ -24,12 +24,12 @@ suite "binary trie":
let y = c.value
check y == x
check result == zeroHash or trie.getRootHash() == result
result = trie.getRootHash()
check res == zeroHash or trie.getRootHash() == res
res = trie.getRootHash()
# insert already exist key/value
trie.set(kv_pairs[0].key, kv_pairs[0].value)
check trie.getRootHash() == result
check trie.getRootHash() == res
# Delete all key/value
random.shuffle(kv_pairs)

View File

@ -7,10 +7,9 @@
{.used.}
import
std/[sequtils, tables, options, sugar],
std/[tables, options],
chronos,
testutils/unittests,
./test_utils,
../../eth/utp/utp_router,
../../eth/utp/utp_protocol,
../../eth/keys,

View File

@ -8,7 +8,7 @@
import
std/options,
stew/[byteutils, bitops2],
stew/byteutils,
unittest2,
../../eth/utp/packets,
../../eth/keys
@ -32,7 +32,7 @@ suite "Utp packets test vectors":
)
let encodedSyn = encodePacket(synPacket)
let synBytes = hexToSeqByte("0x41002741c9b699ba00000000001000002e6c0000")
check:
@ -109,7 +109,7 @@ suite "Utp packets test vectors":
)
let encodedData = encodePacket(dataPacket)
let dataBytes = hexToSeqByte("0x0100667d0f0cbacf0e710cbf00100000208e41a600010203040506070809")
check: