mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-08 08:23:06 +00:00
GethNode interface exposes EthAddress
This commit is contained in:
parent
a80c5c0d08
commit
9499e53bcf
@ -1,6 +1,7 @@
|
||||
using BlockchainUtils;
|
||||
using Logging;
|
||||
using Nethereum.Web3;
|
||||
using Utils;
|
||||
|
||||
namespace NethereumWorkflow
|
||||
{
|
||||
@ -27,6 +28,12 @@ namespace NethereumWorkflow
|
||||
return new NethereumInteraction(log, CreateWeb3(), blockCache);
|
||||
}
|
||||
|
||||
public EthAddress GetEthAddress()
|
||||
{
|
||||
var account = new Nethereum.Web3.Accounts.Account(privateKey);
|
||||
return new EthAddress(account.Address);
|
||||
}
|
||||
|
||||
private Web3 CreateWeb3()
|
||||
{
|
||||
var account = new Nethereum.Web3.Accounts.Account(privateKey);
|
||||
|
||||
@ -13,6 +13,7 @@ namespace GethPlugin
|
||||
public interface IGethNode : IHasContainer
|
||||
{
|
||||
GethDeployment StartResult { get; }
|
||||
EthAddress CurrentAddress { get; }
|
||||
|
||||
Ether GetEthBalance();
|
||||
Ether GetEthBalance(IHasEthAddress address);
|
||||
@ -46,10 +47,12 @@ namespace GethPlugin
|
||||
this.log = log;
|
||||
this.blockCache = blockCache;
|
||||
StartResult = startResult;
|
||||
CurrentAddress = new EthAddress(startResult.Account.Account);
|
||||
}
|
||||
|
||||
public GethDeployment StartResult { get; }
|
||||
public RunningContainer Container => StartResult.Container;
|
||||
public EthAddress CurrentAddress { get; }
|
||||
|
||||
public GethBootstrapNode GetBootstrapRecord()
|
||||
{
|
||||
@ -97,6 +100,7 @@ namespace GethPlugin
|
||||
|
||||
public GethDeployment StartResult => throw new NotImplementedException();
|
||||
public RunningContainer Container => throw new NotImplementedException();
|
||||
public EthAddress CurrentAddress { get; }
|
||||
|
||||
public CustomGethNode(ILog log, BlockCache blockCache, string gethHost, int gethPort, string privateKey)
|
||||
{
|
||||
@ -105,6 +109,9 @@ namespace GethPlugin
|
||||
this.gethHost = gethHost;
|
||||
this.gethPort = gethPort;
|
||||
this.privateKey = privateKey;
|
||||
|
||||
var creator = new NethereumInteractionCreator(log, blockCache, gethHost, gethPort, privateKey);
|
||||
CurrentAddress = creator.GetEthAddress();
|
||||
}
|
||||
|
||||
public GethBootstrapNode GetBootstrapRecord()
|
||||
|
||||
@ -1,16 +1,19 @@
|
||||
using BlockchainUtils;
|
||||
using Core;
|
||||
using KubernetesWorkflow;
|
||||
using Logging;
|
||||
|
||||
namespace GethPlugin
|
||||
{
|
||||
public class GethStarter
|
||||
{
|
||||
private readonly IPluginTools tools;
|
||||
private readonly ILog log;
|
||||
|
||||
public GethStarter(IPluginTools tools)
|
||||
{
|
||||
this.tools = tools;
|
||||
log = new LogPrefixer(tools.GetLog(), $"({nameof(GethStarter)}) ");
|
||||
}
|
||||
|
||||
public GethDeployment StartGeth(GethStartupConfig gethStartupConfig)
|
||||
@ -26,7 +29,7 @@ namespace GethPlugin
|
||||
if (containers.Containers.Length != 1) throw new InvalidOperationException("Expected 1 Geth bootstrap node to be created. Test infra failure.");
|
||||
var container = containers.Containers[0];
|
||||
|
||||
var extractor = new GethContainerInfoExtractor(tools.GetLog(), workflow, container);
|
||||
var extractor = new GethContainerInfoExtractor(log, workflow, container);
|
||||
var account = extractor.ExtractAccounts().Accounts.First();
|
||||
var pubKey = extractor.ExtractPubKey();
|
||||
|
||||
@ -45,12 +48,14 @@ namespace GethPlugin
|
||||
public IGethNode WrapGethContainer(GethDeployment startResult, BlockCache blockCache)
|
||||
{
|
||||
startResult = SerializeGate.Gate(startResult);
|
||||
return new DeploymentGethNode(tools.GetLog(), blockCache, startResult);
|
||||
var node = new DeploymentGethNode(tools.GetLog(), blockCache, startResult);
|
||||
Log($"EthAddress: {node.CurrentAddress}");
|
||||
return node;
|
||||
}
|
||||
|
||||
private void Log(string msg)
|
||||
{
|
||||
tools.GetLog().Log(msg);
|
||||
log.Log(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user