public async Task FindPeer_Closest() { var unknownPeer = new MultiHash("QmdpwjdB94eNm2Lcvp9JqoCxswo3AKQqjLuNZyLixmCxxx"); var swarm = new Swarm { LocalPeer = self }; await swarm.StartAsync(); var dht = new Dht1 { Swarm = swarm }; await dht.StartAsync(); dht.RoutingTable.Add(other); try { var peer = await dht.FindPeerAsync(unknownPeer); Assert.AreEqual(other, peer); } finally { await swarm.StopAsync(); await dht.StopAsync(); } }
public async Task QueryIsCancelled_WhenDhtStops() { var unknownPeer = new MultiHash("QmdpwjdB94eNm2Lcvp9JqoCxswo3AKQqjLuNZyLixmCxxx"); var swarm = new Swarm { LocalPeer = self }; swarm.RegisterPeerAddress("/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd"); swarm.RegisterPeerAddress("/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64"); var dht = new Dht1 { Swarm = swarm }; await dht.StartAsync(); var task = dht.FindPeerAsync(unknownPeer); await Task.Delay(400); await dht.StopAsync(); }
public async Task FindPeer_NoPeers() { var unknownPeer = new MultiHash("QmdpwjdB94eNm2Lcvp9JqoCxswo3AKQqjLuNZyLixmCxxx"); var swarm = new Swarm { LocalPeer = self }; var dht = new Dht1 { Swarm = swarm }; await dht.StartAsync(); try { var peer = await dht.FindPeerAsync(unknownPeer); Assert.IsNull(peer); } finally { await dht.StopAsync(); } }