Inheritance: PeerMessage
示例#1
0
        public void BitfieldCorrupt()
        {
            var data = new[] { true, false, false, true, false, true, false, true, false, true, false, true, false, false, false, true };
            var encoded = new BitfieldMessage(new BitField(data)).Encode();

            PeerMessage.DecodeMessage(encoded, 0, encoded.Length, _testRig.Manager);
        }
示例#2
0
        public void BitfieldCorrupt()
        {
            bool[] data = new bool[] { true, false, false, true, false, true, false, true, false, true, false, true, false, false, false, true };
            byte[] encoded = new BitfieldMessage(new BitField(data)).Encode();

            PeerMessage.DecodeMessage(encoded, 0, encoded.Length, testRig.Manager);
        }
示例#3
0
        public void BitFieldEncoding()
        {
            var data = new[] { true, false, false, true, false, true, false, true, false, true,
                                       false, true, false, false, false, true, true, true, false, false,
                                       false, true, false, true, false, false, true, false, true, false,
                                       true, true, false, false, true, false, false, true, true, false };

            var encoded = new BitfieldMessage(new BitField(data)).Encode();

            var message = (BitfieldMessage) PeerMessage.DecodeMessage(encoded, 0, encoded.Length, _testRig.Manager);
            Assert.AreEqual(data.Length, message.BitField.Length, "#1");
            for (var i = 0; i < data.Length; i++)
                Assert.AreEqual(data[i], message.BitField[i], "#2." + i);
        }
示例#4
0
        public void BitFieldEncoding()
        {
            bool[] data = new bool[] { true, false, false, true, false, true, false, true, false, true,
                                       false, true, false, false, false, true, true, true, false, false,
                                       false, true, false, true, false, false, true, false, true, false,
                                       true, true, false, false, true, false, false, true, true, false };
            byte[] encoded = new BitfieldMessage(new BitField(data)).Encode();

            BitfieldMessage m = (BitfieldMessage)PeerMessage.DecodeMessage(encoded, 0, encoded.Length, testRig.Manager);
            Assert.AreEqual(data.Length, m.BitField.Length, "#1");
            for (int i = 0; i < data.Length; i++)
                Assert.AreEqual(data[i], m.BitField[i], "#2." + i);
        }