Esempio n. 1
0
        public async Task ConnectionEstablished()
        {
            var peerB = new Peer
            {
                AgentVersion = "peerB",
                Id           = "QmdpwjdB94eNm2Lcvp9JqoCxswo3AKQqjLuNZyLixmCM1h",
                PublicKey    =
                    "CAASXjBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDlTSgVLprWaXfmxDr92DJE1FP0wOexhulPqXSTsNh5ot6j+UiuMgwb0shSPKzLx9AuTolCGhnwpTBYHVhFoBErAgMBAAE="
            };
            var swarmB = new SwarmService {
                LocalPeer = peerB
            };
            var swarmBConnections = 0;

            swarmB.ConnectionEstablished += (s, e) => { ++swarmBConnections; };
            await swarmB.StartAsync();

            var peerBAddress = await swarmB.StartListeningAsync("/ip4/127.0.0.1/tcp/0");

            var swarm = new SwarmService {
                LocalPeer = _self
            };
            var swarmConnections = 0;

            swarm.ConnectionEstablished += (s, e) => { ++swarmConnections; };
            await swarm.StartAsync();

            try
            {
                var _ = await swarm.ConnectAsync(peerBAddress);

                Assert.AreEqual(1, swarmConnections);

                // wait for swarmB to settle
                var endTime = DateTime.Now.AddSeconds(3);
                while (true)
                {
                    if (DateTime.Now > endTime)
                    {
                        Assert.Fail("swarmB did not raise event.");
                    }

                    if (swarmBConnections == 1)
                    {
                        break;
                    }

                    await Task.Delay(100).ConfigureAwait(false);
                }
            }
            finally
            {
                await swarm.StopAsync();

                await swarmB.StopAsync();
            }
        }
Esempio n. 2
0
        public void NewPeerAddress()
        {
            var swarm = new SwarmService {
                LocalPeer = _self
            };

            swarm.RegisterPeerAddress(_mars);
            Assert.IsTrue(swarm.KnownPeerAddresses.Contains(_mars));
        }
Esempio n. 3
0
        public DfsService(IBitSwapApi bitSwapApi,
                          BitSwapService bitSwapService,
                          IBlockApi blockApi,
                          IBlockRepositoryApi blockRepositoryApi,
                          IBootstrapApi bootstrapApi,
                          IConfigApi configApi,
                          IDagApi dagApi,
                          IDhtApi dhtApi,
                          IDnsApi dnsApi,
                          KatDhtService dhtService,
                          IUnixFsApi unixFsApi,
                          IKeyApi keyApi,
                          INameApi nameApi,
                          IObjectApi objectApi,
                          IPinApi pinApi,
                          Ping1 pingService,
                          IPubSubApi pubSubApi,
                          PubSubService pubSubService,
                          IStatsApi statsApi,
                          ISwarmApi swarmApi,
                          SwarmService swarmService,
                          DfsOptions dfsOptions,
                          IHashProvider hashProvider,
                          DfsState dfsState,
                          IPasswordManager passwordManager,
                          IMigrationManager migrationManager,
                          Peer localPeer)
        {
            BitSwapApi         = bitSwapApi;
            BitSwapService     = bitSwapService;
            BlockApi           = blockApi;
            BlockRepositoryApi = blockRepositoryApi;
            BootstrapApi       = bootstrapApi;
            ConfigApi          = configApi;
            DagApi             = dagApi;
            DhtApi             = dhtApi;
            DhtService         = dhtService;
            UnixFsApi          = unixFsApi;
            KeyApi             = keyApi;
            NameApi            = nameApi;
            ObjectApi          = objectApi;
            PinApi             = pinApi;
            PingService        = pingService;
            PubSubApi          = pubSubApi;
            PubSubService      = pubSubService;
            StatsApi           = statsApi;
            SwarmApi           = swarmApi;
            SwarmService       = swarmService;
            Options            = dfsOptions;
            _hashProvider      = hashProvider;
            _dfsState          = dfsState;
            DnsApi             = dnsApi;
            MigrationManager   = migrationManager;
            LocalPeer          = localPeer;

            InitAsync().Wait();
        }
Esempio n. 4
0
        public void Start_NoLocalPeer()
        {
            var swarm = new SwarmService();

            ExceptionAssert.Throws <NotSupportedException>(() =>
            {
                swarm.StartAsync().Wait();
            });
        }
Esempio n. 5
0
        public async Task PermanentlyDead()
        {
            var peer = new Peer
            {
                Id        = "QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb",
                Addresses = new MultiAddress[]
                {
                    "/ip4/127.0.0.1/tcp/4040/ipfs/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb"
                }
            };
            var swarm = new SwarmService {
                LocalPeer = self
            };
            var manager = new PeerManager
            {
                SwarmService   = swarm,
                InitialBackoff = TimeSpan.FromMilliseconds(100),
                MaxBackoff     = TimeSpan.FromMilliseconds(200),
            };

            Assert.AreEqual(0, manager.DeadPeers.Count);

            try
            {
                await swarm.StartAsync();

                await manager.StartAsync();

                try
                {
                    await swarm.ConnectAsync(peer);
                }
                catch
                {
                    // ignored
                }

                Assert.AreEqual(1, manager.DeadPeers.Count);

                var end = DateTime.Now + TimeSpan.FromSeconds(6);
                while (DateTime.Now <= end)
                {
                    if (manager.DeadPeers[peer].NextAttempt == DateTime.MaxValue)
                    {
                        return;
                    }
                }
                Assert.Fail("not truely dead");
            }
            finally
            {
                await swarm.StopAsync();

                await manager.StopAsync();
            }
        }
Esempio n. 6
0
        public async Task Start_Stop()
        {
            var swarm = new SwarmService
            {
                LocalPeer = _self
            };
            await swarm.StartAsync();

            await swarm.StopAsync();
        }
Esempio n. 7
0
        public async Task Backoff_Increases()
        {
            var peer = new Peer
            {
                Id        = "QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTxx",
                Addresses = new MultiAddress[]
                {
                    "/ip4/127.0.0.1/tcp/4040/ipfs/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTxx"
                }
            };
            var swarm = new SwarmService {
                LocalPeer = self
            };
            var manager = new PeerManager
            {
                SwarmService   = swarm,
                InitialBackoff = TimeSpan.FromMilliseconds(100),
            };

            Assert.AreEqual(0, manager.DeadPeers.Count);

            try
            {
                await swarm.StartAsync();

                await manager.StartAsync();

                try
                {
                    await swarm.ConnectAsync(peer);
                }
                catch
                {
                    // ignored
                }

                Assert.AreEqual(1, manager.DeadPeers.Count);

                var end = DateTime.Now + TimeSpan.FromSeconds(4);
                while (DateTime.Now <= end)
                {
                    if (manager.DeadPeers[peer].Backoff > manager.InitialBackoff)
                    {
                        return;
                    }
                }
                Assert.Fail("backoff did not increase");
            }
            finally
            {
                await swarm.StopAsync();

                await manager.StopAsync();
            }
        }
Esempio n. 8
0
        public void NewPeerAddress_Duplicate()
        {
            var swarm = new SwarmService {
                LocalPeer = _self
            };

            swarm.RegisterPeerAddress(_mars);
            Assert.AreEqual(1, swarm.KnownPeerAddresses.Count());

            swarm.RegisterPeerAddress(_mars);
            Assert.AreEqual(1, swarm.KnownPeerAddresses.Count());
        }
Esempio n. 9
0
        public void NewPeerAddress_InvalidAddress_MissingPeerId()
        {
            var swarm = new SwarmService {
                LocalPeer = _self
            };

            ExceptionAssert.Throws <Exception>(() =>
            {
                var _ = swarm.RegisterPeerAddress("/ip4/10.1.10.10/tcp/29087");
            });
            Assert.AreEqual(0, swarm.KnownPeerAddresses.Count());
        }
Esempio n. 10
0
        /// <inheritdoc />
        public Task StopAsync()
        {
            _log.Debug("Stopping");

            SwarmService.RemoveProtocol(this);
            SwarmService.PeerDiscovered -= Swarm_PeerDiscovered;
            SwarmService.PeerRemoved    -= Swarm_PeerRemoved;

            Stopped?.Invoke(this, EventArgs.Empty);
            ContentRouter?.Dispose();
            return(Task.CompletedTask);
        }
Esempio n. 11
0
#pragma warning disable VSTHRD100 // Avoid async void methods
        /// <summary>
        ///     Fired when a peer is discovered.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="peer"></param>
        /// <remarks>
        ///     Registers the peer with the <see cref="SwarmService" />.
        /// </remarks>
        private void OnPeerDiscovered(object sender, Peer peer)
#pragma warning restore VSTHRD100 // Avoid async void methods
        {
            try
            {
                SwarmService.RegisterPeer(peer);
            }
            catch (Exception ex)
            {
                Log.Warning("failed to register peer " + peer, ex);

                // eat it, nothing we can do.
            }
        }
Esempio n. 12
0
        /// <summary>
        ///   Fired when a peer is discovered.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="peer"></param>
        /// <remarks>
        ///   Registers the peer with the <see cref="SwarmService"/>.
        /// </remarks>
        async void OnPeerDiscovered(object sender, Peer peer)
        {
            try
            {
                var swarm = await SwarmService.ConfigureAwait(false);

                swarm.RegisterPeer(peer);
            }
            catch (Exception ex)
            {
                log.Warn("failed to register peer " + peer, ex);
                // eat it, nothing we can do.
            }
        }
Esempio n. 13
0
        public async Task Listening_IPv6Any()
        {
            var peerA = new Peer
            {
                Id           = _self.Id,
                PublicKey    = _self.PublicKey,
                AgentVersion = _self.AgentVersion
            };
            MultiAddress addr   = "/ip6/::/tcp/0";
            var          swarmA = new SwarmService {
                LocalPeer = peerA
            };
            var peerB = new Peer
            {
                Id           = _other.Id,
                PublicKey    = _other.PublicKey,
                AgentVersion = _other.AgentVersion
            };
            var swarmB = new SwarmService {
                LocalPeer = peerB
            };
            await swarmA.StartAsync();

            await swarmB.StartAsync();

            try
            {
                var another = await swarmA.StartListeningAsync(addr);

                Assert.IsFalse(peerA.Addresses.Contains(addr));
                Assert.IsTrue(peerA.Addresses.Contains(another));

                await swarmB.ConnectAsync(another);

                Assert.IsTrue(swarmB.KnownPeers.Contains(peerA));

                // TODO: Assert.IsTrue(swarmA.KnownPeers.Contains(peerB));

                await swarmA.StopListeningAsync(addr);

                Assert.AreEqual(0, peerA.Addresses.Count());
            }
            finally
            {
                await swarmA.StopAsync();

                await swarmB.StopAsync();
            }
        }
Esempio n. 14
0
        public async Task RemotePeer_Contains_ConnectedAddress2()
        {
            // Only works on Windows because connecting to 127.0.0.100 is allowed
            // when listening on 0.0.0.0
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                return;
            }

            var peerB = new Peer
            {
                AgentVersion = "peerB",
                Id           = "QmdpwjdB94eNm2Lcvp9JqoCxswo3AKQqjLuNZyLixmCM1h",
                PublicKey    =
                    "CAASXjBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDlTSgVLprWaXfmxDr92DJE1FP0wOexhulPqXSTsNh5ot6j+UiuMgwb0shSPKzLx9AuTolCGhnwpTBYHVhFoBErAgMBAAE="
            };
            var swarmB = new SwarmService {
                LocalPeer = peerB
            };
            await swarmB.StartAsync();

            var peerBAddress = await swarmB.StartListeningAsync("/ip4/0.0.0.0/tcp/0");

            var peerBPort = peerBAddress.Protocols[1].Value;

            Assert.IsTrue(peerB.Addresses.Any());

            var swarm = new SwarmService {
                LocalPeer = _self
            };
            await swarm.StartAsync();

            try
            {
                MultiAddress ma         = $"/ip4/127.0.0.100/tcp/{peerBPort}/ipfs/{peerB.Id}";
                var          connection = await swarm.ConnectAsync(ma);

                var remote = connection.RemotePeer;
                Assert.AreEqual(remote.ConnectedAddress, ma);
                CollectionAssert.Contains(remote.Addresses.ToArray(), ma);
            }
            finally
            {
                await swarm.StopAsync();

                await swarmB.StopAsync();
            }
        }
Esempio n. 15
0
        /// <inheritdoc />
        public Task StartAsync()
        {
            _log.Debug("Starting");

            foreach (var protocol in Protocols)
            {
                SwarmService.AddProtocol(protocol);
            }

            SwarmService.ConnectionEstablished += Swarm_ConnectionEstablished;

            // TODO: clear the stats.
            _peerLedgers.Clear();

            return(Task.CompletedTask);
        }
Esempio n. 16
0
        public async Task IsRunning()
        {
            var swarm = new SwarmService {
                LocalPeer = _self
            };

            Assert.IsFalse(swarm.IsRunning);

            await swarm.StartAsync();

            Assert.IsTrue(swarm.IsRunning);

            await swarm.StopAsync();

            Assert.IsFalse(swarm.IsRunning);
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        /// <summary>
        ///   Advertise that we can provide the CID to the X closest peers
        ///   of the CID.
        /// </summary>
        /// <param name="cid">
        ///   The CID to advertise.ipfs
        /// </param>
        /// <remarks>
        ///   This starts a background process to send the AddProvider message
        ///   to the 4 closest peers to the <paramref name="cid"/>.
        /// </remarks>
        public void Advertise(Cid cid)
        {
            _ = Task.Run(async() =>
            {
                var advertsNeeded = 4;
                var message       = new DhtMessage
                {
                    Type          = MessageType.AddProvider,
                    Key           = cid.Hash.ToArray(),
                    ProviderPeers = new[]
                    {
                        new DhtPeerMessage
                        {
                            Id        = SwarmService.LocalPeer.Id.ToArray(),
                            Addresses = SwarmService.LocalPeer.Addresses
                                        .Select(a => a.WithoutPeerId().ToArray())
                                        .ToArray()
                        }
                    }
                };

                var peers = RoutingTable
                            .NearestPeers(cid.Hash)
                            .Where(p => p != SwarmService.LocalPeer);

                foreach (var peer in peers)
                {
                    try
                    {
                        await using (var stream = await SwarmService.DialAsync(peer, ToString()))
                        {
                            Serializer.SerializeWithLengthPrefix(stream, message, PrefixStyle.Base128);
                            await stream.FlushAsync();
                        }

                        if (--advertsNeeded == 0)
                        {
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        // eat it.  This is fire and forget.
                    }
                }
            });
        }
Esempio n. 19
0
        public async Task Noop_OnPeerDiscovered_When_NotBelow_MinConnections()
        {
            var swarmA = new SwarmService {
                LocalPeer = peerA
            };
            await swarmA.StartAsync();

            await swarmA.StartListeningAsync("/ip4/127.0.0.1/tcp/0");

            var swarmB = new SwarmService {
                LocalPeer = peerB
            };
            await swarmB.StartAsync();

            var peerBAddress = await swarmB.StartListeningAsync("/ip4/127.0.0.1/tcp/0");

            try
            {
                using (new AutoDialer(swarmA)
                {
                    MinConnections = 0
                })
                {
                    var other = swarmA.RegisterPeerAddress(peerBAddress);

                    // wait for the connection.
                    var endTime = DateTime.Now.AddSeconds(3);
                    while (other.ConnectedAddress == null)
                    {
                        if (DateTime.Now > endTime)
                        {
                            return;
                        }

                        await Task.Delay(100);
                    }

                    Assert.Fail("Autodial should not happen");
                }
            }
            finally
            {
                await swarmA.StopAsync();

                await swarmB.StopAsync();
            }
        }
Esempio n. 20
0
        public async Task StoppedEventRaised()
        {
            var swarm = new SwarmService {
                LocalPeer = self
            };
            var dht = new DhtService {
                SwarmService = swarm
            };
            var stopped = false;

            dht.Stopped += (s, e) => { stopped = true; };
            await dht.StartAsync();

            await dht.StopAsync();

            Assert.IsTrue(stopped);
        }
Esempio n. 21
0
        /// <inheritdoc />
        public Task StopAsync()
        {
            _log.Debug("Stopping");

            SwarmService.ConnectionEstablished -= Swarm_ConnectionEstablished;
            foreach (var protocol in Protocols)
            {
                SwarmService.RemoveProtocol(protocol);
            }

            foreach (var cid in _wants.Keys)
            {
                Unwant(cid);
            }

            return(Task.CompletedTask);
        }
Esempio n. 22
0
        /// <inheritdoc />
        public Task StartAsync()
        {
            _log.Debug("Starting");

            RoutingTable  = new RoutingTable(SwarmService.LocalPeer);
            ContentRouter = new ContentRouter();
            SwarmService.AddProtocol(this);
            SwarmService.PeerDiscovered += Swarm_PeerDiscovered;
            SwarmService.PeerRemoved    += Swarm_PeerRemoved;

            foreach (var peer in SwarmService.KnownPeers)
            {
                RoutingTable.Add(peer);
            }

            return(Task.CompletedTask);
        }
Esempio n. 23
0
        public void Listening_MissingTransport()
        {
            var peer = new Peer
            {
                Id           = _self.Id,
                PublicKey    = _self.PublicKey,
                AgentVersion = _self.AgentVersion
            };
            var swarm = new SwarmService {
                LocalPeer = peer
            };

            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                var _ = swarm.StartListeningAsync("/ip4/127.0.0.1").Result;
            });
            Assert.AreEqual(0, peer.Addresses.Count());
        }
Esempio n. 24
0
        public void NewPeerAddress_Self()
        {
            var swarm = new SwarmService {
                LocalPeer = _self
            };
            var selfAddress = "/ip4/178.62.158.247/tcp/4001/ipfs/" + _self.Id;

            ExceptionAssert.Throws <Exception>(() =>
            {
                var _ = swarm.RegisterPeerAddress(selfAddress);
            });

            selfAddress = "/ip4/178.62.158.247/tcp/4001/p2p/" + _self.Id;
            ExceptionAssert.Throws <Exception>(() =>
            {
                var _ = swarm.RegisterPeerAddress(selfAddress);
            });
        }
Esempio n. 25
0
        public async Task Connect_WithSomeUnreachableAddresses()
        {
            const string bid   = "QmdpwjdB94eNm2Lcvp9JqoCxswo3AKQqjLuNZyLixmCM1h";
            var          peerB = new Peer
            {
                AgentVersion = "peerB",
                Id           = bid,
                PublicKey    =
                    "CAASXjBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDlTSgVLprWaXfmxDr92DJE1FP0wOexhulPqXSTsNh5ot6j+UiuMgwb0shSPKzLx9AuTolCGhnwpTBYHVhFoBErAgMBAAE=",
                Addresses = new MultiAddress[]
                {
                    $"/ip4/127.0.0.2/tcp/2/ipfs/{bid}",
                    $"/ip4/127.0.0.3/tcp/3/ipfs/{bid}"
                }
            };
            var swarmB = new SwarmService {
                LocalPeer = peerB
            };
            await swarmB.StartAsync();

            var _ = await swarmB.StartListeningAsync("/ip4/127.0.0.1/tcp/0");

            Assert.IsTrue(peerB.Addresses.Any());

            var swarm = new SwarmService {
                LocalPeer = _self
            };
            await swarm.StartAsync();

            try
            {
                var remotePeer = (await swarm.ConnectAsync(peerB)).RemotePeer;
                Assert.IsNotNull(remotePeer.ConnectedAddress);
                Assert.AreEqual(peerB.PublicKey, remotePeer.PublicKey);
                Assert.IsTrue(remotePeer.IsValid());
                Assert.IsTrue(swarm.KnownPeers.Contains(peerB));
            }
            finally
            {
                await swarm.StopAsync();

                await swarmB.StopAsync();
            }
        }
Esempio n. 26
0
        public void Connecting_To_Self()
        {
            var swarm = new SwarmService {
                LocalPeer = _self
            };

            swarm.StartAsync().Wait();
            try
            {
                ExceptionAssert.Throws <Exception>(() =>
                {
                    var _ = swarm.ConnectAsync(_earth).Result;
                });
            }
            finally
            {
                swarm.StopAsync().Wait();
            }
        }
Esempio n. 27
0
        public async Task PeerDisconnected()
        {
            var peerB = new Peer
            {
                AgentVersion = "peerB",
                Id           = "QmdpwjdB94eNm2Lcvp9JqoCxswo3AKQqjLuNZyLixmCM1h",
                PublicKey    =
                    "CAASXjBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDlTSgVLprWaXfmxDr92DJE1FP0wOexhulPqXSTsNh5ot6j+UiuMgwb0shSPKzLx9AuTolCGhnwpTBYHVhFoBErAgMBAAE="
            };
            var swarmB = new SwarmService {
                LocalPeer = peerB
            };
            await swarmB.StartAsync();

            var peerBAddress = await swarmB.StartListeningAsync("/ip4/127.0.0.1/tcp/0");

            var swarm = new SwarmService {
                LocalPeer = _self
            };
            var swarmConnections = 0;

            swarm.ConnectionEstablished += (s, e) => { ++swarmConnections; };
            swarm.PeerDisconnected      += (s, e) => { --swarmConnections; };
            await swarm.StartAsync();

            try
            {
                var _ = await swarm.ConnectAsync(peerBAddress);

                Assert.AreEqual(1, swarmConnections);

                await swarm.StopAsync();

                Assert.AreEqual(0, swarmConnections);
            }
            finally
            {
                await swarm.StopAsync();

                await swarmB.StopAsync();
            }
        }
Esempio n. 28
0
        public void Connecting_To_Blacklisted_Address()
        {
            var swarm = new SwarmService {
                LocalPeer = _self
            };

            swarm.BlackList.Add(_mars);
            swarm.StartAsync().Wait();
            try
            {
                ExceptionAssert.Throws <Exception>(() =>
                {
                    var _ = swarm.ConnectAsync(_mars).Result;
                });
            }
            finally
            {
                swarm.StopAsync().Wait();
            }
        }
Esempio n. 29
0
        public async Task Connecting_To_Self_Indirect()
        {
            var swarm = new SwarmService {
                LocalPeer = _self
            };
            await swarm.StartAsync();

            try
            {
                var listen = await swarm.StartListeningAsync("/ip4/127.0.0.1/tcp/0");

                var bad = listen.Clone();
                bad.Protocols[2].Value = "QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb";
                ExceptionAssert.Throws <Exception>(() => { swarm.ConnectAsync(bad).Wait(); });
            }
            finally
            {
                await swarm.StopAsync();
            }
        }
Esempio n. 30
0
        public async Task ProcessAddProviderMessage()
        {
            var swarm = new SwarmService {
                LocalPeer = self
            };
            var dht = new DhtService {
                SwarmService = swarm
            };
            await dht.StartAsync();

            try
            {
                Cid cid =
                    "zBunRGrmCGokA1oMESGGTfrtcMFsVA8aEtcNzM54akPWXF97uXCqTjF3GZ9v8YzxHrG66J8QhtPFWwZebRZ2zeUEELu67";
                var request = new DhtMessage
                {
                    Type          = MessageType.AddProvider,
                    Key           = cid.Hash.ToArray(),
                    ProviderPeers = new[]
                    {
                        new DhtPeerMessage
                        {
                            Id        = other.Id.ToArray(),
                            Addresses = other.Addresses.Select(a => a.ToArray()).ToArray()
                        }
                    }
                };
                var response = dht.ProcessAddProvider(other, request, new DhtMessage());
                Assert.IsNull(response);
                var providers = dht.ContentRouter.Get(cid).ToArray();
                Assert.AreEqual(1, providers.Length);
                Assert.AreEqual(other.Id, providers[0]);

                var provider = swarm.KnownPeers.Single(p => p == other);
                Assert.AreNotEqual(0, provider.Addresses.Count());
            }
            finally
            {
                await dht.StopAsync();
            }
        }