Пример #1
0
        public void DecodeEndodedListWithOneLongElement()
        {
            byte[][] bytes = new byte[1][];

            byte[] data = new byte[256 * 256];

            for (int j = 0; j < data.Length; j++)
            {
                data[j] = (byte)(j);
            }

            bytes[0] = Rlp.Encode(data);

            byte[] list = Rlp.EncodeList(bytes);

            var result = Rlp.DecodeList(list);

            Assert.IsNotNull(result);
            Assert.AreEqual(bytes.Length, result.Count);

            for (int k = 0; k < bytes.Length; k++)
            {
                Assert.IsTrue(bytes[k].SequenceEqual(result[k]));
            }
        }
Пример #2
0
        public void DecodeEncodeEmptyList()
        {
            var result = Rlp.DecodeList(Rlp.EncodeList(new byte[0]));

            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.Count);
        }
Пример #3
0
        public void DecodeSimpleListWithOneElement()
        {
            var result = Rlp.DecodeList(Rlp.EncodeList(new byte[] { 0x01 }));

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);

            var elem = result[0];

            Assert.IsNotNull(elem);
            Assert.AreEqual(1, elem.Length);
            Assert.AreEqual(0x01, elem[0]);
        }
Пример #4
0
        public void DecodeEndodedListWithTwoElements()
        {
            byte[] bytes1 = Rlp.Encode(new byte[] { 0x01 });
            byte[] bytes2 = Rlp.Encode(new byte[] { 0x02 });

            byte[] list = Rlp.EncodeList(bytes1, bytes2);

            var result = Rlp.DecodeList(list);

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count);

            Assert.IsTrue(bytes1.SequenceEqual(result[0]));
            Assert.IsTrue(bytes2.SequenceEqual(result[1]));
        }