From 9a227b3d0e6a71e7ed059fa70d662c3320fa5765 Mon Sep 17 00:00:00 2001 From: ThatBen Date: Thu, 16 Jan 2025 13:51:29 +0100 Subject: [PATCH] lots of using-statement fixes --- .gitignore | 1 + .../CodexClient/CodexNodeFactory.cs | 12 +- ProjectPlugins/CodexPlugin/CodexDeployment.cs | 3 +- .../CodexInstanceContainerExtension.cs | 3 +- ProjectPlugins/CodexPlugin/CodexNodeGroup.cs | 5 +- ProjectPlugins/CodexPlugin/CodexStarter.cs | 135 +++++++++++------- .../CodexPlugin/CodexStartupConfig.cs | 3 +- .../CodexPlugin/CoreInterfaceExtensions.cs | 3 +- .../OverwatchSupport/CodexLogConverter.cs | 4 +- .../CodexNodeTranscriptWriter.cs | 3 +- .../OverwatchSupport/CodexTranscriptWriter.cs | 3 +- .../OverwatchSupport/IdentityMap.cs | 4 +- .../BlockReceivedLineConverter.cs | 4 +- .../LineConverters/BootstrapLineConverter.cs | 4 +- .../DialSuccessfulLineConverter.cs | 4 +- .../PeerDroppedLineConverter.cs | 4 +- .../OverwatchSupport/ModelExtensions.cs | 3 +- ProjectPlugins/CodexPluginPrebuild/Program.cs | 2 +- Tests/DistTestCore/Configuration.cs | 4 +- Tests/DistTestCore/DistTest.cs | 18 ++- Tests/DistTestCore/TestLifecycle.cs | 11 +- .../AutoBootstrapDistTest.cs | 3 +- .../BasicTests/PyramidTests.cs | 7 +- Tests/ExperimentalTests/CodexDistTest.cs | 2 +- .../FullyConnectedDownloadTests.cs | 5 +- .../MultiswarmTests.cs | 2 +- .../Helpers/FullConnectivityHelper.cs | 2 +- .../Helpers/PeerConnectionTestHelpers.cs | 2 +- .../Helpers/PeerDownloadTestHelpers.cs | 2 +- .../LayeredDiscoveryTests.cs | 2 +- .../PeerDiscoveryTests/PeerDiscoveryTests.cs | 3 +- .../UtilityTests/LogHelperTests.cs | 2 +- .../UtilityTests/NetworkIsolationTest.cs | 3 +- .../CodexContractsPlugin/TestTokenTests.cs | 4 +- Tools/AutoClient/CodexInstance.cs | 3 +- Tools/BiblioTech/Commands/MintCommand.cs | 1 + .../Commands/UserAssociateCommand.cs | 10 +- Tools/BiblioTech/Options/EthAddressOption.cs | 4 +- Tools/BiblioTech/UserData.cs | 1 + Tools/BiblioTech/UserRepo.cs | 1 + Tools/KeyMaker/Controllers/KeyController.cs | 4 +- Tools/TestNetRewarder/HistoricState.cs | 2 +- Tools/TestNetRewarder/RequestBuilder.cs | 2 +- Tools/TestNetRewarder/RewardCheck.cs | 3 +- .../Receivers/LogReplaceReceiver.cs | 2 +- .../Receivers/NodesDegree.cs | 2 +- 46 files changed, 178 insertions(+), 129 deletions(-) diff --git a/.gitignore b/.gitignore index 488beaf6..b5c9e08b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ obj bin .vscode Tools/AutoClient/datapath +.editorconfig diff --git a/ProjectPlugins/CodexClient/CodexNodeFactory.cs b/ProjectPlugins/CodexClient/CodexNodeFactory.cs index 447ae018..d8048a0e 100644 --- a/ProjectPlugins/CodexClient/CodexNodeFactory.cs +++ b/ProjectPlugins/CodexClient/CodexNodeFactory.cs @@ -9,15 +9,15 @@ namespace CodexClient { private readonly ILog log; private readonly IFileManager fileManager; - private readonly ICodexHooksProvider hooksProvider; + private readonly CodexHooksFactory hooksFactor; private readonly IHttpFactory httpFactory; private readonly IIProcessControlFactory processControlFactory; - public CodexNodeFactory(ILog log, IFileManager fileManager, ICodexHooksProvider hooksProvider, IHttpFactory httpFactory, IIProcessControlFactory processControlFactory) + public CodexNodeFactory(ILog log, IFileManager fileManager, CodexHooksFactory hooksFactory, IHttpFactory httpFactory, IIProcessControlFactory processControlFactory) { this.log = log; this.fileManager = fileManager; - this.hooksProvider = hooksProvider; + this.hooksFactor = hooksFactory; this.httpFactory = httpFactory; this.processControlFactory = processControlFactory; } @@ -26,9 +26,11 @@ namespace CodexClient { var processControl = processControlFactory.CreateProcessControl(instance); var access = new CodexAccess(log, httpFactory, processControl, instance); - var hooks = hooksProvider.CreateHooks(access.GetName()); + var hooks = hooksFactor.CreateHooks(access.GetName()); var marketplaceAccess = CreateMarketplaceAccess(instance, access, hooks); - return new CodexNode(log, access, fileManager, marketplaceAccess, hooks); + var node = new CodexNode(log, access, fileManager, marketplaceAccess, hooks); + node.Initialize(); + return node; } private IMarketplaceAccess CreateMarketplaceAccess(ICodexInstance instance, CodexAccess access, ICodexNodeHooks hooks) diff --git a/ProjectPlugins/CodexPlugin/CodexDeployment.cs b/ProjectPlugins/CodexPlugin/CodexDeployment.cs index 0a22deae..ec44db3a 100644 --- a/ProjectPlugins/CodexPlugin/CodexDeployment.cs +++ b/ProjectPlugins/CodexPlugin/CodexDeployment.cs @@ -1,4 +1,5 @@ -using CodexContractsPlugin; +using CodexClient; +using CodexContractsPlugin; using GethPlugin; using KubernetesWorkflow.Types; diff --git a/ProjectPlugins/CodexPlugin/CodexInstanceContainerExtension.cs b/ProjectPlugins/CodexPlugin/CodexInstanceContainerExtension.cs index 5e97dd0f..2104823e 100644 --- a/ProjectPlugins/CodexPlugin/CodexInstanceContainerExtension.cs +++ b/ProjectPlugins/CodexPlugin/CodexInstanceContainerExtension.cs @@ -1,6 +1,5 @@ -using Core; +using CodexClient; using KubernetesWorkflow.Types; -using Logging; using Utils; namespace CodexPlugin diff --git a/ProjectPlugins/CodexPlugin/CodexNodeGroup.cs b/ProjectPlugins/CodexPlugin/CodexNodeGroup.cs index c178f459..8c82ce22 100644 --- a/ProjectPlugins/CodexPlugin/CodexNodeGroup.cs +++ b/ProjectPlugins/CodexPlugin/CodexNodeGroup.cs @@ -14,9 +14,9 @@ namespace CodexPlugin public class CodexNodeGroup : ICodexNodeGroup { - private readonly CodexNode[] nodes; + private readonly ICodexNode[] nodes; - public CodexNodeGroup(IPluginTools tools, CodexNode[] nodes) + public CodexNodeGroup(IPluginTools tools, ICodexNode[] nodes) { this.nodes = nodes; Version = new DebugInfoVersion(); @@ -61,7 +61,6 @@ namespace CodexPlugin public void EnsureOnline() { - foreach (var node in nodes) node.Initialize(); var versionResponses = Nodes.Select(n => n.Version); var first = versionResponses.First(); diff --git a/ProjectPlugins/CodexPlugin/CodexStarter.cs b/ProjectPlugins/CodexPlugin/CodexStarter.cs index a2baf96f..e6521479 100644 --- a/ProjectPlugins/CodexPlugin/CodexStarter.cs +++ b/ProjectPlugins/CodexPlugin/CodexStarter.cs @@ -1,4 +1,5 @@ -using CodexPlugin.Hooks; +using CodexClient; +using CodexClient.Hooks; using Core; using KubernetesWorkflow; using KubernetesWorkflow.Types; @@ -7,7 +8,7 @@ using Utils; namespace CodexPlugin { - public class CodexStarter : IProcessControl + public class CodexStarter : IIProcessControlFactory { private readonly IPluginTools pluginTools; private readonly CodexContainerRecipe recipe = new CodexContainerRecipe(); @@ -24,6 +25,15 @@ namespace CodexPlugin public CodexHooksFactory HooksFactory { get; } = new CodexHooksFactory(); + public IProcessControl CreateProcessControl(ICodexInstance instance) + { + var pod = podMap[instance]; + return new CodexContainerProcessControl(pluginTools, pod, onStop: () => + { + podMap.Remove(instance); + }); + } + public RunningPod[] BringOnline(CodexSetup codexSetup) { LogSeparator(); @@ -47,46 +57,14 @@ namespace CodexPlugin return containers; } - public void Stop(ICodexInstance instance, bool waitTillStopped) - { - Log($"Stopping node..."); - var pod = podMap[instance]; - podMap.Remove(instance); - - var workflow = pluginTools.CreateWorkflow(); - workflow.Stop(pod, waitTillStopped); - Log("Stopped."); - } - - public IDownloadedLog DownloadLog(ICodexInstance instance, LogFile file) - { - var workflow = pluginTools.CreateWorkflow(); - var pod = podMap[instance]; - return workflow.DownloadContainerLog(pod.Containers.Single()); - } - - public void DeleteDataDirFolder(ICodexInstance instance) - { - var pod = podMap[instance]; - var container = pod.Containers.Single(); - - try - { - var dataDirVar = container.Recipe.EnvVars.Single(e => e.Name == "CODEX_DATA_DIR"); - var dataDir = dataDirVar.Value; - var workflow = pluginTools.CreateWorkflow(); - workflow.ExecuteCommand(container, "rm", "-Rfv", $"/codex/{dataDir}/repo"); - Log("Deleted repo folder."); - } - catch (Exception e) - { - Log("Unable to delete repo folder: " + e); - } - } - public ICodexNodeGroup WrapCodexContainers(CoreInterface coreInterface, RunningPod[] containers) { - var codexNodeFactory = new CodexNodeFactory(pluginTools, HooksFactory); + var codexNodeFactory = new CodexNodeFactory( + log: pluginTools.GetLog(), + fileManager: pluginTools.GetFileManager(), + hooksFactory: HooksFactory, + httpFactory: pluginTools, + processControlFactory: this); var group = CreateCodexGroup(coreInterface, containers, codexNodeFactory); @@ -139,8 +117,7 @@ namespace CodexPlugin private CodexNodeGroup CreateCodexGroup(CoreInterface coreInterface, RunningPod[] runningContainers, CodexNodeFactory codexNodeFactory) { var instances = runningContainers.Select(CreateInstance).ToArray(); - var accesses = instances.Select(CreateAccess).ToArray(); - var nodes = accesses.Select(codexNodeFactory.CreateOnlineCodexNode).ToArray(); + var nodes = instances.Select(codexNodeFactory.CreateCodexNode).ToArray(); var group = new CodexNodeGroup(pluginTools, nodes); try @@ -156,18 +133,6 @@ namespace CodexPlugin return group; } - private CodexAccess CreateAccess(ICodexInstance instance) - { - var crashWatcher = CreateCrashWatcher(instance); - return new CodexAccess(pluginTools, this, instance, crashWatcher); - } - - private ICrashWatcher CreateCrashWatcher(ICodexInstance instance) - { - var pod = podMap[instance]; - return pluginTools.CreateWorkflow().CreateCrashWatcher(pod.Containers.Single()); - } - private ICodexInstance CreateInstance(RunningPod pod) { var instance = CodexInstanceContainerExtension.CreateFromPod(pod); @@ -198,4 +163,66 @@ namespace CodexPlugin pluginTools.GetLog().Log(message); } } + + public class CodexContainerProcessControl : IProcessControl + { + private readonly IPluginTools tools; + private readonly RunningPod pod; + private readonly Action onStop; + private readonly ContainerCrashWatcher crashWatcher; + + public CodexContainerProcessControl(IPluginTools tools, RunningPod pod, Action onStop) + { + this.tools = tools; + this.pod = pod; + this.onStop = onStop; + + crashWatcher = tools.CreateWorkflow().CreateCrashWatcher(pod.Containers.Single()); + crashWatcher.Start(); + } + + public void Stop(bool waitTillStopped) + { + Log($"Stopping node..."); + var workflow = tools.CreateWorkflow(); + workflow.Stop(pod, waitTillStopped); + crashWatcher.Stop(); + onStop(); + Log("Stopped."); + } + + public IDownloadedLog DownloadLog(LogFile file) + { + var workflow = tools.CreateWorkflow(); + return workflow.DownloadContainerLog(pod.Containers.Single()); + } + + public void DeleteDataDirFolder() + { + var container = pod.Containers.Single(); + + try + { + var dataDirVar = container.Recipe.EnvVars.Single(e => e.Name == "CODEX_DATA_DIR"); + var dataDir = dataDirVar.Value; + var workflow = tools.CreateWorkflow(); + workflow.ExecuteCommand(container, "rm", "-Rfv", $"/codex/{dataDir}/repo"); + Log("Deleted repo folder."); + } + catch (Exception e) + { + Log("Unable to delete repo folder: " + e); + } + } + + public bool HasCrashed() + { + return crashWatcher.HasCrashed(); + } + + private void Log(string message) + { + tools.GetLog().Log(message); + } + } } diff --git a/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs b/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs index 63903090..69cdac6e 100644 --- a/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs +++ b/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs @@ -1,4 +1,5 @@ -using KubernetesWorkflow; +using CodexClient; +using KubernetesWorkflow; using Utils; namespace CodexPlugin diff --git a/ProjectPlugins/CodexPlugin/CoreInterfaceExtensions.cs b/ProjectPlugins/CodexPlugin/CoreInterfaceExtensions.cs index 6fb8842e..91783e42 100644 --- a/ProjectPlugins/CodexPlugin/CoreInterfaceExtensions.cs +++ b/ProjectPlugins/CodexPlugin/CoreInterfaceExtensions.cs @@ -1,4 +1,5 @@ -using CodexPlugin.Hooks; +using CodexClient; +using CodexClient.Hooks; using Core; using KubernetesWorkflow.Types; diff --git a/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexLogConverter.cs b/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexLogConverter.cs index 9e55e3a4..71be7873 100644 --- a/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexLogConverter.cs +++ b/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexLogConverter.cs @@ -1,5 +1,5 @@ -using CodexPlugin.OverwatchSupport.LineConverters; -using KubernetesWorkflow; +using CodexClient; +using CodexPlugin.OverwatchSupport.LineConverters; using Logging; using OverwatchTranscript; using Utils; diff --git a/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexNodeTranscriptWriter.cs b/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexNodeTranscriptWriter.cs index c221806e..346715ca 100644 --- a/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexNodeTranscriptWriter.cs +++ b/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexNodeTranscriptWriter.cs @@ -1,4 +1,5 @@ -using CodexPlugin.Hooks; +using CodexClient; +using CodexClient.Hooks; using OverwatchTranscript; using Utils; diff --git a/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexTranscriptWriter.cs b/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexTranscriptWriter.cs index 1bfc7cf3..afd8d1a2 100644 --- a/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexTranscriptWriter.cs +++ b/ProjectPlugins/CodexPlugin/OverwatchSupport/CodexTranscriptWriter.cs @@ -1,5 +1,4 @@ -using CodexPlugin.Hooks; -using KubernetesWorkflow; +using CodexClient.Hooks; using Logging; using OverwatchTranscript; using Utils; diff --git a/ProjectPlugins/CodexPlugin/OverwatchSupport/IdentityMap.cs b/ProjectPlugins/CodexPlugin/OverwatchSupport/IdentityMap.cs index d272e9cd..a0843fd5 100644 --- a/ProjectPlugins/CodexPlugin/OverwatchSupport/IdentityMap.cs +++ b/ProjectPlugins/CodexPlugin/OverwatchSupport/IdentityMap.cs @@ -1,4 +1,6 @@ -namespace CodexPlugin.OverwatchSupport +using CodexClient; + +namespace CodexPlugin.OverwatchSupport { public class IdentityMap { diff --git a/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/BlockReceivedLineConverter.cs b/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/BlockReceivedLineConverter.cs index c9259df9..70be0bdd 100644 --- a/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/BlockReceivedLineConverter.cs +++ b/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/BlockReceivedLineConverter.cs @@ -1,4 +1,6 @@ -namespace CodexPlugin.OverwatchSupport.LineConverters +using CodexClient; + +namespace CodexPlugin.OverwatchSupport.LineConverters { public class BlockReceivedLineConverter : ILineConverter { diff --git a/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/BootstrapLineConverter.cs b/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/BootstrapLineConverter.cs index 792b6e50..9cec14f0 100644 --- a/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/BootstrapLineConverter.cs +++ b/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/BootstrapLineConverter.cs @@ -1,4 +1,6 @@ -namespace CodexPlugin.OverwatchSupport.LineConverters +using CodexClient; + +namespace CodexPlugin.OverwatchSupport.LineConverters { public class BootstrapLineConverter : ILineConverter { diff --git a/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/DialSuccessfulLineConverter.cs b/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/DialSuccessfulLineConverter.cs index 0d9f1a7e..510b8dde 100644 --- a/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/DialSuccessfulLineConverter.cs +++ b/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/DialSuccessfulLineConverter.cs @@ -1,4 +1,6 @@ -namespace CodexPlugin.OverwatchSupport.LineConverters +using CodexClient; + +namespace CodexPlugin.OverwatchSupport.LineConverters { public class DialSuccessfulLineConverter : ILineConverter { diff --git a/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/PeerDroppedLineConverter.cs b/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/PeerDroppedLineConverter.cs index 6ec30cd1..858c0f8f 100644 --- a/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/PeerDroppedLineConverter.cs +++ b/ProjectPlugins/CodexPlugin/OverwatchSupport/LineConverters/PeerDroppedLineConverter.cs @@ -1,4 +1,6 @@ -namespace CodexPlugin.OverwatchSupport.LineConverters +using CodexClient; + +namespace CodexPlugin.OverwatchSupport.LineConverters { public class PeerDroppedLineConverter : ILineConverter { diff --git a/ProjectPlugins/CodexPlugin/OverwatchSupport/ModelExtensions.cs b/ProjectPlugins/CodexPlugin/OverwatchSupport/ModelExtensions.cs index a15d998a..b839ced2 100644 --- a/ProjectPlugins/CodexPlugin/OverwatchSupport/ModelExtensions.cs +++ b/ProjectPlugins/CodexPlugin/OverwatchSupport/ModelExtensions.cs @@ -1,4 +1,5 @@ -using OverwatchTranscript; +using CodexClient; +using OverwatchTranscript; namespace CodexPlugin.OverwatchSupport { diff --git a/ProjectPlugins/CodexPluginPrebuild/Program.cs b/ProjectPlugins/CodexPluginPrebuild/Program.cs index fcdf8b5b..6e9d3b9b 100644 --- a/ProjectPlugins/CodexPluginPrebuild/Program.cs +++ b/ProjectPlugins/CodexPluginPrebuild/Program.cs @@ -15,7 +15,7 @@ public static class Program var pluginRoot = FindCodexPluginFolder(); var clientRoot = FindCodexClientFolder(); Console.WriteLine("Located CodexPlugin: " + pluginRoot); - var openApiFile = Path.Combine(pluginRoot, "openapi.yaml"); + var openApiFile = Path.Combine(clientRoot, "openapi.yaml"); var clientFile = Path.Combine(clientRoot, "obj", "openapiClient.cs"); var targetFile = Path.Combine(pluginRoot, "ApiChecker.cs"); diff --git a/Tests/DistTestCore/Configuration.cs b/Tests/DistTestCore/Configuration.cs index 3fa34b5e..c092a27e 100644 --- a/Tests/DistTestCore/Configuration.cs +++ b/Tests/DistTestCore/Configuration.cs @@ -29,12 +29,12 @@ namespace DistTestCore /// public bool AlwaysDownloadContainerLogs { get; set; } - public KubernetesWorkflow.Configuration GetK8sConfiguration(ITimeSet timeSet, string k8sNamespace) + public KubernetesWorkflow.Configuration GetK8sConfiguration(IK8sTimeSet timeSet, string k8sNamespace) { return GetK8sConfiguration(timeSet, new DoNothingK8sHooks(), k8sNamespace); } - public KubernetesWorkflow.Configuration GetK8sConfiguration(ITimeSet timeSet, IK8sHooks hooks, string k8sNamespace) + public KubernetesWorkflow.Configuration GetK8sConfiguration(IK8sTimeSet timeSet, IK8sHooks hooks, string k8sNamespace) { var config = new KubernetesWorkflow.Configuration( kubeConfigFile: kubeConfigFile, diff --git a/Tests/DistTestCore/DistTest.cs b/Tests/DistTestCore/DistTest.cs index 09330df6..691f19ed 100644 --- a/Tests/DistTestCore/DistTest.cs +++ b/Tests/DistTestCore/DistTest.cs @@ -6,6 +6,7 @@ using NUnit.Framework; using NUnit.Framework.Interfaces; using System.Reflection; using Utils; +using WebUtils; using Assert = NUnit.Framework.Assert; namespace DistTestCore @@ -35,7 +36,7 @@ namespace DistTestCore fixtureLog = new FixtureLog(logConfig, startTime, deployId); statusLog = new StatusLog(logConfig, startTime, "dist-tests", deployId); - globalEntryPoint = new EntryPoint(fixtureLog, configuration.GetK8sConfiguration(new DefaultTimeSet(), TestNamespacePrefix), configuration.GetFileManagerFolder()); + globalEntryPoint = new EntryPoint(fixtureLog, configuration.GetK8sConfiguration(new DefaultK8sTimeSet(), TestNamespacePrefix), configuration.GetFileManagerFolder()); Initialize(fixtureLog); } @@ -194,7 +195,8 @@ namespace DistTestCore var lifecycle = new TestLifecycle( fixtureLog.CreateTestLog(), configuration, - GetTimeSet(), + GetWebCallTimeSet(), + GetK8sTimeSet(), testNamespace, deployId, ShouldWaitForCleanup()); @@ -241,10 +243,16 @@ namespace DistTestCore } } - private ITimeSet GetTimeSet() + private IWebCallTimeSet GetWebCallTimeSet() { - if (ShouldUseLongTimeouts()) return new LongTimeSet(); - return new DefaultTimeSet(); + if (ShouldUseLongTimeouts()) return new LongWebCallTimeSet(); + return new DefaultWebCallTimeSet(); + } + + private IK8sTimeSet GetK8sTimeSet() + { + if (ShouldUseLongTimeouts()) return new LongK8sTimeSet(); + return new DefaultK8sTimeSet(); } private bool ShouldWaitForCleanup() diff --git a/Tests/DistTestCore/TestLifecycle.cs b/Tests/DistTestCore/TestLifecycle.cs index 16a4ecd4..2a11cedb 100644 --- a/Tests/DistTestCore/TestLifecycle.cs +++ b/Tests/DistTestCore/TestLifecycle.cs @@ -6,6 +6,7 @@ using KubernetesWorkflow.Recipe; using KubernetesWorkflow.Types; using Logging; using Utils; +using WebUtils; namespace DistTestCore { @@ -18,15 +19,16 @@ namespace DistTestCore private readonly string deployId; private readonly List stoppedContainerLogs = new List(); - public TestLifecycle(TestLog log, Configuration configuration, ITimeSet timeSet, string testNamespace, string deployId, bool waitForCleanup) + public TestLifecycle(TestLog log, Configuration configuration, IWebCallTimeSet webCallTimeSet, IK8sTimeSet k8sTimeSet, string testNamespace, string deployId, bool waitForCleanup) { Log = log; Configuration = configuration; - TimeSet = timeSet; + WebCallTimeSet = webCallTimeSet; + K8STimeSet = k8sTimeSet; TestNamespace = testNamespace; TestStart = DateTime.UtcNow; - entryPoint = new EntryPoint(log, configuration.GetK8sConfiguration(timeSet, this, testNamespace), configuration.GetFileManagerFolder(), timeSet); + entryPoint = new EntryPoint(log, configuration.GetK8sConfiguration(k8sTimeSet, this, testNamespace), configuration.GetFileManagerFolder(), webCallTimeSet, k8sTimeSet); metadata = entryPoint.GetPluginMetadata(); CoreInterface = entryPoint.CreateInterface(); this.deployId = deployId; @@ -37,7 +39,8 @@ namespace DistTestCore public DateTime TestStart { get; } public TestLog Log { get; } public Configuration Configuration { get; } - public ITimeSet TimeSet { get; } + public IWebCallTimeSet WebCallTimeSet { get; } + public IK8sTimeSet K8STimeSet { get; } public string TestNamespace { get; } public bool WaitForCleanup { get; } public CoreInterface CoreInterface { get; } diff --git a/Tests/ExperimentalTests/AutoBootstrapDistTest.cs b/Tests/ExperimentalTests/AutoBootstrapDistTest.cs index 668f27b5..d39c31ec 100644 --- a/Tests/ExperimentalTests/AutoBootstrapDistTest.cs +++ b/Tests/ExperimentalTests/AutoBootstrapDistTest.cs @@ -1,4 +1,5 @@ -using CodexPlugin; +using CodexClient; +using CodexPlugin; using DistTestCore; using NUnit.Framework; diff --git a/Tests/ExperimentalTests/BasicTests/PyramidTests.cs b/Tests/ExperimentalTests/BasicTests/PyramidTests.cs index 306d9d44..390a6c0e 100644 --- a/Tests/ExperimentalTests/BasicTests/PyramidTests.cs +++ b/Tests/ExperimentalTests/BasicTests/PyramidTests.cs @@ -1,10 +1,5 @@ -using CodexPlugin; +using CodexClient; using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Utils; namespace CodexTests.BasicTests diff --git a/Tests/ExperimentalTests/CodexDistTest.cs b/Tests/ExperimentalTests/CodexDistTest.cs index fbe25ffa..3d83021a 100644 --- a/Tests/ExperimentalTests/CodexDistTest.cs +++ b/Tests/ExperimentalTests/CodexDistTest.cs @@ -1,4 +1,5 @@ using BlockchainUtils; +using CodexClient; using CodexContractsPlugin; using CodexNetDeployer; using CodexPlugin; @@ -15,7 +16,6 @@ using Newtonsoft.Json; using NUnit.Framework; using NUnit.Framework.Constraints; using OverwatchTranscript; -using Utils; namespace CodexTests { diff --git a/Tests/ExperimentalTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs b/Tests/ExperimentalTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs index 00dacd22..8898f49c 100644 --- a/Tests/ExperimentalTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs +++ b/Tests/ExperimentalTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs @@ -1,6 +1,5 @@ -using CodexContractsPlugin; -using CodexPlugin; -using GethPlugin; +using CodexClient; +using CodexContractsPlugin; using NUnit.Framework; using Utils; diff --git a/Tests/ExperimentalTests/DownloadConnectivityTests/MultiswarmTests.cs b/Tests/ExperimentalTests/DownloadConnectivityTests/MultiswarmTests.cs index 29618947..8b8f9d1e 100644 --- a/Tests/ExperimentalTests/DownloadConnectivityTests/MultiswarmTests.cs +++ b/Tests/ExperimentalTests/DownloadConnectivityTests/MultiswarmTests.cs @@ -1,4 +1,4 @@ -using CodexPlugin; +using CodexClient; using FileUtils; using Logging; using NUnit.Framework; diff --git a/Tests/ExperimentalTests/Helpers/FullConnectivityHelper.cs b/Tests/ExperimentalTests/Helpers/FullConnectivityHelper.cs index 58474d16..f57a3c65 100644 --- a/Tests/ExperimentalTests/Helpers/FullConnectivityHelper.cs +++ b/Tests/ExperimentalTests/Helpers/FullConnectivityHelper.cs @@ -1,4 +1,4 @@ -using CodexPlugin; +using CodexClient; using Logging; using NUnit.Framework; diff --git a/Tests/ExperimentalTests/Helpers/PeerConnectionTestHelpers.cs b/Tests/ExperimentalTests/Helpers/PeerConnectionTestHelpers.cs index 692162b8..ab4bd6a3 100644 --- a/Tests/ExperimentalTests/Helpers/PeerConnectionTestHelpers.cs +++ b/Tests/ExperimentalTests/Helpers/PeerConnectionTestHelpers.cs @@ -1,4 +1,4 @@ -using CodexPlugin; +using CodexClient; using Logging; using static CodexTests.Helpers.FullConnectivityHelper; diff --git a/Tests/ExperimentalTests/Helpers/PeerDownloadTestHelpers.cs b/Tests/ExperimentalTests/Helpers/PeerDownloadTestHelpers.cs index 6dab12a1..9f7d309d 100644 --- a/Tests/ExperimentalTests/Helpers/PeerDownloadTestHelpers.cs +++ b/Tests/ExperimentalTests/Helpers/PeerDownloadTestHelpers.cs @@ -1,4 +1,4 @@ -using CodexPlugin; +using CodexClient; using FileUtils; using Logging; using Utils; diff --git a/Tests/ExperimentalTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs b/Tests/ExperimentalTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs index 33225d6f..dc3d049f 100644 --- a/Tests/ExperimentalTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs +++ b/Tests/ExperimentalTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs @@ -1,4 +1,4 @@ -using CodexPlugin; +using CodexClient; using NUnit.Framework; namespace CodexTests.PeerDiscoveryTests diff --git a/Tests/ExperimentalTests/PeerDiscoveryTests/PeerDiscoveryTests.cs b/Tests/ExperimentalTests/PeerDiscoveryTests/PeerDiscoveryTests.cs index 6ec35169..88ee0dbb 100644 --- a/Tests/ExperimentalTests/PeerDiscoveryTests/PeerDiscoveryTests.cs +++ b/Tests/ExperimentalTests/PeerDiscoveryTests/PeerDiscoveryTests.cs @@ -1,6 +1,5 @@ using CodexContractsPlugin; -using CodexPlugin; -using GethPlugin; +using CodexClient; using NUnit.Framework; namespace CodexTests.PeerDiscoveryTests diff --git a/Tests/ExperimentalTests/UtilityTests/LogHelperTests.cs b/Tests/ExperimentalTests/UtilityTests/LogHelperTests.cs index 443201f4..d6a1dfc4 100644 --- a/Tests/ExperimentalTests/UtilityTests/LogHelperTests.cs +++ b/Tests/ExperimentalTests/UtilityTests/LogHelperTests.cs @@ -1,4 +1,4 @@ -using CodexPlugin; +using CodexClient; using NUnit.Framework; using Utils; diff --git a/Tests/ExperimentalTests/UtilityTests/NetworkIsolationTest.cs b/Tests/ExperimentalTests/UtilityTests/NetworkIsolationTest.cs index c100143c..a86f6260 100644 --- a/Tests/ExperimentalTests/UtilityTests/NetworkIsolationTest.cs +++ b/Tests/ExperimentalTests/UtilityTests/NetworkIsolationTest.cs @@ -1,4 +1,5 @@ -using CodexPlugin; +using CodexClient; +using CodexPlugin; using DistTestCore; using NUnit.Framework; using Utils; diff --git a/Tests/FrameworkTests/CodexContractsPlugin/TestTokenTests.cs b/Tests/FrameworkTests/CodexContractsPlugin/TestTokenTests.cs index b74ac86e..3dadf6f2 100644 --- a/Tests/FrameworkTests/CodexContractsPlugin/TestTokenTests.cs +++ b/Tests/FrameworkTests/CodexContractsPlugin/TestTokenTests.cs @@ -1,6 +1,6 @@ -using CodexContractsPlugin; -using NUnit.Framework; +using NUnit.Framework; using System.Numerics; +using Utils; namespace FrameworkTests.CodexContractsPlugin { diff --git a/Tools/AutoClient/CodexInstance.cs b/Tools/AutoClient/CodexInstance.cs index 5399b2b1..3be59d45 100644 --- a/Tools/AutoClient/CodexInstance.cs +++ b/Tools/AutoClient/CodexInstance.cs @@ -1,4 +1,5 @@ -using CodexOpenApi; +using CodexClient; +using CodexOpenApi; using CodexPlugin; using Logging; using Nethereum.Model; diff --git a/Tools/BiblioTech/Commands/MintCommand.cs b/Tools/BiblioTech/Commands/MintCommand.cs index b5cb9330..8a6cd33c 100644 --- a/Tools/BiblioTech/Commands/MintCommand.cs +++ b/Tools/BiblioTech/Commands/MintCommand.cs @@ -1,6 +1,7 @@ using BiblioTech.Options; using CodexContractsPlugin; using GethPlugin; +using Utils; namespace BiblioTech.Commands { diff --git a/Tools/BiblioTech/Commands/UserAssociateCommand.cs b/Tools/BiblioTech/Commands/UserAssociateCommand.cs index 1fc6d63c..61d55fb9 100644 --- a/Tools/BiblioTech/Commands/UserAssociateCommand.cs +++ b/Tools/BiblioTech/Commands/UserAssociateCommand.cs @@ -1,8 +1,6 @@ using BiblioTech.Options; using Discord; -using GethPlugin; -using k8s.KubeConfigModels; -using NBitcoin.Secp256k1; +using Utils; namespace BiblioTech.Commands { @@ -67,14 +65,14 @@ namespace BiblioTech.Commands await Program.AdminChecker.SendInAdminChannel($"User {Mention(user)} used '/{Name}' but the provided address is already in use by another user. (address: {newAddress})"); } - private async Task ResponseOK(CommandContext context, IUser user, GethPlugin.EthAddress newAddress) + private async Task ResponseOK(CommandContext context, IUser user, EthAddress newAddress) { await context.Followup(new string[] -{ + { "Done! Thank you for joining the test net!", "By default, the bot will @-mention you with test-net related notifications.", $"You can enable/disable this behavior with the '/{notifyCommand.Name}' command." -}); + }); await Program.AdminChecker.SendInAdminChannel($"User {Mention(user)} used '/{Name}' successfully. ({newAddress})"); } diff --git a/Tools/BiblioTech/Options/EthAddressOption.cs b/Tools/BiblioTech/Options/EthAddressOption.cs index c8cc0a78..0351972a 100644 --- a/Tools/BiblioTech/Options/EthAddressOption.cs +++ b/Tools/BiblioTech/Options/EthAddressOption.cs @@ -1,5 +1,5 @@ -using GethPlugin; -using Nethereum.Util; +using Nethereum.Util; +using Utils; namespace BiblioTech.Options { diff --git a/Tools/BiblioTech/UserData.cs b/Tools/BiblioTech/UserData.cs index 540c326a..715611e0 100644 --- a/Tools/BiblioTech/UserData.cs +++ b/Tools/BiblioTech/UserData.cs @@ -1,5 +1,6 @@ using CodexContractsPlugin; using GethPlugin; +using Utils; namespace BiblioTech { diff --git a/Tools/BiblioTech/UserRepo.cs b/Tools/BiblioTech/UserRepo.cs index 35d8ec87..d1a766ab 100644 --- a/Tools/BiblioTech/UserRepo.cs +++ b/Tools/BiblioTech/UserRepo.cs @@ -2,6 +2,7 @@ using Discord; using GethPlugin; using Newtonsoft.Json; +using Utils; namespace BiblioTech { diff --git a/Tools/KeyMaker/Controllers/KeyController.cs b/Tools/KeyMaker/Controllers/KeyController.cs index 09644e9c..c4d1890d 100644 --- a/Tools/KeyMaker/Controllers/KeyController.cs +++ b/Tools/KeyMaker/Controllers/KeyController.cs @@ -1,5 +1,5 @@ +using GethPlugin; using Microsoft.AspNetCore.Mvc; -using Utils; namespace KeyMaker.Controllers { @@ -10,7 +10,7 @@ namespace KeyMaker.Controllers [HttpGet] public KeyResponse Get() { - var account = EthAccount.GenerateNew(); + var account = EthAccountGenerator.GenerateNew(); return new KeyResponse { diff --git a/Tools/TestNetRewarder/HistoricState.cs b/Tools/TestNetRewarder/HistoricState.cs index 8487aa06..2e744145 100644 --- a/Tools/TestNetRewarder/HistoricState.cs +++ b/Tools/TestNetRewarder/HistoricState.cs @@ -1,7 +1,7 @@ using CodexContractsPlugin; using CodexContractsPlugin.Marketplace; -using GethPlugin; using Newtonsoft.Json; +using Utils; namespace TestNetRewarder { diff --git a/Tools/TestNetRewarder/RequestBuilder.cs b/Tools/TestNetRewarder/RequestBuilder.cs index 6ea25f34..b1f641b8 100644 --- a/Tools/TestNetRewarder/RequestBuilder.cs +++ b/Tools/TestNetRewarder/RequestBuilder.cs @@ -1,5 +1,5 @@ using DiscordRewards; -using GethPlugin; +using Utils; namespace TestNetRewarder { diff --git a/Tools/TestNetRewarder/RewardCheck.cs b/Tools/TestNetRewarder/RewardCheck.cs index b7f6b73b..3739d686 100644 --- a/Tools/TestNetRewarder/RewardCheck.cs +++ b/Tools/TestNetRewarder/RewardCheck.cs @@ -1,9 +1,8 @@ using BlockchainUtils; using CodexContractsPlugin.ChainMonitor; using DiscordRewards; -using GethPlugin; -using NethereumWorkflow; using System.Numerics; +using Utils; namespace TestNetRewarder { diff --git a/Tools/TranscriptAnalysis/Receivers/LogReplaceReceiver.cs b/Tools/TranscriptAnalysis/Receivers/LogReplaceReceiver.cs index d4963eef..a20f656c 100644 --- a/Tools/TranscriptAnalysis/Receivers/LogReplaceReceiver.cs +++ b/Tools/TranscriptAnalysis/Receivers/LogReplaceReceiver.cs @@ -1,4 +1,4 @@ -using CodexPlugin; +using CodexClient; using CodexPlugin.OverwatchSupport; using OverwatchTranscript; diff --git a/Tools/TranscriptAnalysis/Receivers/NodesDegree.cs b/Tools/TranscriptAnalysis/Receivers/NodesDegree.cs index d3ab71a0..d37b3d38 100644 --- a/Tools/TranscriptAnalysis/Receivers/NodesDegree.cs +++ b/Tools/TranscriptAnalysis/Receivers/NodesDegree.cs @@ -1,4 +1,4 @@ -using CodexPlugin; +using CodexClient; using CodexPlugin.OverwatchSupport; using OverwatchTranscript;