mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-08 16:33:07 +00:00
Trying to prove disconnects slow down clients
This commit is contained in:
parent
4e093f12d7
commit
35816141a3
@ -71,11 +71,6 @@ namespace CodexContractsPlugin.ChainMonitor
|
||||
var timeRange = contracts.GetPeriodTimeRange(currentPeriod.PeriodNumber);
|
||||
var blockRange = geth.ConvertTimeRangeToBlockRange(timeRange);
|
||||
|
||||
// MarkProofAsMissingFunction
|
||||
// SubmitProofFunction
|
||||
// FreeSlot1Function
|
||||
// FreeSlotFunction
|
||||
|
||||
var callReports = new List<FunctionCallReport>();
|
||||
geth.IterateTransactions(blockRange, (t, blkI, blkUtc) =>
|
||||
{
|
||||
|
||||
@ -3,6 +3,7 @@ using Core;
|
||||
using KubernetesWorkflow.Types;
|
||||
using Logging;
|
||||
using Nethereum.ABI.FunctionEncoding.Attributes;
|
||||
using Nethereum.BlockchainProcessing.BlockStorage.Entities.Mapping;
|
||||
using Nethereum.Contracts;
|
||||
using Nethereum.RPC.Eth.DTOs;
|
||||
using NethereumWorkflow;
|
||||
|
||||
@ -46,6 +46,93 @@ namespace CodexReleaseTests.DataTests
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Combinatorial]
|
||||
public void BlackHoleTest(
|
||||
[Values(5)] int numBlackHoles,
|
||||
[Values(50, 200)] int sourceNodes)
|
||||
{
|
||||
var blackHoles = StartCodex(numBlackHoles, n => n.WithName("BlackHole"));
|
||||
|
||||
var remaining = sourceNodes;
|
||||
var listLock = new object();
|
||||
var nodes = new List<ICodexNode>();
|
||||
var startTask = Task.Run(() =>
|
||||
{
|
||||
while (remaining > 0)
|
||||
{
|
||||
if (nodes.Count < 3)
|
||||
{
|
||||
var count = Math.Min(5, remaining);
|
||||
remaining -= count;
|
||||
var n = StartCodex(count);
|
||||
lock (listLock)
|
||||
{
|
||||
nodes.AddRange(n);
|
||||
}
|
||||
}
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
});
|
||||
|
||||
while (remaining > 0 || nodes.Count > 0)
|
||||
{
|
||||
var node = TakeNode(nodes, listLock);
|
||||
|
||||
var file = GenerateTestFile(200.MB());
|
||||
var cid = node.UploadFile(file);
|
||||
|
||||
SimultaneousDownload(blackHoles, file, cid);
|
||||
|
||||
node.Stop(waitTillStopped: false);
|
||||
|
||||
AllOk(blackHoles);
|
||||
}
|
||||
|
||||
startTask.Wait();
|
||||
}
|
||||
|
||||
private void AllOk(ICodexNodeGroup blackHoles)
|
||||
{
|
||||
foreach (var n in blackHoles)
|
||||
{
|
||||
Assert.That(n.HasCrashed(), Is.False);
|
||||
var info = n.GetDebugInfo();
|
||||
Assert.That(string.IsNullOrEmpty(info.Spr), Is.False);
|
||||
}
|
||||
}
|
||||
|
||||
private void SimultaneousDownload(ICodexNodeGroup blackHoles, TrackedFile file, ContentId cid)
|
||||
{
|
||||
var tasks = blackHoles.Select(n =>
|
||||
Task<TrackedFile>.Run(() => n.DownloadContent(cid))
|
||||
).ToArray();
|
||||
|
||||
Task.WaitAll(tasks);
|
||||
|
||||
var received = tasks.Select(t => t.Result).ToArray();
|
||||
|
||||
foreach (var r in received)
|
||||
{
|
||||
file.AssertIsEqual(r);
|
||||
}
|
||||
}
|
||||
|
||||
private ICodexNode TakeNode(List<ICodexNode> nodes, object listLock)
|
||||
{
|
||||
while (nodes.Count == 0)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
lock (listLock)
|
||||
{
|
||||
var n = nodes[0];
|
||||
nodes.RemoveAt(0);
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
private void AllNodesHaveFile()
|
||||
{
|
||||
Log($"{nameof(AllNodesHaveFile)} {nodes.Names()}");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user