From be5d911cda973153311f0a378226fec540e7c1a1 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Tue, 15 Feb 2022 15:02:25 +0100 Subject: [PATCH] partial tests (AddProvider) --- tests/p2p/test_providers.nim | 59 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/tests/p2p/test_providers.nim b/tests/p2p/test_providers.nim index 17b8ff9..1453959 100644 --- a/tests/p2p/test_providers.nim +++ b/tests/p2p/test_providers.nim @@ -13,43 +13,42 @@ import std/sequtils, chronos, stew/byteutils, nimcrypto, testutils/unittests, eth/keys, - eth/p2p/enode, - ../../dht/[discovery, kademlia, node], - chronicles + ../../eth/p2p/providers, + chronicles, + ../../eth/p2p/discoveryv5/protocol as discv5_protocol, + ./discv5_test_helper, + libp2p/routing_record -proc localAddress(port: int): Address = - let port = Port(port) - result = Address(udpPort: port, tcpPort: port, - ip: parseIpAddress("127.0.0.1")) +proc initProvidersNode*( + rng: ref BrHmacDrbgContext, + privKey: keys.PrivateKey, + address: Address, + bootstrapRecords: openArray[Record] = []): + ProvidersProtocol = -proc initDiscoveryNode(privKey: PrivateKey, address: Address, - bootnodes: seq[ENode]): DiscoveryProtocol = - let node = newDiscoveryProtocol(privKey, address, bootnodes) - node.open() + let d = initDiscoveryNode(rng, privKey, address, bootstrapRecords) + ProvidersProtocol(discovery: d) - return node - -proc bootstrapNodes(nodecount: int, bootnodes: seq[ENode], rng = keys.newRng()) : Future[seq[DiscoveryProtocol]] {.async.} = +proc bootstrapNodes(nodecount: int, bootnodes: openArray[Record], rng = keys.newRng()) : seq[ProvidersProtocol] = for i in 0..