public void DeregisterPeer() { var swarm = new SwarmService { LocalPeer = _self }; swarm.RegisterPeer(_other); Assert.IsTrue(swarm.KnownPeers.Contains(_other)); Peer removedPeer = null; swarm.PeerRemoved += (s, e) => removedPeer = e; swarm.DeregisterPeer(_other); Assert.IsFalse(swarm.KnownPeers.Contains(_other)); Assert.AreEqual(_other, removedPeer); }
public async Task RemovesPeerFromRoutingTable() { var swarm = new SwarmService { LocalPeer = self }; var dht = new DhtService { SwarmService = swarm }; await dht.StartAsync(); try { var peer = swarm.RegisterPeerAddress( "/ip4/127.0.0.1/tcp/4001/ipfs/QmdpwjdB94eNm2Lcvp9JqoCxswo3AKQqjLuNZyLixmCM1h"); Assert.IsTrue(dht.RoutingTable.Contains(peer)); swarm.DeregisterPeer(peer); Assert.IsFalse(dht.RoutingTable.Contains(peer)); } finally { await dht.StopAsync(); } }