From 02e5e1bc1ea46d1c0deb07b906c62a985d9ee12e Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 2 Jun 2022 13:26:14 +0900 Subject: [PATCH] Fix CheckNoDeadLink which can enter in infinite loop --- BTCPayServer.Tests/ThirdPartyTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BTCPayServer.Tests/ThirdPartyTests.cs b/BTCPayServer.Tests/ThirdPartyTests.cs index 8086de2ba..8baeb60b5 100644 --- a/BTCPayServer.Tests/ThirdPartyTests.cs +++ b/BTCPayServer.Tests/ThirdPartyTests.cs @@ -203,7 +203,8 @@ namespace BTCPayServer.Tests "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); request.Headers.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0"); - var response = await httpClient.SendAsync(request); + using var cts = new CancellationTokenSource(5_000); + var response = await httpClient.SendAsync(request, cts.Token); Assert.Equal(HttpStatusCode.OK, response.StatusCode); if (uri.Fragment.Length != 0) { @@ -223,11 +224,11 @@ namespace BTCPayServer.Tests } catch (Exception) when (retryLeft > 0) { + retryLeft--; goto retry; } catch (Exception ex) { - retryLeft--; var details = ex is EqualException ? (ex as EqualException).Actual : ex.Message; TestLogs.LogInformation($"FAILED: {url} ({file}) {details}");