test(net): cover ElectrumClient's multi-segment response dispatch

DispatchLine's ArrayPool-copy path (for a JSON-RPC line spanning
multiple PipeReader segments) only ran for small responses in existing
tests, which stay single-segment. A 256 KB fake response forces the
multi-segment branch and verifies the payload still arrives intact.
This commit is contained in:
2026-07-07 16:25:47 +02:00
parent a46f5e6638
commit 31012ce825
@@ -98,6 +98,21 @@ public class ElectrumClientTests
await disconnected.Task.WaitAsync(Timeout); await disconnected.Task.WaitAsync(Timeout);
} }
[Fact]
public async Task Una_risposta_molto_grande_arriva_integra()
{
// A payload far beyond the PipeReader's segment size forces the
// multi-segment dispatch path (ArrayPool copy) instead of the fast span.
var big = new string('x', 256 * 1024);
await using var server = new FakeElectrumServer();
server.Handle("blockchain.transaction.get", _ => big);
await using var client = await ElectrumClient.ConnectAsync(server.Host, server.Port, useSsl: false);
var result = await client.GetTransactionAsync("00").WaitAsync(Timeout);
Assert.Equal(big, result);
}
[Fact] [Fact]
public async Task La_cancellazione_del_token_annulla_la_richiesta_pendente() public async Task La_cancellazione_del_token_annulla_la_richiesta_pendente()
{ {