Exemplo n.º 1
0
        public void Decode_WhenEncodedDataIsGreaterThan55BytesReturnCorrectValue()
        {
            var bytes = RLP.Encode("This is a sentence. A sentence that is longer than 55 bytes.");

            var result = RLP.Decode(bytes);

            Assert.IsTrue(result.Count == 1);
            Assert.IsTrue(result[0] == "This is a sentence. A sentence that is longer than 55 bytes.");
        }
Exemplo n.º 2
0
        public void Decode_WhenDataIsSingleByteAndLessThanOrEqualTo127ReturnValue()
        {
            var bytes = RLP.Encode(10);

            var result = RLP.Decode(bytes);

            Assert.IsTrue(result.Count == 1);
            Assert.IsTrue(result[0] == "10");
        }
Exemplo n.º 3
0
        public void Decode_WhenEncodedDataIs0To55BytesReturnCorrectValue()
        {
            var bytes = RLP.Encode("cheese on toast");

            var result = RLP.Decode(bytes);

            Assert.IsTrue(result.Count == 1);
            Assert.IsTrue(result[0] == "cheese on toast");
        }
Exemplo n.º 4
0
        public void Decode_WhenEncodedLengthIs56To255Bytes()
        {
            var input = RLP.Encode("This is a sentence. A sentence that is longer than 55 bytes.".ToBytes());

            var result = RLP.Decode(input);

            Assert.IsTrue(result.Count == 1);
            Assert.IsTrue(result[0].IsCollection == false);
            Assert.AreEqual("This is a sentence. A sentence that is longer than 55 bytes.", System.Text.Encoding.ASCII.GetString(result[0].String));
        }
Exemplo n.º 5
0
        public void Decode_WhenEncodedLengthIs0To55Bytes()
        {
            var input = RLP.Encode("cheese on toast".ToBytes());

            var result = RLP.Decode(input);

            Assert.IsTrue(result.Count == 1);
            Assert.IsTrue(result[0].IsCollection == false);
            Assert.AreEqual("cheese on toast", System.Text.Encoding.ASCII.GetString(result[0].String));
        }
Exemplo n.º 6
0
        public void Decode_WhenEncodedIsSingleByteAndLessThanOrEqualTo127()
        {
            var item = RLP.Encode(127.ToBytes());

            var result = RLP.Decode(item);

            Assert.IsTrue(result.Count == 1);
            Assert.IsTrue(result[0].IsCollection == false);
            Assert.IsTrue(result[0].String[0] == 127);
        }
Exemplo n.º 7
0
        public void Decode_WhenEncodedCollectionIs0To55BytesReturnCorrectValues()
        {
            var bytes = RLP.Encode(new List <string> {
                "cat", "dog"
            });

            var result = RLP.Decode(bytes);

            Assert.IsTrue(result.Count == 2);
            Assert.IsTrue(result[0] == "cat");
            Assert.IsTrue(result[1] == "dog");
        }
Exemplo n.º 8
0
        public void Decode_WhenEncodedCollectionIs0To55Bytes()
        {
            var input = RLP.Encode(new List <byte[]> {
                "cat".ToBytes(), "dog".ToBytes()
            });

            var result = RLP.Decode(input);

            Assert.IsTrue(result.Count == 2);
            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));
        }
Exemplo n.º 9
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");
        }
Exemplo n.º 10
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]);
        }