예제 #1
0
        public void Uses_same_compression_as_py_zero()
        {
            byte[] bytesPy           = Bytes.FromHexString(File.ReadAllText(Path.Combine(TestContext.CurrentContext.WorkDirectory, "Rlpx", _pythonCompressedTestFileName)));
            byte[] bytesUncompressed = Bytes.FromHexString(File.ReadAllText(Path.Combine(TestContext.CurrentContext.WorkDirectory, "Rlpx", _uncompressedTestFileName)));

            ZeroSnappyEncoderForTest encoder = new ZeroSnappyEncoderForTest();

            byte[] compressed = encoder.TestEncode(Bytes.Concat(1, bytesUncompressed));
            Assert.AreEqual(bytesPy, compressed.Skip(1).ToArray());
        }
예제 #2
0
        public void Roundtrip_zero()
        {
            SnappyDecoderForTest     decoder = new SnappyDecoderForTest();
            ZeroSnappyEncoderForTest encoder = new ZeroSnappyEncoderForTest();

            byte[] expectedUncompressed = Bytes.FromHexString(File.ReadAllText(Path.Combine(TestContext.CurrentContext.WorkDirectory, "Rlpx", _uncompressedTestFileName)));
            byte[] compressed           = encoder.TestEncode(Bytes.Concat(1, expectedUncompressed));
            byte[] uncompressedResult   = decoder.TestDecode(compressed.Skip(1).ToArray());
            Assert.AreEqual(expectedUncompressed, uncompressedResult);
        }
예제 #3
0
        public void Uses_same_compression_as_py_zero_or_go()
        {
            byte[] bytesPy           = Bytes.FromHexString(File.ReadAllText(Path.Combine(TestContext.CurrentContext.WorkDirectory, "Rlpx", _pythonCompressedTestFileName)));
            byte[] bytesGo           = Bytes.FromHexString(File.ReadAllText(Path.Combine(TestContext.CurrentContext.WorkDirectory, "Rlpx", _pythonCompressedTestFileName)));
            byte[] bytesUncompressed = Bytes.FromHexString(File.ReadAllText(Path.Combine(TestContext.CurrentContext.WorkDirectory, "Rlpx", _uncompressedTestFileName)));

            ZeroSnappyEncoderForTest encoder = new ZeroSnappyEncoderForTest();

            byte[] compressed      = encoder.TestEncode(Bytes.Concat(1, bytesUncompressed));
            bool   oneOfTwoMatches = Bytes.AreEqual(bytesGo, compressed) || Bytes.AreEqual(bytesPy, compressed);

            Assert.True(oneOfTwoMatches);
        }