diff --git a/DistTestCore/GethStarter.cs b/DistTestCore/GethStarter.cs index 914b680..3ac8ce0 100644 --- a/DistTestCore/GethStarter.cs +++ b/DistTestCore/GethStarter.cs @@ -36,13 +36,8 @@ namespace DistTestCore var interaction = marketplaceNetwork.StartInteraction(lifecycle.Log); var tokenAddress = marketplaceNetwork.Marketplace.TokenAddress; - foreach (var account in companionNode.Accounts) - { - interaction.TransferWeiTo(account.Account, marketplaceConfig.InitialEth.Wei); - interaction.MintTestTokens(account.Account, marketplaceConfig.InitialTestTokens.Amount, tokenAddress); - } - - interaction.WaitForAllTransactions(); + var accounts = companionNode.Accounts.Select(a => a.Account).ToArray(); + interaction.MintTestTokens(accounts, marketplaceConfig.InitialTestTokens.Amount, tokenAddress); } private GethStartResult CreateGethStartResult(MarketplaceNetwork marketplaceNetwork, GethCompanionNodeInfo companionNode) diff --git a/DistTestCore/Marketplace/CodexContractsContainerRecipe.cs b/DistTestCore/Marketplace/CodexContractsContainerRecipe.cs index 00a9a7c..1df6d2e 100644 --- a/DistTestCore/Marketplace/CodexContractsContainerRecipe.cs +++ b/DistTestCore/Marketplace/CodexContractsContainerRecipe.cs @@ -7,7 +7,7 @@ namespace DistTestCore.Marketplace #if Arm64 public const string DockerImage = "emizzle/codex-contracts-deployment:latest"; #else - public const string DockerImage = "thatbenbierens/codex-contracts-deployment"; + public const string DockerImage = "thatbenbierens/codex-contracts-deployment:nomint"; #endif public const string MarketplaceAddressFilename = "/usr/app/deployments/codexdisttestnetwork/Marketplace.json"; public const string MarketplaceArtifactFilename = "/usr/app/artifacts/contracts/Marketplace.sol/Marketplace.json"; diff --git a/DistTestCore/Marketplace/ContainerInfoExtractor.cs b/DistTestCore/Marketplace/ContainerInfoExtractor.cs index 281a613..f99827b 100644 --- a/DistTestCore/Marketplace/ContainerInfoExtractor.cs +++ b/DistTestCore/Marketplace/ContainerInfoExtractor.cs @@ -19,13 +19,14 @@ namespace DistTestCore.Marketplace this.container = container; } - public string ExtractAccount(int? orderNumber) + public AllGethAccounts ExtractAccounts() { log.Debug(); - var account = Retry(() => FetchAccount(orderNumber)); - if (string.IsNullOrEmpty(account)) throw new InvalidOperationException("Unable to fetch account for geth node. Test infra failure."); + var accountsCsv = Retry(() => FetchAccountsCsv()); + if (string.IsNullOrEmpty(accountsCsv)) throw new InvalidOperationException("Unable to fetch accounts.csv for geth node. Test infra failure."); - return account; + var lines = accountsCsv.Split('\n'); + return new AllGethAccounts(lines.Select(ParseLineToAccount).ToArray()); } public string ExtractPubKey() @@ -37,15 +38,6 @@ namespace DistTestCore.Marketplace return pubKey; } - public string ExtractPrivateKey(int? orderNumber) - { - log.Debug(); - var privKey = Retry(() => FetchPrivateKey(orderNumber)); - if (string.IsNullOrEmpty(privKey)) throw new InvalidOperationException("Unable to fetch private key from geth node. Test infra failure."); - - return privKey; - } - public string ExtractMarketplaceAddress() { log.Debug(); @@ -88,14 +80,9 @@ namespace DistTestCore.Marketplace } } - private string FetchAccount(int? orderNumber) + private string FetchAccountsCsv() { - return workflow.ExecuteCommand(container, "cat", GethContainerRecipe.GetAccountFilename(orderNumber)); - } - - private string FetchPrivateKey(int? orderNumber) - { - return workflow.ExecuteCommand(container, "cat", GethContainerRecipe.GetPrivateKeyFilename(orderNumber)); + return workflow.ExecuteCommand(container, "cat", GethContainerRecipe.AccountsFilename); } private string FetchMarketplaceAddress() @@ -120,6 +107,15 @@ namespace DistTestCore.Marketplace workflow.DownloadContainerLog(container, enodeFinder); return enodeFinder.GetPubKey(); } + + private GethAccount ParseLineToAccount(string l) + { + var tokens = l.Replace("\r", "").Split(','); + if (tokens.Length != 2) throw new InvalidOperationException(); + var account = tokens[0]; + var privateKey = tokens[1]; + return new GethAccount(account, privateKey); + } } public class PubKeyFinder : LogHandler, ILogHandler diff --git a/DistTestCore/Marketplace/GethBootstrapNodeInfo.cs b/DistTestCore/Marketplace/GethBootstrapNodeInfo.cs index 0c19fbf..b59fb80 100644 --- a/DistTestCore/Marketplace/GethBootstrapNodeInfo.cs +++ b/DistTestCore/Marketplace/GethBootstrapNodeInfo.cs @@ -6,19 +6,19 @@ namespace DistTestCore.Marketplace { public class GethBootstrapNodeInfo { - public GethBootstrapNodeInfo(RunningContainers runningContainers, string account, string pubKey, string privateKey, Port discoveryPort) + public GethBootstrapNodeInfo(RunningContainers runningContainers, AllGethAccounts allAccounts, string pubKey, Port discoveryPort) { RunningContainers = runningContainers; - Account = account; + AllAccounts = allAccounts; + Account = allAccounts.Accounts[0]; PubKey = pubKey; - PrivateKey = privateKey; DiscoveryPort = discoveryPort; } public RunningContainers RunningContainers { get; } - public string Account { get; } + public AllGethAccounts AllAccounts { get; } + public GethAccount Account { get; } public string PubKey { get; } - public string PrivateKey { get; } public Port DiscoveryPort { get; } public NethereumInteraction StartInteraction(BaseLog log) @@ -26,10 +26,19 @@ namespace DistTestCore.Marketplace var ip = RunningContainers.RunningPod.Cluster.IP; var port = RunningContainers.Containers[0].ServicePorts[0].Number; var account = Account; - var privateKey = PrivateKey; - var creator = new NethereumInteractionCreator(log, ip, port, account, privateKey); + var creator = new NethereumInteractionCreator(log, ip, port, account.PrivateKey); return creator.CreateWorkflow(); } } + + public class AllGethAccounts + { + public GethAccount[] Accounts { get; } + + public AllGethAccounts(GethAccount[] accounts) + { + Accounts = accounts; + } + } } diff --git a/DistTestCore/Marketplace/GethBootstrapNodeStarter.cs b/DistTestCore/Marketplace/GethBootstrapNodeStarter.cs index 300893b..56296ff 100644 --- a/DistTestCore/Marketplace/GethBootstrapNodeStarter.cs +++ b/DistTestCore/Marketplace/GethBootstrapNodeStarter.cs @@ -20,20 +20,20 @@ namespace DistTestCore.Marketplace var bootstrapContainer = containers.Containers[0]; var extractor = new ContainerInfoExtractor(lifecycle.Log, workflow, bootstrapContainer); - var account = extractor.ExtractAccount(null); + var accounts = extractor.ExtractAccounts(); var pubKey = extractor.ExtractPubKey(); - var privateKey = extractor.ExtractPrivateKey(null); var discoveryPort = bootstrapContainer.Recipe.GetPortByTag(GethContainerRecipe.DiscoveryPortTag); + var result = new GethBootstrapNodeInfo(containers, accounts, pubKey, discoveryPort); - LogEnd($"Geth bootstrap node started with account '{account}'"); + LogEnd($"Geth bootstrap node started with account '{result.Account.Account}'"); - return new GethBootstrapNodeInfo(containers, account, pubKey, privateKey, discoveryPort); + return result; } private StartupConfig CreateBootstrapStartupConfig() { var config = new StartupConfig(); - config.Add(new GethStartupConfig(true, null!, 0)); + config.Add(new GethStartupConfig(true, null!, 0, 0)); return config; } } diff --git a/DistTestCore/Marketplace/GethCompanionNodeInfo.cs b/DistTestCore/Marketplace/GethCompanionNodeInfo.cs index 64e8ad9..5731ab3 100644 --- a/DistTestCore/Marketplace/GethCompanionNodeInfo.cs +++ b/DistTestCore/Marketplace/GethCompanionNodeInfo.cs @@ -6,30 +6,29 @@ namespace DistTestCore.Marketplace { public class GethCompanionNodeInfo { - public GethCompanionNodeInfo(RunningContainer runningContainer, GethCompanionAccount[] accounts) + public GethCompanionNodeInfo(RunningContainer runningContainer, GethAccount[] accounts) { RunningContainer = runningContainer; Accounts = accounts; } public RunningContainer RunningContainer { get; } - public GethCompanionAccount[] Accounts { get; } + public GethAccount[] Accounts { get; } - public NethereumInteraction StartInteraction(BaseLog log, GethCompanionAccount account) + public NethereumInteraction StartInteraction(BaseLog log, GethAccount account) { var ip = RunningContainer.Pod.Cluster.IP; var port = RunningContainer.ServicePorts[0].Number; - var accountStr = account.Account; var privateKey = account.PrivateKey; - var creator = new NethereumInteractionCreator(log, ip, port, accountStr, privateKey); + var creator = new NethereumInteractionCreator(log, ip, port, privateKey); return creator.CreateWorkflow(); } } - public class GethCompanionAccount + public class GethAccount { - public GethCompanionAccount(string account, string privateKey) + public GethAccount(string account, string privateKey) { Account = account; PrivateKey = privateKey; diff --git a/DistTestCore/Marketplace/GethCompanionNodeStarter.cs b/DistTestCore/Marketplace/GethCompanionNodeStarter.cs index 80c1bcd..a71c661 100644 --- a/DistTestCore/Marketplace/GethCompanionNodeStarter.cs +++ b/DistTestCore/Marketplace/GethCompanionNodeStarter.cs @@ -5,6 +5,8 @@ namespace DistTestCore.Marketplace { public class GethCompanionNodeStarter : BaseStarter { + private int companionAccountIndex = 0; + public GethCompanionNodeStarter(TestLifecycle lifecycle, WorkflowCreator workflowCreator) : base(lifecycle, workflowCreator) { @@ -14,53 +16,43 @@ namespace DistTestCore.Marketplace { LogStart($"Initializing companion for {codexSetup.NumberOfNodes} Codex nodes."); - var startupConfig = CreateCompanionNodeStartupConfig(marketplace.Bootstrap, codexSetup.NumberOfNodes); + var config = CreateCompanionNodeStartupConfig(marketplace.Bootstrap, codexSetup.NumberOfNodes); var workflow = workflowCreator.CreateWorkflow(); - var containers = workflow.Start(1, Location.Unspecified, new GethContainerRecipe(), startupConfig); - WaitForAccountCreation(codexSetup.NumberOfNodes); + var containers = workflow.Start(1, Location.Unspecified, new GethContainerRecipe(), CreateStartupConfig(config)); if (containers.Containers.Length != 1) throw new InvalidOperationException("Expected one Geth companion node to be created. Test infra failure."); var container = containers.Containers[0]; - var node = CreateCompanionInfo(workflow, container, codexSetup.NumberOfNodes); + var node = CreateCompanionInfo(container, marketplace, config); EnsureCompanionNodeIsSynced(node, marketplace); LogEnd($"Initialized one companion node for {codexSetup.NumberOfNodes} Codex nodes. Their accounts: [{string.Join(",", node.Accounts.Select(a => a.Account))}]"); return node; } - private void WaitForAccountCreation(int numberOfNodes) + private GethCompanionNodeInfo CreateCompanionInfo(RunningContainer container, MarketplaceNetwork marketplace, GethStartupConfig config) { - // We wait proportional to the number of account the node has to create. It takes a few seconds for each one to generate the keys and create the files - // we will be trying to read in 'ExtractAccount', later on in the start-up process. - Time.Sleep(TimeSpan.FromSeconds(4.5 * numberOfNodes)); - } - - private GethCompanionNodeInfo CreateCompanionInfo(StartupWorkflow workflow, RunningContainer container, int numberOfAccounts) - { - var extractor = new ContainerInfoExtractor(lifecycle.Log, workflow, container); - var accounts = ExtractAccounts(extractor, numberOfAccounts).ToArray(); + var accounts = ExtractAccounts(marketplace, config); return new GethCompanionNodeInfo(container, accounts); } - private IEnumerable ExtractAccounts(ContainerInfoExtractor extractor, int numberOfAccounts) + private static GethAccount[] ExtractAccounts(MarketplaceNetwork marketplace, GethStartupConfig config) { - for (int i = 0; i < numberOfAccounts; i++) yield return ExtractAccount(extractor, i + 1); - } - - private GethCompanionAccount ExtractAccount(ContainerInfoExtractor extractor, int orderNumber) - { - var account = extractor.ExtractAccount(orderNumber); - var privKey = extractor.ExtractPrivateKey(orderNumber); - return new GethCompanionAccount(account, privKey); + return marketplace.Bootstrap.AllAccounts.Accounts + .Skip(1 + config.CompanionAccountStartIndex) + .Take(config.NumberOfCompanionAccounts) + .ToArray(); } private void EnsureCompanionNodeIsSynced(GethCompanionNodeInfo node, MarketplaceNetwork marketplace) { try { - var interaction = node.StartInteraction(lifecycle.Log, node.Accounts.First()); - interaction.EnsureSynced(marketplace.Marketplace.Address, marketplace.Marketplace.Abi); + Time.WaitUntil(() => + { + var interaction = node.StartInteraction(lifecycle.Log, node.Accounts.First()); + return interaction.IsSynced(marketplace.Marketplace.Address, marketplace.Marketplace.Abi); + }, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(3)); } catch (Exception e) { @@ -68,10 +60,17 @@ namespace DistTestCore.Marketplace } } - private StartupConfig CreateCompanionNodeStartupConfig(GethBootstrapNodeInfo bootstrapNode, int numberOfAccounts) + private GethStartupConfig CreateCompanionNodeStartupConfig(GethBootstrapNodeInfo bootstrapNode, int numberOfAccounts) + { + var config = new GethStartupConfig(false, bootstrapNode, companionAccountIndex, numberOfAccounts); + companionAccountIndex += numberOfAccounts; + return config; + } + + private StartupConfig CreateStartupConfig(GethStartupConfig gethConfig) { var config = new StartupConfig(); - config.Add(new GethStartupConfig(false, bootstrapNode, numberOfAccounts)); + config.Add(gethConfig); return config; } } diff --git a/DistTestCore/Marketplace/GethContainerRecipe.cs b/DistTestCore/Marketplace/GethContainerRecipe.cs index 008d293..fa95054 100644 --- a/DistTestCore/Marketplace/GethContainerRecipe.cs +++ b/DistTestCore/Marketplace/GethContainerRecipe.cs @@ -7,23 +7,14 @@ namespace DistTestCore.Marketplace #if Arm64 public const string DockerImage = "emizzle/geth-confenv:latest"; #else - public const string DockerImage = "thatbenbierens/geth-confenv:latest"; + public const string DockerImage = "thatbenbierens/geth-confenv:onethousand"; #endif + public const string HttpPortTag = "http_port"; public const string DiscoveryPortTag = "disc_port"; private const string defaultArgs = "--ipcdisable --syncmode full"; - public static string GetAccountFilename(int? orderNumber) - { - if (orderNumber == null) return "account_string.txt"; - return $"account_string_{orderNumber.Value}.txt"; - } - - public static string GetPrivateKeyFilename(int? orderNumber) - { - if (orderNumber == null) return "private.key"; - return $"private_{orderNumber.Value}.key"; - } + public const string AccountsFilename = "accounts.csv"; protected override string Image => DockerImage; @@ -50,14 +41,17 @@ namespace DistTestCore.Marketplace private string CreateBootstapArgs(Port discovery) { - AddEnvVar("IS_BOOTSTRAP", "1"); + AddEnvVar("ENABLE_MINER", "1"); + UnlockAccounts(0, 1); var exposedPort = AddExposedPort(tag: HttpPortTag); return $"--http.port {exposedPort.Number} --port {discovery.Number} --discovery.port {discovery.Number} {defaultArgs}"; } private string CreateCompanionArgs(Port discovery, GethStartupConfig config) { - AddEnvVar("NUMBER_OF_ACCOUNTS", config.NumberOfCompanionAccounts.ToString()); + UnlockAccounts( + config.CompanionAccountStartIndex + 1, + config.NumberOfCompanionAccounts); var port = AddInternalPort(); var authRpc = AddInternalPort(); @@ -70,5 +64,15 @@ namespace DistTestCore.Marketplace return $"--port {port.Number} --discovery.port {discovery.Number} --authrpc.port {authRpc.Number} --http.addr 0.0.0.0 --http.port {httpPort.Number} --ws --ws.addr 0.0.0.0 --ws.port {httpPort.Number} {bootstrapArg} {defaultArgs}"; } + + private void UnlockAccounts(int startIndex, int numberOfAccounts) + { + if (startIndex < 0) throw new ArgumentException(); + if (numberOfAccounts < 1) throw new ArgumentException(); + if (startIndex + numberOfAccounts > 1000) throw new ArgumentException("Out of accounts!"); + + AddEnvVar("UNLOCK_START_INDEX", startIndex.ToString()); + AddEnvVar("UNLOCK_NUMBER", numberOfAccounts.ToString()); + } } } diff --git a/DistTestCore/Marketplace/GethStartupConfig.cs b/DistTestCore/Marketplace/GethStartupConfig.cs index bc9671f..7aee078 100644 --- a/DistTestCore/Marketplace/GethStartupConfig.cs +++ b/DistTestCore/Marketplace/GethStartupConfig.cs @@ -2,15 +2,17 @@ { public class GethStartupConfig { - public GethStartupConfig(bool isBootstrapNode, GethBootstrapNodeInfo bootstrapNode, int numberOfCompanionAccounts) + public GethStartupConfig(bool isBootstrapNode, GethBootstrapNodeInfo bootstrapNode, int companionAccountStartIndex, int numberOfCompanionAccounts) { IsBootstrapNode = isBootstrapNode; BootstrapNode = bootstrapNode; + CompanionAccountStartIndex = companionAccountStartIndex; NumberOfCompanionAccounts = numberOfCompanionAccounts; } public bool IsBootstrapNode { get; } public GethBootstrapNodeInfo BootstrapNode { get; } + public int CompanionAccountStartIndex { get; } public int NumberOfCompanionAccounts { get; } } } diff --git a/DistTestCore/Marketplace/MarketplaceAccess.cs b/DistTestCore/Marketplace/MarketplaceAccess.cs index b66679c..1cc19e7 100644 --- a/DistTestCore/Marketplace/MarketplaceAccess.cs +++ b/DistTestCore/Marketplace/MarketplaceAccess.cs @@ -19,10 +19,10 @@ namespace DistTestCore.Marketplace { private readonly TestLog log; private readonly MarketplaceNetwork marketplaceNetwork; - private readonly GethCompanionAccount account; + private readonly GethAccount account; private readonly CodexAccess codexAccess; - public MarketplaceAccess(TestLog log, MarketplaceNetwork marketplaceNetwork, GethCompanionAccount account, CodexAccess codexAccess) + public MarketplaceAccess(TestLog log, MarketplaceNetwork marketplaceNetwork, GethAccount account, CodexAccess codexAccess) { this.log = log; this.marketplaceNetwork = marketplaceNetwork; diff --git a/DistTestCore/Marketplace/MarketplaceAccessFactory.cs b/DistTestCore/Marketplace/MarketplaceAccessFactory.cs index ea4786c..cd37d81 100644 --- a/DistTestCore/Marketplace/MarketplaceAccessFactory.cs +++ b/DistTestCore/Marketplace/MarketplaceAccessFactory.cs @@ -33,10 +33,10 @@ namespace DistTestCore.Marketplace return new MarketplaceAccess(log, marketplaceNetwork, companionNode, access); } - private GethCompanionAccount GetGethCompanionNode(CodexAccess access) + private GethAccount GetGethCompanionNode(CodexAccess access) { - var account = access.Container.Recipe.Additionals.Single(a => a is GethCompanionAccount); - return (GethCompanionAccount)account; + var account = access.Container.Recipe.Additionals.Single(a => a is GethAccount); + return (GethAccount)account; } } } diff --git a/Nethereum/NethereumInteraction.cs b/Nethereum/NethereumInteraction.cs index 3d74e54..46d6da0 100644 --- a/Nethereum/NethereumInteraction.cs +++ b/Nethereum/NethereumInteraction.cs @@ -10,16 +10,13 @@ namespace NethereumWorkflow { public class NethereumInteraction { - private readonly List openTasks = new List(); private readonly BaseLog log; private readonly Web3 web3; - private readonly string rootAccount; - internal NethereumInteraction(BaseLog log, Web3 web3, string rootAccount) + internal NethereumInteraction(BaseLog log, Web3 web3) { this.log = log; this.web3 = web3; - this.rootAccount = rootAccount; } public string GetTokenAddress(string marketplaceAddress) @@ -31,29 +28,13 @@ namespace NethereumWorkflow return Time.Wait(handler.QueryAsync(marketplaceAddress, function)); } - public void TransferWeiTo(string account, decimal amount) + public void MintTestTokens(string[] accounts, decimal amount, string tokenAddress) { - log.Debug($"{amount} --> {account}"); - if (amount < 1 || string.IsNullOrEmpty(account)) throw new ArgumentException("Invalid arguments for AddToBalance"); + if (amount < 1 || accounts.Length < 1) throw new ArgumentException("Invalid arguments for MintTestTokens"); - var value = ToHexBig(amount); - var transactionId = Time.Wait(web3.Eth.TransactionManager.SendTransactionAsync(rootAccount, account, value)); - openTasks.Add(web3.Eth.TransactionManager.TransactionReceiptService.PollForReceiptAsync(transactionId)); - } + var tasks = accounts.Select(a => MintTokens(a, amount, tokenAddress)); - public void MintTestTokens(string account, decimal amount, string tokenAddress) - { - log.Debug($"({tokenAddress}) {amount} --> {account}"); - if (amount < 1 || string.IsNullOrEmpty(account)) throw new ArgumentException("Invalid arguments for MintTestTokens"); - - var function = new MintTokensFunction - { - Holder = account, - Amount = ToBig(amount) - }; - - var handler = web3.Eth.GetContractTransactionHandler(); - openTasks.Add(handler.SendRequestAndWaitForReceiptAsync(tokenAddress, function)); + Task.WaitAll(tasks.ToArray()); } public decimal GetBalance(string tokenAddress, string account) @@ -68,48 +49,54 @@ namespace NethereumWorkflow return ToDecimal(Time.Wait(handler.QueryAsync(tokenAddress, function))); } - public void WaitForAllTransactions() + public bool IsSynced(string marketplaceAddress, string marketplaceAbi) { - var tasks = openTasks.ToArray(); - openTasks.Clear(); - - Task.WaitAll(tasks); + try + { + return IsBlockNumberOK() && IsContractAvailable(marketplaceAddress, marketplaceAbi); + } + catch + { + return false; + } } - public void EnsureSynced(string marketplaceAddress, string marketplaceAbi) + private Task MintTokens(string account, decimal amount, string tokenAddress) { - WaitUntilSynced(); - WaitForContract(marketplaceAddress, marketplaceAbi); + log.Debug($"({tokenAddress}) {amount} --> {account}"); + if (string.IsNullOrEmpty(account)) throw new ArgumentException("Invalid arguments for MintTestTokens"); + + var function = new MintTokensFunction + { + Holder = account, + Amount = ToBig(amount) + }; + + var handler = web3.Eth.GetContractTransactionHandler(); + return handler.SendRequestAndWaitForReceiptAsync(tokenAddress, function); } - private void WaitUntilSynced() + private bool IsBlockNumberOK() { log.Debug(); - Time.WaitUntil(() => - { - var sync = Time.Wait(web3.Eth.Syncing.SendRequestAsync()); - var number = Time.Wait(web3.Eth.Blocks.GetBlockNumber.SendRequestAsync()); - var numberOfBlocks = ToDecimal(number); - return !sync.IsSyncing && numberOfBlocks > 256; - - }, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(3)); + var sync = Time.Wait(web3.Eth.Syncing.SendRequestAsync()); + var number = Time.Wait(web3.Eth.Blocks.GetBlockNumber.SendRequestAsync()); + var numberOfBlocks = ToDecimal(number); + return !sync.IsSyncing && numberOfBlocks > 256; } - private void WaitForContract(string marketplaceAddress, string marketplaceAbi) + private bool IsContractAvailable(string marketplaceAddress, string marketplaceAbi) { log.Debug(); - Time.WaitUntil(() => + try { - try - { - var contract = web3.Eth.GetContract(marketplaceAbi, marketplaceAddress); - return contract != null; - } - catch - { - return false; - } - }, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(3)); + var contract = web3.Eth.GetContract(marketplaceAbi, marketplaceAddress); + return contract != null; + } + catch + { + return false; + } } private HexBigInteger ToHexBig(decimal amount) diff --git a/Nethereum/NethereumInteractionCreator.cs b/Nethereum/NethereumInteractionCreator.cs index ff7e9fd..3ac0431 100644 --- a/Nethereum/NethereumInteractionCreator.cs +++ b/Nethereum/NethereumInteractionCreator.cs @@ -8,21 +8,19 @@ namespace NethereumWorkflow private readonly BaseLog log; private readonly string ip; private readonly int port; - private readonly string rootAccount; private readonly string privateKey; - public NethereumInteractionCreator(BaseLog log, string ip, int port, string rootAccount, string privateKey) + public NethereumInteractionCreator(BaseLog log, string ip, int port, string privateKey) { this.log = log; this.ip = ip; this.port = port; - this.rootAccount = rootAccount; this.privateKey = privateKey; } public NethereumInteraction CreateWorkflow() { - return new NethereumInteraction(log, CreateWeb3(), rootAccount); + return new NethereumInteraction(log, CreateWeb3()); } private Web3 CreateWeb3() diff --git a/Tests/BasicTests/ExampleTests.cs b/Tests/BasicTests/ExampleTests.cs index afafe9a..6951433 100644 --- a/Tests/BasicTests/ExampleTests.cs +++ b/Tests/BasicTests/ExampleTests.cs @@ -71,13 +71,13 @@ namespace Tests.BasicTests requiredCollateral: 10.TestTokens(), minRequiredNumberOfNodes: 1, proofProbability: 5, - duration: TimeSpan.FromMinutes(2)); + duration: TimeSpan.FromMinutes(1)); - Time.Sleep(TimeSpan.FromMinutes(1)); + Time.Sleep(TimeSpan.FromSeconds(10)); seller.Marketplace.AssertThatBalance(Is.LessThan(sellerInitialBalance), "Collateral was not placed."); - Time.Sleep(TimeSpan.FromMinutes(2)); + Time.Sleep(TimeSpan.FromMinutes(1)); seller.Marketplace.AssertThatBalance(Is.GreaterThan(sellerInitialBalance), "Seller was not paid for storage."); buyer.Marketplace.AssertThatBalance(Is.LessThan(buyerInitialBalance), "Buyer was not charged for storage.");