Skip to content

Commit

Permalink
Make test less flaky
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Sep 22, 2024
1 parent 47b572f commit 4623e56
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion NBitcoin.Tests/ProtocolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,20 @@ public void CanConnectToRandomNode()
PeersToDiscover = 50
});
watch.Start();
int retry = 5;
retry:
using (var node = Node.Connect(Network.Main, parameters))
{
var timeToFind = watch.Elapsed;
node.VersionHandshake();
try
{
node.VersionHandshake();
}
catch when (retry > 0)
{
retry--;
goto retry;
}
node.Dispose();
watch.Restart();
using (var node2 = Node.Connect(Network.Main, parameters))
Expand Down

0 comments on commit 4623e56

Please sign in to comment.