Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Nethermind/Nethermind.Core.Test/RlpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@ public void Long_and_big_integer_encoded_the_same(long value)
Assert.That(rlpBigInt.Bytes, Is.EqualTo(rlpLong.Bytes));
}

[Test]
public void Encode_generic_with_Rlp_input_preserves_original_bytes()
{
Rlp original = Rlp.Encode(255L);
Rlp reEncoded = Rlp.Encode<Rlp>(original);

Assert.That(reEncoded.Bytes, Is.EqualTo(original.Bytes));
Assert.That(reEncoded, Is.SameAs(original));
}

[TestCase(true)]
[TestCase(false)]
public void RlpContextWithSliceMemory_shouldNotCopyUnderlyingData(bool sliceValue)
Expand Down
3 changes: 1 addition & 2 deletions src/Nethermind/Nethermind.Serialization.Rlp/Rlp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ public static Rlp Encode<T>(T item, RlpBehaviors behaviors = RlpBehaviors.None)
{
if (item is Rlp rlp)
{
RlpStream stream = new(LengthOfSequence(rlp.Length));
return new(stream.Data.ToArray());
return rlp;
}

IRlpStreamDecoder<T>? rlpStreamDecoder = GetStreamDecoder<T>();
Expand Down