Adds test for making sure node does not crash after mysterious CID is downloaded

This commit is contained in:
Ben 2024-06-18 11:04:04 +02:00
parent 54f053cfcc
commit e1da38b6e8
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
2 changed files with 31 additions and 13 deletions

View File

@ -17,18 +17,6 @@ namespace CodexTests.BasicTests
LogNodeStatus(primary);
}
[Test]
public void RestartTest()
{
var primary = StartCodex();
primary.Stop(waitTillStopped: true);
primary = StartCodex();
PerformOneClientTest(primary);
}
private void PerformOneClientTest(ICodexNode primary)
{
var testFile = GenerateTestFile(1.MB());

View File

@ -1,4 +1,5 @@
using NUnit.Framework;
using CodexPlugin;
using NUnit.Framework;
using Utils;
namespace CodexTests.BasicTests
@ -20,5 +21,34 @@ namespace CodexTests.BasicTests
testFile.AssertIsEqual(downloadedFile);
}
[Test]
public void DownloadingUnknownCidDoesNotCauseCrash()
{
var node = StartCodex(2).First();
var unknownCid = new ContentId("zDvZRwzkzHsok3Z8yMoiXE9EDBFwgr8WygB8s4ddcLzzSwwXAxLZ");
try
{
node.DownloadContent(unknownCid);
}
catch (Exception ex)
{
if (!ex.Message.StartsWith("Retry 'DownloadFile' timed out"))
{
throw;
}
}
// Check that the node stays alive for at least another 5 minutes.
var start = DateTime.UtcNow;
while ((DateTime.UtcNow - start) < TimeSpan.FromMinutes(5))
{
Thread.Sleep(5000);
var info = node.GetDebugInfo();
Assert.That(!string.IsNullOrEmpty(info.Id));
}
}
}
}