40 lines
1.0 KiB
C#
Raw Normal View History

2023-04-26 14:59:26 +02:00
using DistTestCore;
using NUnit.Framework;
2023-06-01 12:27:54 +02:00
namespace TestsLong.BasicTests
2023-04-26 14:59:26 +02:00
{
[TestFixture]
public class DownloadTests : DistTest
{
[TestCase(3, 500)]
[TestCase(5, 100)]
2023-04-28 07:22:17 +02:00
[TestCase(10, 256)]
[UseLongTimeouts]
public void ParallelDownload(int numberOfNodes, int filesizeMb)
2023-04-26 14:59:26 +02:00
{
2023-04-26 15:32:27 +02:00
var group = SetupCodexNodes(numberOfNodes);
var host = SetupCodexNode();
2023-04-26 14:59:26 +02:00
foreach (var node in group)
{
host.ConnectToPeer(node);
}
var testFile = GenerateTestFile(filesizeMb.MB());
2023-04-26 14:59:26 +02:00
var contentId = host.UploadFile(testFile);
var list = new List<Task<TestFile?>>();
2023-06-01 12:27:54 +02:00
2023-04-26 14:59:26 +02:00
foreach (var node in group)
{
list.Add(Task.Run(() => { return node.DownloadContent(contentId); }));
}
Task.WaitAll(list.ToArray());
foreach (var task in list)
{
testFile.AssertIsEqual(task.Result);
}
}
}
}