TorControlReplyReader: Fix the issue when the last line of response was not read.
MODIFY
WalletWasabi.Tests/UnitTests/Tor/Control/Messages/GetInfoCircuitStatusReplyTests.cs
WalletWasabi.Tests/UnitTests/Tor/Control/Messages/GetInfoCircuitStatusReplyTests.cs
@@ -22,12 +22,14 @@ namespace WalletWasabi.Tests.UnitTests.Tor.Control
sb.Append("3 BUILT $E9F71AC06F29B2110E3FC09016B0E50407444EE2~libertas,$706A7674A217BA905FE677E82236B7B968A23DB7~rofltor04,$4D4938B725B89561773A161215D88B7C45C43C35~TheGreenDynamo,$18CA339AD0C33EAB035F1D869518F3D2D88BABC0~FreeAssange BUILD_FLAGS=IS_INTERNAL,NEED_CAPACITY PURPOSE=HS_CLIENT_HSDIR HS_STATE=HSCI_CONNECTING TIME_CREATED=2021-05-15T14:04:19.353271\r\n");
sb.Append("4 EXTENDED $E9F71AC06F29B2110E3FC09016B0E50407444EE2~libertas BUILD_FLAGS=IS_INTERNAL,NEED_CAPACITY PURPOSE=MEASURE_TIMEOUT TIME_CREATED=2021-05-15T14:04:19.631228\r\n");
sb.Append("5 BUILT $E9F71AC06F29B2110E3FC09016B0E50407444EE2~libertas,$31D270A38505D4BFBBCABF717E9FB4BCA6DDF2FF~Belgium,$B411027C926A9BFFCF7DA91E3CAF1856A321EFFD~pulsetor BUILD_FLAGS=IS_INTERNAL,NEED_CAPACITY PURPOSE=HS_CLIENT_REND HS_STATE=HSCR_JOINED REND_QUERY=wasabiukrxmkdgve5kynjztuovbg43uxcbcxn6y2okcrsg7gb6jdmbad TIME_CREATED=2021-05-15T14:04:20.634686\r\n");
-
sb.Append(".\r\n");
+ sb.Append("250 OK\r\n");
string data = sb.ToString();
TorControlReply rawReply = await TorControlReplyReaderTest.ParseAsync(data);
+ Assert.Equal(8, rawReply.ResponseLines.Count);
+
GetInfoCircuitStatusReply reply = GetInfoCircuitStatusReply.FromReply(rawReply);
Assert.Equal(5, reply.Circuits.Count);

MODIFY
WalletWasabi/Tor/Control/TorControlReplyReader.cs
WalletWasabi/Tor/Control/TorControlReplyReader.cs
@@ -30,6 +30,10 @@ namespace WalletWasabi.Tor.Control
{
line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false);
}
+ catch (OperationCanceledException)
+ {
+ throw;
+ }
catch (InvalidDataException e)
{
throw new TorControlReplyParseException("No reply line was received.", e);
@@ -94,8 +98,10 @@ namespace WalletWasabi.Tor.Control
responses.Add(line);
- if (id == '+' && ".".Equals(line))
+ if (id == '+' && ".".Equals(line, StringComparison.Ordinal))
{
+ line = await reader.ReadLineAsync(cancellationToken).ConfigureAwait(false);
+ responses.Add(line);
break;
}
}

TorControlReplyReader: Fix the issue when the last line of response was not read.