public void Rlp_stream_and_standard_have_same_results()
        {
            LogEntry        logEntry = new LogEntry(TestItem.AddressA, new byte[] { 1, 2, 3 }, new[] { TestItem.KeccakA, TestItem.KeccakB });
            LogEntryDecoder decoder  = LogEntryDecoder.Instance;

            Rlp rlpStreamResult = decoder.Encode(logEntry);

            Rlp rlp = decoder.Encode(logEntry);

            Assert.AreEqual(rlp.Bytes.ToHexString(), rlpStreamResult.Bytes.ToHexString());
        }
Esempio n. 2
0
        public void Can_do_roundtrip()
        {
            LogEntry        logEntry     = new LogEntry(TestItem.AddressA, new byte[] { 1, 2, 3 }, new[] { TestItem.KeccakA, TestItem.KeccakB });
            LogEntryDecoder decoder      = new LogEntryDecoder();
            Rlp             rlp          = decoder.Encode(logEntry);
            LogEntry        deserialized = decoder.Decode(rlp.Bytes.AsRlpStream());

            Assert.AreEqual(logEntry.Data, deserialized.Data, "data");
            Assert.AreEqual(logEntry.LoggersAddress, deserialized.LoggersAddress, "address");
            Assert.AreEqual(logEntry.Topics, deserialized.Topics, "topics");
        }
        public void Can_do_roundtrip_rlp_stream()
        {
            LogEntry        logEntry = new(TestItem.AddressA, new byte[] { 1, 2, 3 }, new[] { TestItem.KeccakA, TestItem.KeccakB });
            LogEntryDecoder decoder  = LogEntryDecoder.Instance;

            Rlp      encoded      = decoder.Encode(logEntry);
            LogEntry deserialized = decoder.Decode(new RlpStream(encoded.Bytes));

            Assert.AreEqual(logEntry.Data, deserialized.Data, "data");
            Assert.AreEqual(logEntry.LoggersAddress, deserialized.LoggersAddress, "address");
            Assert.AreEqual(logEntry.Topics, deserialized.Topics, "topics");
        }
Esempio n. 4
0
        public bool TryGetNext(out LogEntryStructRef current)
        {
            if (_logs is null)
            {
                if (_decoderContext.Position < _length)
                {
                    LogEntryDecoder.DecodeStructRef(ref _decoderContext, RlpBehaviors.None, out current);
                    Index++;
                    return(true);
                }
            }
            else
            {
                if (++Index < _length)
                {
                    current = new LogEntryStructRef(_logs[Index]);
                    return(true);
                }
            }

            current = new LogEntryStructRef();
            return(false);
        }