示例#1
0
        public void CanSerializeDeserializePeerTable()
        {
            AddressManager addrman = new AddressManager();

            addrman.SavePeerFile("CanSerializeDeserializePeerTable.dat", Network.Main);
            AddressManager.LoadPeerFile("CanSerializeDeserializePeerTable.dat", Network.Main);

            addrman           = AddressManager.LoadPeerFile("../../../data/peers.dat", Network.Main);
            addrman.DebugMode = true;
            addrman.Check();
            addrman.SavePeerFile("serializerPeer.dat", Network.Main);

            AddressManager addrman2 = AddressManager.LoadPeerFile("serializerPeer.dat", Network.Main);

            addrman2.DebugMode = true;
            addrman2.Check();
            addrman2.SavePeerFile("serializerPeer2.dat", Network.Main);

            var original = File.ReadAllBytes("serializerPeer2.dat");
            var after    = File.ReadAllBytes("serializerPeer.dat");

            Assert.True(original.SequenceEqual(after));
        }
示例#2
0
        public void CanSerializeDeserializePeerTable()
        {
            AddressManager addrman = new AddressManager();

            addrman.SavePeerFile("strat-CanSerializeDeserializePeerTable.dat", Network.StratisMain);
            AddressManager.LoadPeerFile("strat-CanSerializeDeserializePeerTable.dat", Network.StratisMain);

            addrman           = AddressManager.LoadPeerFile(TestDataLocations.DataFolder("peers.dat"), Network.StratisMain);
            addrman.DebugMode = true;
            addrman.Check();
            addrman.SavePeerFile("serializerPeer.dat", Network.StratisMain);

            AddressManager addrman2 = AddressManager.LoadPeerFile("serializerPeer.dat", Network.StratisMain);

            addrman2.DebugMode = true;
            addrman2.Check();
            addrman2.SavePeerFile("serializerPeer2.dat", Network.StratisMain);

            var original = File.ReadAllBytes("serializerPeer2.dat");
            var after    = File.ReadAllBytes("serializerPeer.dat");

            Assert.True(original.SequenceEqual(after));
        }