public void TestBasicStore() { var ps = new PeerStore(); var addrs = MakeAddresses(10); var i = 0; var pids = new List <PeerId>(); foreach (var a in addrs) { var p = new PeerId((i++).ToString()); pids.Add(p); ps.AddAddress(p, a, AddressManager.PermanentAddrTTL); } Assert.That(ps.Peers.Length, Is.EqualTo(10)); var pinfo = ps.PeerInfo(pids[0]); Assert.That(pinfo.Addresses[0], Is.EqualTo(addrs[0])); }
public void TestStoreProtoStore() { var ps = new PeerStore(); var p1 = (PeerId)"ef2ea34a"; var protos = new[] { "a", "b", "c", "d" }; ps.AddProtocols(p1, protos); var output = ps.GetProtocols(p1); Assert.That(output, Is.EqualTo(protos)); var sorted = protos.ToList(); sorted.Sort(); Assert.That(sorted.SequenceEqual(output), Is.True); var supported = ps.SupportsProtocols(p1, "q", "w", "a", "y", "b"); Assert.That(supported.Length, Is.EqualTo(2)); Assert.That(supported[0], Is.EqualTo("a")); Assert.That(supported[1], Is.EqualTo("b")); }