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. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
std/[options, math, sugar] std/[options, math]
export options export options

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@
import import
std/options, std/options,
stew/[byteutils, bitops2], stew/byteutils,
unittest2, unittest2,
../../eth/utp/packets, ../../eth/utp/packets,
../../eth/keys ../../eth/keys