Skip to content

Commit 9622a7b

Browse files
committed
Merge remote-tracking branch 'origin/feature/declarative-rlp' into feature/declarative-rlp
# Conflicts: # src/Nethermind/Nethermind.Serialization.FluentRlp/Rlp.cs
2 parents b2e5951 + 1c8f472 commit 9622a7b

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited
2+
// SPDX-License-Identifier: LGPL-3.0-only
3+
4+
using FluentAssertions;
5+
using FluentAssertions.Collections;
6+
7+
namespace Nethermind.Serialization.FluentRlp.Test;
8+
9+
// NOTE: `FluentAssertions` currently does not support `(ReadOnly)Span<T>` or `(ReadOnly)Memory<T>` assertions.
10+
public static class Extensions
11+
{
12+
public static GenericCollectionAssertions<T> Should<T>(this ReadOnlySpan<T> span) => span.ToArray().Should();
13+
public static GenericCollectionAssertions<T> Should<T>(this ReadOnlyMemory<T> memory) => memory.ToArray().Should();
14+
15+
public static AndConstraint<GenericCollectionAssertions<TExpectation>> BeEquivalentTo<TExpectation>(
16+
this GenericCollectionAssertions<TExpectation> @this,
17+
ReadOnlySpan<TExpectation> expectation,
18+
string because = "",
19+
params object[] becauseArgs)
20+
{
21+
return @this.BeEquivalentTo(expectation.ToArray(), config => config, because, becauseArgs);
22+
}
23+
24+
public static AndConstraint<GenericCollectionAssertions<TExpectation>> BeEquivalentTo<TExpectation>(
25+
this GenericCollectionAssertions<TExpectation> @this,
26+
ReadOnlyMemory<TExpectation> expectation,
27+
string because = "",
28+
params object[] becauseArgs)
29+
{
30+
return @this.BeEquivalentTo(expectation.ToArray(), config => config, because, becauseArgs);
31+
}
32+
}

src/Nethermind/Nethermind.Serialization.FluentRlp.Test/RlpReadWriteTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public void Choice()
204204
var intRlp = Rlp.Write(static (ref RlpWriter w) => { w.Write(42); });
205205
var wrappedIntRlp = Rlp.Write(static (ref RlpWriter w) => w.WriteSequence(static (ref RlpWriter w) => { w.Write(42); }));
206206

207-
foreach (var rlp in (byte[][])[intRlp, wrappedIntRlp])
207+
foreach (var rlp in (ReadOnlyMemory<byte>[])[intRlp, wrappedIntRlp])
208208
{
209209
int decoded = Rlp.Read(rlp, (scoped ref RlpReader r) => r.Choice(wrappedReader, intReader));
210210

0 commit comments

Comments
 (0)