Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ETCM-207: Create DiscoveryKademliaIntegrationSpec.
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...very/it/src/io/iohk/scalanet/discovery/ethereum/v4/DiscoveryKademliaIntegrationSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.iohk.scalanet.discovery.ethereum.v4 | ||
|
||
import io.iohk.scalanet.kademlia.KademliaIntegrationSpec | ||
import io.iohk.scalanet.discovery.ethereum.Node | ||
import io.iohk.scalanet.discovery.ethereum.v4.mocks.MockSigAlg | ||
import monix.eval.Task | ||
import io.iohk.scalanet.discovery.crypto.SigAlg | ||
import io.iohk.scalanet.NetUtils | ||
import scodec.bits.BitVector | ||
import io.iohk.scalanet.kademlia.XorOrdering | ||
import cats.effect.Resource | ||
|
||
class DiscoveryKademliaIntegrationSpec extends KademliaIntegrationSpec("DiscoveryService with StaticUDPPeerGroup") { | ||
override type PeerRecord = Node | ||
|
||
class DiscoveryTestNode( | ||
override val self: Node, | ||
service: DiscoveryService | ||
) extends TestNode { | ||
override def getPeers: Task[Seq[Node]] = | ||
service.getNodes.map(_.toSeq) | ||
} | ||
|
||
implicit val sigalg: SigAlg = new MockSigAlg() | ||
|
||
override def generatePeerRecord(): Node = { | ||
val address = NetUtils.aRandomAddress | ||
val (publicKey, _) = sigalg.newKeyPair | ||
Node(publicKey, Node.Address(address.getAddress, address.getPort, address.getPort)) | ||
} | ||
|
||
override def makeXorOrdering(baseId: BitVector): Ordering[Node] = | ||
XorOrdering[Node](baseId)(_.id) | ||
|
||
override def startNode( | ||
selfRecord: PeerRecord, | ||
initialNodes: Set[PeerRecord], | ||
testConfig: TestNodeKademliaConfig | ||
): Resource[Task, TestNode] = ??? | ||
} |