2023-04-14 07:54:07 +00:00
|
|
|
|
using DistTestCore.Marketplace;
|
|
|
|
|
using KubernetesWorkflow;
|
|
|
|
|
|
|
|
|
|
namespace DistTestCore
|
|
|
|
|
{
|
|
|
|
|
public class GethStarter
|
|
|
|
|
{
|
|
|
|
|
private readonly TestLifecycle lifecycle;
|
|
|
|
|
private readonly GethBootstrapNodeStarter bootstrapNodeStarter;
|
2023-04-14 08:51:35 +00:00
|
|
|
|
private readonly GethCompanionNodeStarter companionNodeStarter;
|
2023-04-14 07:54:07 +00:00
|
|
|
|
private GethBootstrapNodeInfo? bootstrapNode;
|
|
|
|
|
|
|
|
|
|
public GethStarter(TestLifecycle lifecycle, WorkflowCreator workflowCreator)
|
|
|
|
|
{
|
|
|
|
|
this.lifecycle = lifecycle;
|
|
|
|
|
|
|
|
|
|
bootstrapNodeStarter = new GethBootstrapNodeStarter(lifecycle, workflowCreator);
|
2023-04-14 08:51:35 +00:00
|
|
|
|
companionNodeStarter = new GethCompanionNodeStarter(lifecycle, workflowCreator);
|
2023-04-14 07:54:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 08:51:35 +00:00
|
|
|
|
public GethStartResult BringOnlineMarketplaceFor(CodexSetup codexSetup)
|
2023-04-14 07:54:07 +00:00
|
|
|
|
{
|
2023-04-14 08:51:35 +00:00
|
|
|
|
if (codexSetup.MarketplaceConfig == null) return CreateMarketplaceUnavailableResult();
|
|
|
|
|
|
2023-04-14 07:54:07 +00:00
|
|
|
|
EnsureBootstrapNode();
|
2023-04-14 08:51:35 +00:00
|
|
|
|
var companionNodes = StartCompanionNodes(codexSetup);
|
|
|
|
|
|
|
|
|
|
TransferInitialBalance(codexSetup.MarketplaceConfig.InitialBalance, bootstrapNode, companionNodes);
|
|
|
|
|
|
|
|
|
|
return new GethStartResult(CreateMarketplaceAccessFactory(), bootstrapNode!, companionNodes);
|
2023-04-14 07:54:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 08:51:35 +00:00
|
|
|
|
private void TransferInitialBalance(int initialBalance, GethBootstrapNodeInfo? bootstrapNode, GethCompanionNodeInfo[] companionNodes)
|
2023-04-14 07:54:07 +00:00
|
|
|
|
{
|
2023-04-14 08:51:35 +00:00
|
|
|
|
aaaa
|
2023-04-14 07:54:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 08:51:35 +00:00
|
|
|
|
private GethStartResult CreateMarketplaceUnavailableResult()
|
|
|
|
|
{
|
|
|
|
|
return new GethStartResult(new MarketplaceUnavailableAccessFactory(), null!, Array.Empty<GethCompanionNodeInfo>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IMarketplaceAccessFactory CreateMarketplaceAccessFactory()
|
2023-04-14 07:54:07 +00:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 08:51:35 +00:00
|
|
|
|
private void EnsureBootstrapNode()
|
|
|
|
|
{
|
|
|
|
|
if (bootstrapNode != null) return;
|
|
|
|
|
bootstrapNode = bootstrapNodeStarter.StartGethBootstrapNode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private GethCompanionNodeInfo[] StartCompanionNodes(CodexSetup codexSetup)
|
2023-04-14 07:54:07 +00:00
|
|
|
|
{
|
2023-04-14 08:51:35 +00:00
|
|
|
|
return companionNodeStarter.StartCompanionNodesFor(codexSetup, bootstrapNode!);
|
2023-04-14 07:54:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|