mirror of https://github.com/status-im/nim-eth.git
Default compile all tests and binaries with TRACE log level (#549)
In order to avoid unused warning and more importantly to make sure all log statements work.
This commit is contained in:
parent
10870d8b15
commit
86b37bf72e
29
eth.nimble
29
eth.nimble
|
@ -24,25 +24,28 @@ let styleCheckStyle =
|
||||||
else:
|
else:
|
||||||
"error"
|
"error"
|
||||||
|
|
||||||
let commonParams = " --verbosity:0 --hints:off --skipUserCfg:on " &
|
let commonParams =
|
||||||
"--warning[ObservableStores]:off --styleCheck:usages --styleCheck:" &
|
" --skipUserCfg:on" &
|
||||||
styleCheckStyle & " " & getEnv("NIMFLAGS") & " "
|
" --verbosity:0 --hints:off" &
|
||||||
|
" --warning[ObservableStores]:off " &
|
||||||
|
" --styleCheck:usages --styleCheck:" & styleCheckStyle &
|
||||||
|
" " & getEnv("NIMFLAGS") &
|
||||||
|
" -d:chronosStrictException" &
|
||||||
|
" -d:chronicles_log_level=TRACE"
|
||||||
|
|
||||||
proc runTest(path: string, release: bool = true, chronosStrict = true) =
|
proc runTest(path: string, release: bool = true) =
|
||||||
echo "\nBuilding and running: ", path
|
echo "\nBuilding and running: ", path
|
||||||
let releaseMode = if release: "-d:release" else: ""
|
let releaseMode = if release: " -d:release" else: ""
|
||||||
let chronosMode =
|
|
||||||
if chronosStrict: "-d:chronosStrictException" else: ""
|
exec "nim c -r" &
|
||||||
exec "nim c -r " & releaseMode & " " & chronosMode &
|
releaseMode & commonParams & " " & path
|
||||||
" -d:chronicles_log_level=ERROR " & commonParams & path
|
|
||||||
rmFile path
|
rmFile path
|
||||||
|
|
||||||
proc buildBinary(path: string) =
|
proc buildBinary(path: string) =
|
||||||
echo "\nBuilding: ", path
|
echo "\nBuilding: ", path
|
||||||
exec "nim c -d:release -d:chronosStrictException " &
|
exec "nim c -d:release" & commonParams &
|
||||||
"-d:chronicles_log_level=TRACE --threads:on " & commonParams &
|
" --warning[CaseTransition]:off" &
|
||||||
"--warning[CaseTransition]:off --warning[ObservableStores]:off " &
|
" " & path
|
||||||
path
|
|
||||||
|
|
||||||
task test_keyfile, "Run keyfile tests":
|
task test_keyfile, "Run keyfile tests":
|
||||||
runTest("tests/keyfile/all_tests")
|
runTest("tests/keyfile/all_tests")
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
--threads:on
|
||||||
|
|
||||||
-d:"chronicles_runtime_filtering=on"
|
-d:"chronicles_runtime_filtering=on"
|
|
@ -3,6 +3,8 @@
|
||||||
# rocksdb init does this type of assignment
|
# rocksdb init does this type of assignment
|
||||||
--define:nimOldCaseObjects
|
--define:nimOldCaseObjects
|
||||||
|
|
||||||
|
-d:"chronicles_runtime_filtering=on"
|
||||||
|
|
||||||
# Avoid some rare stack corruption while using exceptions with a SEH-enabled
|
# Avoid some rare stack corruption while using exceptions with a SEH-enabled
|
||||||
# toolchain: https://github.com/status-im/nimbus-eth2/issues/3121
|
# toolchain: https://github.com/status-im/nimbus-eth2/issues/3121
|
||||||
@if windows and not vcc:
|
@if windows and not vcc:
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
import
|
import
|
||||||
std/sequtils,
|
std/sequtils,
|
||||||
chronos, stew/byteutils, nimcrypto, testutils/unittests,
|
chronos, stew/byteutils, nimcrypto, testutils/unittests,
|
||||||
../../eth/keys, ../../eth/p2p/[discovery, kademlia, enode]
|
../../eth/keys, ../../eth/p2p/[discovery, kademlia, enode],
|
||||||
|
../stubloglevel
|
||||||
|
|
||||||
proc localAddress(port: int): Address =
|
proc localAddress(port: int): Address =
|
||||||
let port = Port(port)
|
let port = Port(port)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import
|
||||||
../../eth/p2p/discoveryv5/[enr, node, routing_table, encoding, sessions,
|
../../eth/p2p/discoveryv5/[enr, node, routing_table, encoding, sessions,
|
||||||
messages, nodes_verification],
|
messages, nodes_verification],
|
||||||
../../eth/p2p/discoveryv5/protocol as discv5_protocol,
|
../../eth/p2p/discoveryv5/protocol as discv5_protocol,
|
||||||
|
../stubloglevel,
|
||||||
./discv5_test_helper
|
./discv5_test_helper
|
||||||
|
|
||||||
suite "Discovery v5 Tests":
|
suite "Discovery v5 Tests":
|
||||||
|
|
|
@ -5,7 +5,8 @@ import
|
||||||
unittest2,
|
unittest2,
|
||||||
stint, stew/byteutils, stew/shims/net,
|
stint, stew/byteutils, stew/shims/net,
|
||||||
../../eth/keys,
|
../../eth/keys,
|
||||||
../../eth/p2p/discoveryv5/[messages_encoding, encoding, enr, node, sessions]
|
../../eth/p2p/discoveryv5/[messages_encoding, encoding, enr, node, sessions],
|
||||||
|
../stubloglevel
|
||||||
|
|
||||||
let rng = newRng()
|
let rng = newRng()
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import
|
||||||
std/tables,
|
std/tables,
|
||||||
chronos, testutils/unittests,
|
chronos, testutils/unittests,
|
||||||
../../eth/p2p,
|
../../eth/p2p,
|
||||||
|
../stubloglevel,
|
||||||
./p2p_test_helper
|
./p2p_test_helper
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
@ -5,6 +5,7 @@ import
|
||||||
unittest2, stint,
|
unittest2, stint,
|
||||||
chronos, stew/byteutils,
|
chronos, stew/byteutils,
|
||||||
../../eth/[p2p, common],
|
../../eth/[p2p, common],
|
||||||
|
../stubloglevel,
|
||||||
./p2p_test_helper,
|
./p2p_test_helper,
|
||||||
./eth_protocol
|
./eth_protocol
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import chronicles
|
||||||
|
|
||||||
|
{.used.}
|
||||||
|
|
||||||
|
when defined(chronicles_runtime_filtering):
|
||||||
|
setLogLevel(ERROR)
|
|
@ -11,7 +11,6 @@ import
|
||||||
unittest2,
|
unittest2,
|
||||||
../../eth/utp/growable_buffer
|
../../eth/utp/growable_buffer
|
||||||
|
|
||||||
|
|
||||||
type TestObj = object
|
type TestObj = object
|
||||||
foo: string
|
foo: string
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ import
|
||||||
../../eth/utp/utp_discv5_protocol,
|
../../eth/utp/utp_discv5_protocol,
|
||||||
../../eth/keys,
|
../../eth/keys,
|
||||||
../../eth/utp/utp_router as rt,
|
../../eth/utp/utp_router as rt,
|
||||||
../p2p/discv5_test_helper
|
../p2p/discv5_test_helper,
|
||||||
|
../stubloglevel
|
||||||
|
|
||||||
procSuite "Utp protocol over discovery v5 tests":
|
procSuite "Utp protocol over discovery v5 tests":
|
||||||
let rng = newRng()
|
let rng = newRng()
|
||||||
|
|
|
@ -12,11 +12,8 @@ import
|
||||||
../../eth/utp/packets,
|
../../eth/utp/packets,
|
||||||
../../eth/keys
|
../../eth/keys
|
||||||
|
|
||||||
suite "Utp packets encoding/decoding":
|
suite "uTP Packet Encoding":
|
||||||
|
test "Encode/decode SYN packet":
|
||||||
let rng = newRng()
|
|
||||||
|
|
||||||
test "Encode/decode syn packet":
|
|
||||||
let synPacket = synPacket(5, 10, 20)
|
let synPacket = synPacket(5, 10, 20)
|
||||||
let encoded = encodePacket(synPacket)
|
let encoded = encodePacket(synPacket)
|
||||||
let decoded = decodePacket(encoded)
|
let decoded = decodePacket(encoded)
|
||||||
|
@ -30,7 +27,7 @@ suite "Utp packets encoding/decoding":
|
||||||
check:
|
check:
|
||||||
synPacketDec == synPacket
|
synPacketDec == synPacket
|
||||||
|
|
||||||
test "Encode/decode fin packet":
|
test "Encode/decode FIN packet":
|
||||||
let finPacket = finPacket(5, 10, 20, 30, 40)
|
let finPacket = finPacket(5, 10, 20, 30, 40)
|
||||||
let encoded = encodePacket(finPacket)
|
let encoded = encodePacket(finPacket)
|
||||||
let decoded = decodePacket(encoded)
|
let decoded = decodePacket(encoded)
|
||||||
|
@ -44,7 +41,7 @@ suite "Utp packets encoding/decoding":
|
||||||
check:
|
check:
|
||||||
finPacketDec == finPacket
|
finPacketDec == finPacket
|
||||||
|
|
||||||
test "Encode/decode reset packet":
|
test "Encode/decode RESET packet":
|
||||||
let resetPacket = resetPacket(5, 10, 20)
|
let resetPacket = resetPacket(5, 10, 20)
|
||||||
let encoded = encodePacket(resetPacket)
|
let encoded = encodePacket(resetPacket)
|
||||||
let decoded = decodePacket(encoded)
|
let decoded = decodePacket(encoded)
|
||||||
|
@ -58,7 +55,7 @@ suite "Utp packets encoding/decoding":
|
||||||
check:
|
check:
|
||||||
resetPacketDec == resetPacket
|
resetPacketDec == resetPacket
|
||||||
|
|
||||||
test "Encode/decode ack packet without extensions":
|
test "Encode/decode ACK packet: without extensions":
|
||||||
let ackPacket = ackPacket(5, 10, 20, 30, 40)
|
let ackPacket = ackPacket(5, 10, 20, 30, 40)
|
||||||
let encoded = encodePacket(ackPacket)
|
let encoded = encodePacket(ackPacket)
|
||||||
let decoded = decodePacket(encoded)
|
let decoded = decodePacket(encoded)
|
||||||
|
@ -72,7 +69,7 @@ suite "Utp packets encoding/decoding":
|
||||||
check:
|
check:
|
||||||
ackPacketDec == ackPacket
|
ackPacketDec == ackPacket
|
||||||
|
|
||||||
test "Encode/decode ack packet with extensions":
|
test "Encode/decode ACK packet: with extensions":
|
||||||
let bitMask: array[4, byte] = [1'u8, 2, 3, 4]
|
let bitMask: array[4, byte] = [1'u8, 2, 3, 4]
|
||||||
let ackPacket = ackPacket(5, 10, 20, 30, 40, some(bitMask))
|
let ackPacket = ackPacket(5, 10, 20, 30, 40, some(bitMask))
|
||||||
let encoded = encodePacket(ackPacket)
|
let encoded = encodePacket(ackPacket)
|
||||||
|
@ -117,7 +114,6 @@ suite "Utp packets encoding/decoding":
|
||||||
err3.isErr()
|
err3.isErr()
|
||||||
err3.error() == "Packet too short for selective ack extension"
|
err3.error() == "Packet too short for selective ack extension"
|
||||||
|
|
||||||
|
|
||||||
var encoded4 = encodePacket(ackPacket)
|
var encoded4 = encodePacket(ackPacket)
|
||||||
# change change extension field to something other than 0 or 1
|
# change change extension field to something other than 0 or 1
|
||||||
encoded4[1] = 2
|
encoded4[1] = 2
|
||||||
|
@ -126,11 +122,11 @@ suite "Utp packets encoding/decoding":
|
||||||
err4.isErr()
|
err4.isErr()
|
||||||
err4.error() == "Invalid extension type"
|
err4.error() == "Invalid extension type"
|
||||||
|
|
||||||
test "Decode state packet":
|
test "Decode STATE packet":
|
||||||
# Packet obtained by interaction with c reference implementation
|
# Packet obtained by interaction with c reference implementation
|
||||||
let pack: array[20, uint8] = [
|
let pack: array[20, uint8] = [
|
||||||
0x21'u8, 0x0, 0x15, 0x72, 0x00, 0xBA, 0x4D, 0x71, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0,
|
0x21'u8, 0x0, 0x15, 0x72, 0x00, 0xBA, 0x4D, 0x71, 0x0, 0x0,
|
||||||
0x0, 0x41, 0xA7, 0x00, 0x01]
|
0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x41, 0xA7, 0x00, 0x01]
|
||||||
let decoded = decodePacket(pack)
|
let decoded = decodePacket(pack)
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
|
|
@ -13,7 +13,8 @@ import
|
||||||
./test_utils,
|
./test_utils,
|
||||||
../../eth/utp/utp_router as rt,
|
../../eth/utp/utp_router as rt,
|
||||||
../../eth/utp/utp_protocol,
|
../../eth/utp/utp_protocol,
|
||||||
../../eth/keys
|
../../eth/keys,
|
||||||
|
../stubloglevel
|
||||||
|
|
||||||
proc setAcceptedCallback(event: AsyncEvent): AcceptConnectionCallback[TransportAddress] =
|
proc setAcceptedCallback(event: AsyncEvent): AcceptConnectionCallback[TransportAddress] =
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -13,7 +13,8 @@ import
|
||||||
../../eth/utp/utp_router,
|
../../eth/utp/utp_router,
|
||||||
../../eth/utp/utp_protocol,
|
../../eth/utp/utp_protocol,
|
||||||
../../eth/keys,
|
../../eth/keys,
|
||||||
../../eth/p2p/discoveryv5/random2
|
../../eth/p2p/discoveryv5/random2,
|
||||||
|
../stubloglevel
|
||||||
|
|
||||||
proc connectTillSuccess(p: UtpProtocol, to: TransportAddress, maxTries: int = 20): Future[UtpSocket[TransportAddress]] {.async.} =
|
proc connectTillSuccess(p: UtpProtocol, to: TransportAddress, maxTries: int = 20): Future[UtpSocket[TransportAddress]] {.async.} =
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
|
@ -13,7 +13,8 @@ import
|
||||||
./test_utils,
|
./test_utils,
|
||||||
../../eth/utp/utp_router,
|
../../eth/utp/utp_router,
|
||||||
../../eth/utp/packets,
|
../../eth/utp/packets,
|
||||||
../../eth/keys
|
../../eth/keys,
|
||||||
|
../stubloglevel
|
||||||
|
|
||||||
proc hash*(x: UtpSocketKey[int]): Hash =
|
proc hash*(x: UtpSocketKey[int]): Hash =
|
||||||
var h = 0
|
var h = 0
|
||||||
|
|
|
@ -14,7 +14,8 @@ import
|
||||||
../../eth/utp/utp_router,
|
../../eth/utp/utp_router,
|
||||||
../../eth/utp/utp_socket,
|
../../eth/utp/utp_socket,
|
||||||
../../eth/utp/packets,
|
../../eth/utp/packets,
|
||||||
../../eth/keys
|
../../eth/keys,
|
||||||
|
../stubloglevel
|
||||||
|
|
||||||
procSuite "Utp socket unit test":
|
procSuite "Utp socket unit test":
|
||||||
let rng = newRng()
|
let rng = newRng()
|
||||||
|
|
|
@ -15,7 +15,8 @@ import
|
||||||
../../eth/utp/utp_router,
|
../../eth/utp/utp_router,
|
||||||
../../eth/utp/utp_socket,
|
../../eth/utp/utp_socket,
|
||||||
../../eth/utp/packets,
|
../../eth/utp/packets,
|
||||||
../../eth/keys
|
../../eth/keys,
|
||||||
|
../stubloglevel
|
||||||
|
|
||||||
procSuite "Utp socket selective acks unit test":
|
procSuite "Utp socket selective acks unit test":
|
||||||
let rng = newRng()
|
let rng = newRng()
|
||||||
|
|
Loading…
Reference in New Issue