From c5dd5e41155b453a0785b6c04fa2c72995fc41b8 Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Thu, 22 Jun 2023 18:13:16 +0200 Subject: [PATCH] Enable tests with also json sink and fix failures (#624) And a few minor cleanups --- eth/p2p/discoveryv5/routing_table.nim | 2 +- eth/utp/utp_protocol.nim | 2 ++ eth/utp/utp_socket.nim | 2 ++ tests/nim.cfg | 2 ++ tools/dcli.nim | 6 +++++- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/eth/p2p/discoveryv5/routing_table.nim b/eth/p2p/discoveryv5/routing_table.nim index a080b96..d8db595 100644 --- a/eth/p2p/discoveryv5/routing_table.nim +++ b/eth/p2p/discoveryv5/routing_table.nim @@ -11,7 +11,7 @@ import std/[algorithm, times, sequtils, bitops, sets, options], bearssl/rand, stint, chronicles, metrics, chronos, stew/shims/net as stewNet, - ../../net/utils, stew/endians2, + ../../net/utils, "."/[node, random2, enr] export options diff --git a/eth/utp/utp_protocol.nim b/eth/utp/utp_protocol.nim index 8bcae22..0cc06fc 100644 --- a/eth/utp/utp_protocol.nim +++ b/eth/utp/utp_protocol.nim @@ -27,6 +27,8 @@ type proc (d: DatagramTransport): SendCallback[TransportAddress] {.gcsafe, raises: [].} +chronicles.formatIt(TransportAddress): $it + # This should probably be defined in TransportAddress module, as hash function should # be consistent with equality function # in nim zero arrays always have hash equal to 0, irrespectively of array size, to diff --git a/eth/utp/utp_socket.nim b/eth/utp/utp_socket.nim index da361bd..fa0f7ce 100644 --- a/eth/utp/utp_socket.nim +++ b/eth/utp/utp_socket.nim @@ -311,6 +311,8 @@ type ConnectionResult*[A] = Result[UtpSocket[A], OutgoingConnectionError] +chronicles.formatIt(UtpSocketKey): $it + const # Default maximum size of the data packet payload. With this configuration # data packets will have 508 bytes (488 + 20 header). diff --git a/tests/nim.cfg b/tests/nim.cfg index 593f46f..1a3ae0d 100644 --- a/tests/nim.cfg +++ b/tests/nim.cfg @@ -3,6 +3,8 @@ # rocksdb init does this type of assignment --define:nimOldCaseObjects +-d:"chronicles_sinks=textlines[stdout],json[dynamic]" +-d:"chronicles_log_level=TRACE" -d:"chronicles_runtime_filtering=on" # Avoid some rare stack corruption while using exceptions with a SEH-enabled diff --git a/tools/dcli.nim b/tools/dcli.nim index c89e634..e002107 100644 --- a/tools/dcli.nim +++ b/tools/dcli.nim @@ -6,6 +6,8 @@ # This file may not be copied, modified, or distributed except according to # those terms. +{.push raises: [].} + import std/[options, strutils, tables, sets], confutils, confutils/std/net, chronicles, chronicles/topics_registry, @@ -182,7 +184,7 @@ proc discover(d: discv5_protocol.Protocol, psFile: string) {.async.} = await sleepAsync(1000) # 1 sec of delay -proc run(config: DiscoveryConf) = +proc run(config: DiscoveryConf) {.raises: [CatchableError].} = let bindIp = config.listenAddress udpPort = Port(config.udpPort) @@ -235,7 +237,9 @@ proc run(config: DiscoveryConf) = waitFor(discover(d, config.persistingFile)) when isMainModule: + {.pop.} let config = DiscoveryConf.load() + {.push raises: [].} setLogLevel(config.logLevel)