예제 #1
0
        public void Decode_WhenDecodedCollectionIsGreaterThan55BytesReturnCorrectValues()
        {
            var bytes = RLP.Encode(new List <string>
            {
                "cat",
                "dog",
                "this is a collection",
                "that when encoded",
                "will be greater than 55 bytes",
                "127"
            });

            var result = RLP.Decode(bytes);

            Assert.IsTrue(result.Count == 6);
            Assert.IsTrue(result[0] == "cat");
            Assert.IsTrue(result[1] == "dog");
            Assert.IsTrue(result[2] == "this is a collection");
            Assert.IsTrue(result[3] == "that when encoded");
            Assert.IsTrue(result[4] == "will be greater than 55 bytes");
            Assert.IsTrue(result[5] == "127");
        }
예제 #2
0
        public void Decode_WhenEncodedCollectionIs56To255Bytes()
        {
            var input = RLP.Encode(new List <byte[]>
            {
                "cat".ToBytes(),
                "dog".ToBytes(),
                "this is a collection".ToBytes(),
                "that when encoded".ToBytes(),
                "will be greater than 55 bytes".ToBytes(),
                127.ToBytes(),
            });

            var result = RLP.Decode(input);

            Assert.IsTrue(result.Count == 6);
            Assert.IsTrue(result.All(x => x.IsCollection == false));
            Assert.AreEqual("cat", System.Text.Encoding.ASCII.GetString(result[0].String));
            Assert.AreEqual("dog", System.Text.Encoding.ASCII.GetString(result[1].String));
            Assert.AreEqual("this is a collection", System.Text.Encoding.ASCII.GetString(result[2].String));
            Assert.AreEqual("that when encoded", System.Text.Encoding.ASCII.GetString(result[3].String));
            Assert.AreEqual("will be greater than 55 bytes", System.Text.Encoding.ASCII.GetString(result[4].String));
            Assert.AreEqual(127, result[5].String[0]);
        }