cs-codex-dist-tests/Tests/CodexTests/CodexDistTest.cs

74 lines
2.1 KiB
C#
Raw Normal View History

2023-09-19 14:22:07 +00:00
using CodexContractsPlugin;
using CodexPlugin;
2023-09-20 11:56:01 +00:00
using Core;
2023-09-13 12:24:43 +00:00
using DistTestCore;
using DistTestCore.Helpers;
2023-09-19 14:22:07 +00:00
using GethPlugin;
using NUnit.Framework.Constraints;
2023-09-13 12:24:43 +00:00
namespace Tests
{
public class CodexDistTest : DistTest
{
2023-09-19 09:51:59 +00:00
private readonly List<ICodexNode> onlineCodexNodes = new List<ICodexNode>();
2023-09-13 12:24:43 +00:00
2023-09-20 11:56:01 +00:00
public CodexDistTest()
{
ProjectPlugin.Load<CodexPlugin.CodexPlugin>();
ProjectPlugin.Load<CodexContractsPlugin.CodexContractsPlugin>();
ProjectPlugin.Load<GethPlugin.GethPlugin>();
ProjectPlugin.Load<MetricsPlugin.MetricsPlugin>();
}
2023-09-19 09:51:59 +00:00
public ICodexNode AddCodex()
2023-09-13 12:24:43 +00:00
{
return AddCodex(s => { });
}
2023-09-19 09:51:59 +00:00
public ICodexNode AddCodex(Action<ICodexSetup> setup)
2023-09-13 12:24:43 +00:00
{
return AddCodex(1, setup)[0];
}
public ICodexNodeGroup AddCodex(int numberOfNodes)
{
return AddCodex(numberOfNodes, s => { });
}
public ICodexNodeGroup AddCodex(int numberOfNodes, Action<ICodexSetup> setup)
{
2023-09-20 10:02:32 +00:00
var group = Ci.StartCodexNodes(numberOfNodes, s =>
2023-09-13 12:24:43 +00:00
{
setup(s);
OnCodexSetup(s);
});
onlineCodexNodes.AddRange(group);
return group;
}
public PeerConnectionTestHelpers CreatePeerConnectionTestHelpers()
{
return new PeerConnectionTestHelpers(GetTestLog());
}
public PeerDownloadTestHelpers CreatePeerDownloadTestHelpers()
{
return new PeerDownloadTestHelpers(GetTestLog(), Get().GetFileManager());
}
2023-09-19 09:51:59 +00:00
public IEnumerable<ICodexNode> GetAllOnlineCodexNodes()
2023-09-13 12:24:43 +00:00
{
return onlineCodexNodes;
}
2023-09-19 14:22:07 +00:00
public void AssertBalance(IGethNode gethNode, ICodexContracts contracts, ICodexNode codexNode, Constraint constraint, string msg = "")
{
AssertHelpers.RetryAssert(constraint, () => contracts.GetTestTokenBalance(gethNode, codexNode), nameof(AssertBalance) + msg);
}
2023-09-13 12:24:43 +00:00
protected virtual void OnCodexSetup(ICodexSetup setup)
{
}
}
}