From 31012ce8259874680640e26f5e3d50cbec604267 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Tue, 7 Jul 2026 16:25:47 +0200 Subject: [PATCH] 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. --- .../Net/ElectrumClientTests.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/PalladiumWallet.Tests/Net/ElectrumClientTests.cs b/tests/PalladiumWallet.Tests/Net/ElectrumClientTests.cs index 7fc90ae..7b1256d 100644 --- a/tests/PalladiumWallet.Tests/Net/ElectrumClientTests.cs +++ b/tests/PalladiumWallet.Tests/Net/ElectrumClientTests.cs @@ -98,6 +98,21 @@ public class ElectrumClientTests 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] public async Task La_cancellazione_del_token_annulla_la_richiesta_pendente() {