From 9ae0bfb1c322649d028aa114a463926412eb4631 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 21 Jul 2023 15:51:42 -0600 Subject: [PATCH] Fix nimble install (#78) * make encryption scheme explicit * supress compiler noise * make `nimble install` without `-d` work * move `libp2p_pki_schemes=secp256k1` to config.nims * fix include --- build.nims | 2 -- codexdht.nimble | 6 ++---- codexdht/private/eth/p2p/discoveryv5/encoding.nim | 2 +- config.nims | 2 ++ tests/dht/test_helper.nim | 2 +- tests/dht/test_providers.nim | 1 - tests/testAllParallel.nim | 8 ++++---- 7 files changed, 10 insertions(+), 13 deletions(-) diff --git a/build.nims b/build.nims index b4c5d7f..5dc4b68 100644 --- a/build.nims +++ b/build.nims @@ -1,7 +1,5 @@ import std / [os, strutils, sequtils] -switch("define", "libp2p_pki_schemes=secp256k1") - task testAll, "Run DHT tests": exec "nim c -r tests/testAll.nim" diff --git a/codexdht.nimble b/codexdht.nimble index a91f91f..83425b7 100644 --- a/codexdht.nimble +++ b/codexdht.nimble @@ -2,10 +2,10 @@ version = "0.3.2" author = "Status Research & Development GmbH" -description = "DHT based on the libp2p Kademlia spec" +description = "DHT based on Eth discv5 implementation" license = "MIT" skipDirs = @["tests"] - +installFiles = @["build.nims"] # Dependencies requires "nim >= 1.2.0" @@ -24,5 +24,3 @@ requires "https://github.com/status-im/nim-datastore#head" requires "questionable" include "build.nims" - - diff --git a/codexdht/private/eth/p2p/discoveryv5/encoding.nim b/codexdht/private/eth/p2p/discoveryv5/encoding.nim index 3c6f6e6..9bb5043 100644 --- a/codexdht/private/eth/p2p/discoveryv5/encoding.nim +++ b/codexdht/private/eth/p2p/discoveryv5/encoding.nim @@ -307,7 +307,7 @@ proc encodeHandshakePacket*(rng: var HmacDrbgContext, c: var Codec, authdataHead.add(c.localNode.id.toByteArrayBE()) - let ephKeys = ? KeyPair.random(rng) + let ephKeys = ? KeyPair.random(PKScheme.Secp256k1, rng) .mapErr((e: CryptoError) => ("Failed to create random key pair: " & $e).cstring) diff --git a/config.nims b/config.nims index 831d5cd..15e1770 100644 --- a/config.nims +++ b/config.nims @@ -1,4 +1,6 @@ +switch("define", "libp2p_pki_schemes=secp256k1") + include "build.nims" # begin Nimble config (version 2) diff --git a/tests/dht/test_helper.nim b/tests/dht/test_helper.nim index 38772ca..317399c 100644 --- a/tests/dht/test_helper.nim +++ b/tests/dht/test_helper.nim @@ -14,7 +14,7 @@ proc localAddress*(port: int): Address = Address(ip: ValidIpAddress.init("127.0.0.1"), port: Port(port)) proc example*(T: type PrivateKey, rng: ref HmacDrbgContext): PrivateKey = - PrivateKey.random(rng[]).expect("Valid rng for private key") + PrivateKey.random(PKScheme.Secp256k1, rng[]).expect("Valid rng for private key") proc example*(T: type NodeId, rng: ref HmacDrbgContext): NodeId = let diff --git a/tests/dht/test_providers.nim b/tests/dht/test_providers.nim index 3f01e52..1cc1154 100644 --- a/tests/dht/test_providers.nim +++ b/tests/dht/test_providers.nim @@ -125,7 +125,6 @@ suite "Providers Tests: node alone": debug "Providers:", providers check (providers.len == 0) - suite "Providers Tests: two nodes": var diff --git a/tests/testAllParallel.nim b/tests/testAllParallel.nim index 7bff2e1..f29c975 100644 --- a/tests/testAllParallel.nim +++ b/tests/testAllParallel.nim @@ -8,13 +8,13 @@ var cmds: seq[string] when defined(testsPart1) or defined(testsAll): cmds.add [ - "nim c -r tests/dht/test_providers.nim", - "nim c -r tests/dht/test_providermngr.nim", + "nim c -r --hints:off --verbosity:0 tests/dht/test_providers.nim", + "nim c -r --hints:off --verbosity:0 tests/dht/test_providermngr.nim", ] when defined(testsPart2) or defined(testsAll): cmds.add [ - "nim c -r tests/discv5/test_discoveryv5.nim", - "nim c -r tests/discv5/test_discoveryv5_encoding.nim", + "nim c -r --hints:off --verbosity:0 tests/discv5/test_discoveryv5.nim", + "nim c -r --hints:off --verbosity:0 tests/discv5/test_discoveryv5_encoding.nim", ] echo "Running Test Commands: ", cmds