/// <inheritdoc /> public Task ProvideAsync(Cid cid, bool advertise = true, CancellationToken cancel = default(CancellationToken)) { ContentRouter.Add(cid, this.Swarm.LocalPeer.Id); if (advertise) { Advertise(cid); } return(Task.CompletedTask); }
public void Add_Duplicate() { using (var router = new ContentRouter()) { router.Add(cid1, self.Id); router.Add(cid1, self.Id); var providers = router.Get(cid1); Assert.AreEqual(1, providers.Count()); Assert.AreEqual(self.Id, providers.First()); } }
public void Get_NotExpired() { using (var router = new ContentRouter()) { router.Add(cid1, self.Id, DateTime.MinValue); var providers = router.Get(cid1); Assert.AreEqual(0, providers.Count()); router.Add(cid1, self.Id, DateTime.MaxValue - router.ProviderTTL); providers = router.Get(cid1); Assert.AreEqual(1, providers.Count()); } }
public void Add_MultipleProviders() { using (var router = new ContentRouter()) { router.Add(cid1, self.Id); router.Add(cid1, other.Id); var providers = router.Get(cid1).ToArray(); Assert.AreEqual(2, providers.Length); CollectionAssert.Contains(providers, self.Id); CollectionAssert.Contains(providers, other.Id); } }