Ejemplo n.º 1
0
        public void Attestation_data_there_and_back()
        {
            AttestationData container = new AttestationData(
                new Slot(1),
                new CommitteeIndex(2),
                Sha256.RootOfAnEmptyString,
                new Checkpoint(new Epoch(1), Sha256.RootOfAnEmptyString),
                new Checkpoint(new Epoch(2), Sha256.RootOfAnEmptyString));

            Span <byte> encoded = new byte[Ssz.AttestationDataLength];

            Ssz.Encode(encoded, container);
            AttestationData decoded = Ssz.DecodeAttestationData(encoded);

            Assert.AreEqual(container, decoded);

            Span <byte> encodedAgain = new byte[Ssz.AttestationDataLength];

            Ssz.Encode(encodedAgain, decoded);
            Assert.True(Bytes.AreEqual(encodedAgain, encoded));

            Merkle.Ize(out UInt256 root, container);
        }
Ejemplo n.º 2
0
        public void Attestation_data_there_and_back()
        {
            AttestationData container = new AttestationData();

            container.Slot            = new Slot(1);
            container.CommitteeIndex  = new CommitteeIndex(2);
            container.BeaconBlockRoot = Sha256.OfAnEmptyString;
            container.Source          = new Checkpoint(new Epoch(1), Sha256.OfAnEmptyString);
            container.Target          = new Checkpoint(new Epoch(2), Sha256.OfAnEmptyString);

            Span <byte> encoded = new byte[AttestationData.SszLength];

            Ssz.Encode(encoded, container);
            AttestationData decoded = Ssz.DecodeAttestationData(encoded);

            Assert.AreEqual(container, decoded);

            Span <byte> encodedAgain = new byte[AttestationData.SszLength];

            Ssz.Encode(encodedAgain, decoded);
            Assert.True(Bytes.AreEqual(encodedAgain, encoded));

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