Example #1
0
        public void Historical_batch_there_and_back()
        {
            HistoricalBatch container = new HistoricalBatch();

            container.BlockRoots[3] = Sha256.OfAnEmptyString;
            container.StateRoots[7] = Sha256.OfAnEmptyString;
            Span <byte> encoded = new byte[HistoricalBatch.SszLength];

            Ssz.Encode(encoded, container);
            HistoricalBatch?decoded = Ssz.DecodeHistoricalBatch(encoded);

            Assert.AreEqual(container, decoded);

            Merkle.Ize(out UInt256 root, container);
        }
Example #2
0
        public void Historical_batch_there_and_back()
        {
            Root[] blockRoots = Enumerable.Repeat(Root.Zero, Ssz.SlotsPerHistoricalRoot).ToArray();
            Root[] stateRoots = Enumerable.Repeat(Root.Zero, Ssz.SlotsPerHistoricalRoot).ToArray();
            blockRoots[3] = Sha256.RootOfAnEmptyString;
            stateRoots[7] = Sha256.RootOfAnEmptyString;
            HistoricalBatch container = new HistoricalBatch(blockRoots, stateRoots);
            Span <byte>     encoded   = new byte[Ssz.HistoricalBatchLength()];

            Ssz.Encode(encoded, container);
            HistoricalBatch?decoded = Ssz.DecodeHistoricalBatch(encoded);

            Assert.AreEqual(container, decoded);

            Merkle.Ize(out UInt256 root, container);
        }