cs-codex-dist-tests/DistTestCore/Marketplace/GethBootstrapNodeStarter.cs

41 lines
1.6 KiB
C#
Raw Normal View History

2023-04-14 07:54:07 +00:00
using KubernetesWorkflow;
namespace DistTestCore.Marketplace
{
2023-04-18 11:22:41 +00:00
public class GethBootstrapNodeStarter : BaseStarter
2023-04-14 07:54:07 +00:00
{
public GethBootstrapNodeStarter(TestLifecycle lifecycle, WorkflowCreator workflowCreator)
2023-04-18 11:22:41 +00:00
: base(lifecycle, workflowCreator)
2023-04-14 07:54:07 +00:00
{
}
public GethBootstrapNodeInfo StartGethBootstrapNode()
{
2023-04-18 11:22:41 +00:00
LogStart("Starting Geth bootstrap node...");
2023-04-14 07:54:07 +00:00
var startupConfig = CreateBootstrapStartupConfig();
var workflow = workflowCreator.CreateWorkflow();
var containers = workflow.Start(1, Location.Unspecified, new GethContainerRecipe(), startupConfig);
if (containers.Containers.Length != 1) throw new InvalidOperationException("Expected 1 Geth bootstrap node to be created. Test infra failure.");
var bootstrapContainer = containers.Containers[0];
2023-04-14 07:54:07 +00:00
var extractor = new ContainerInfoExtractor(workflow, bootstrapContainer);
2023-04-14 07:54:07 +00:00
var account = extractor.ExtractAccount();
var pubKey = extractor.ExtractPubKey();
var privateKey = extractor.ExtractPrivateKey();
var discoveryPort = bootstrapContainer.Recipe.GetPortByTag(GethContainerRecipe.DiscoveryPortTag);
2023-04-14 07:54:07 +00:00
2023-04-18 11:22:41 +00:00
LogEnd($"Geth bootstrap node started with account '{account}'");
2023-04-14 07:54:07 +00:00
2023-04-19 05:59:28 +00:00
return new GethBootstrapNodeInfo(containers, account, pubKey, privateKey, discoveryPort);
2023-04-14 07:54:07 +00:00
}
private StartupConfig CreateBootstrapStartupConfig()
{
var config = new StartupConfig();
2023-04-19 05:59:28 +00:00
config.Add(new GethStartupConfig(true, null!));
2023-04-14 07:54:07 +00:00
return config;
}
}
}