public void FixedContainer()
        {
            // Arrange
            var container = new FixedTestContainer()
            {
                A = (byte)0xab,
                B = (ulong)0xaabbccdd00112233,
                C = (uint)0x12345678
            };
            var tree = new SszTree(container.ToSszContainer());

            // Act
            var bytes        = tree.Serialize();
            var hashTreeRoot = tree.HashTreeRoot();

            // Assert
            var expectedByteString = "ab33221100ddccbbaa78563412";
            var byteString         = BitConverter.ToString(bytes.ToArray()).Replace("-", "").ToLowerInvariant();

            byteString.ShouldBe(expectedByteString);

            var expectedHashTreeRoot = Hash(
                Hash(Chunk(new byte[] { 0xab }), Chunk(new byte[] { 0x33, 0x22, 0x11, 0x00, 0xdd, 0xcc, 0xbb, 0xaa })),
                Hash(Chunk(new byte[] { 0x78, 0x56, 0x34, 0x12 }), Chunk(new byte[] { }))
                );
            var expectedHashTreeRootString = BitConverter.ToString(expectedHashTreeRoot).Replace("-", "").ToLowerInvariant();

            var hashTreeRootString = BitConverter.ToString(hashTreeRoot.ToArray()).Replace("-", "").ToLowerInvariant();

            hashTreeRootString.ShouldBe(expectedHashTreeRootString);
        }
Esempio n. 2
0
        private static IEnumerable <SszElement> GetValues(FixedTestContainer item)
        {
            yield return(new SszBasicElement(item.A));

            yield return(new SszBasicElement(item.B));

            yield return(new SszBasicElement(item.C));
        }
Esempio n. 3
0
 public static SszContainer ToSszContainer(this FixedTestContainer item)
 {
     return(new SszContainer(GetValues(item)));
 }