示例#1
0
        public void Test()
        {
            ITunnelOverlap _ito   = new SimpleTunnelOverlap();
            Address        addr_x = new AHAddress(new RNGCryptoServiceProvider());

            byte[] addrbuff = Address.ConvertToAddressBuffer(addr_x.ToBigInteger() + (Address.Full / 2));
            Address.SetClass(addrbuff, AHAddress._class);
            Address addr_y = new AHAddress(addrbuff);

            ArrayList       addresses = new ArrayList();
            ConnectionTable ct_x      = new ConnectionTable();
            ConnectionTable ct_y      = new ConnectionTable();
            ConnectionTable ct_empty  = new ConnectionTable();

            for (int i = 1; i <= 10; i++)
            {
                addrbuff = Address.ConvertToAddressBuffer(addr_x.ToBigInteger() + (i * Address.Full / 16));
                Address.SetClass(addrbuff, AHAddress._class);
                addresses.Add(new AHAddress(addrbuff));

                TransportAddress ta = TransportAddressFactory.CreateInstance("brunet.tcp://158.7.0.1:5000");
                Edge             fe = new FakeEdge(ta, ta, TransportAddress.TAType.Tcp);
                ct_x.Add(new Connection(fe, addresses[i - 1] as AHAddress, "structured", null, null));
                if (i == 10)
                {
                    ct_y.Add(new Connection(fe, addresses[i - 1] as AHAddress, "structured", null, null));
                }
            }


            ConnectionType con_type = ConnectionType.Structured;
            IDictionary    id       = _ito.GetSyncMessage(null, addr_x, ct_x.GetConnections(con_type));

            Assert.AreEqual(_ito.EvaluateOverlap(ct_y.GetConnections(con_type), id)[0].Address, addresses[9], "Have an overlap!");
            Assert.AreEqual(_ito.EvaluateOverlap(ct_empty.GetConnections(con_type), id).Count, 0, "No overlap!");
            Assert.AreEqual(addresses.Contains(_ito.EvaluatePotentialOverlap(id)), true, "EvaluatePotentialOverlap returns valid!");
        }
示例#2
0
    public void Test()
    {
      ITunnelOverlap _ito = new SimpleTunnelOverlap();
      Address addr_x = new AHAddress(new RNGCryptoServiceProvider());
      byte[] addrbuff = Address.ConvertToAddressBuffer(addr_x.ToBigInteger() + (Address.Full / 2));
      Address.SetClass(addrbuff, AHAddress._class);
      Address addr_y = new AHAddress(addrbuff);

      ArrayList addresses = new ArrayList();
      ConnectionTable ct_x = new ConnectionTable();
      ConnectionTable ct_y = new ConnectionTable();
      ConnectionTable ct_empty = new ConnectionTable();
      for(int i = 1; i <= 10; i++) {
        addrbuff = Address.ConvertToAddressBuffer(addr_x.ToBigInteger() + (i * Address.Full / 16));
        Address.SetClass(addrbuff, AHAddress._class);
        addresses.Add(new AHAddress(addrbuff));

        TransportAddress ta = TransportAddressFactory.CreateInstance("brunet.tcp://158.7.0.1:5000");
        Edge fe = new FakeEdge(ta, ta, TransportAddress.TAType.Tcp);
        ct_x.Add(new Connection(fe, addresses[i - 1] as AHAddress, "structured", null, null));
        if(i == 10) {
          ct_y.Add(new Connection(fe, addresses[i - 1] as AHAddress, "structured", null, null));
        }
      }


      ConnectionType con_type = ConnectionType.Structured;
      IDictionary id = _ito.GetSyncMessage(null, addr_x, ct_x.GetConnections(con_type));
      Assert.AreEqual(_ito.EvaluateOverlap(ct_y.GetConnections(con_type), id)[0].Address, addresses[9], "Have an overlap!");
      Assert.AreEqual(_ito.EvaluateOverlap(ct_empty.GetConnections(con_type), id).Count, 0, "No overlap!");
      Assert.AreEqual(addresses.Contains(_ito.EvaluatePotentialOverlap(id)), true, "EvaluatePotentialOverlap returns valid!");
    }