mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-07 16:03:13 +00:00
18 lines
451 B
Nim
18 lines
451 B
Nim
|
|
import std/unittest
|
||
|
|
import pkg/libp2p
|
||
|
|
import pkg/ipfs/ipfsobject
|
||
|
|
import pkg/ipfs/dht/routing
|
||
|
|
|
||
|
|
suite "DHT routing table":
|
||
|
|
|
||
|
|
test "finds peers closest to some content":
|
||
|
|
let peer1 = PeerInfo(peer: PeerId(data: @[1'u8]))
|
||
|
|
let peer2 = PeerInfo(peer: PeerId(data: @[2'u8]))
|
||
|
|
let contentId = IpfsObject(data: @[]).cid
|
||
|
|
|
||
|
|
var table = RoutingTable()
|
||
|
|
table.add(peer1)
|
||
|
|
table.add(peer2)
|
||
|
|
|
||
|
|
check table.closest(contentId) == @[peer1, peer2]
|