diff --git a/DistTestCore/Codex/CodexAccess.cs b/DistTestCore/Codex/CodexAccess.cs index ae84a91..47412e0 100644 --- a/DistTestCore/Codex/CodexAccess.cs +++ b/DistTestCore/Codex/CodexAccess.cs @@ -31,9 +31,9 @@ namespace DistTestCore.Codex return Http().HttpPostJson("sales/availability", request); } - public CodexSalesRequestStorageResponse RequestStorage(CodexSalesRequestStorageRequest request, string contentId) + public string RequestStorage(CodexSalesRequestStorageRequest request, string contentId) { - return Http().HttpPostJson($"storage/request/{contentId}", request); + return Http().HttpPostJson($"storage/request/{contentId}", request); } private Http Http() @@ -91,9 +91,4 @@ namespace DistTestCore.Codex public uint? nodes { get; set; } public uint? tolerance { get; set;} } - - public class CodexSalesRequestStorageResponse - { - public string purchaseId { get; set; } = string.Empty; - } } diff --git a/DistTestCore/Http.cs b/DistTestCore/Http.cs index 62ccbfb..eaccdc8 100644 --- a/DistTestCore/Http.cs +++ b/DistTestCore/Http.cs @@ -41,7 +41,13 @@ namespace DistTestCore public TResponse HttpPostJson(string route, TRequest body) { - var json = Retry(() => + var json = HttpPostJson(route, body); + return TryJsonDeserialize(json); + } + + public string HttpPostJson(string route, TRequest body) + { + return Retry(() => { using var client = GetClient(); var url = GetUrl() + route; @@ -49,8 +55,6 @@ namespace DistTestCore var result = Time.Wait(client.PostAsync(url, content)); return Time.Wait(result.Content.ReadAsStringAsync()); }); - - return TryJsonDeserialize(json); } public string HttpPostStream(string route, Stream stream) diff --git a/DistTestCore/Marketplace/GethCompanionNodeStarter.cs b/DistTestCore/Marketplace/GethCompanionNodeStarter.cs index b087c8a..ad61a9d 100644 --- a/DistTestCore/Marketplace/GethCompanionNodeStarter.cs +++ b/DistTestCore/Marketplace/GethCompanionNodeStarter.cs @@ -41,8 +41,15 @@ namespace DistTestCore.Marketplace private void EnsureCompanionNodeIsSynced(GethCompanionNodeInfo node, MarketplaceNetwork marketplace) { - var interaction = node.StartInteraction(lifecycle.Log); - interaction.EnsureSynced(marketplace.Marketplace.Address, marketplace.Marketplace.Abi); + try + { + var interaction = node.StartInteraction(lifecycle.Log); + interaction.EnsureSynced(marketplace.Marketplace.Address, marketplace.Marketplace.Abi); + } + catch (Exception e) + { + throw new Exception("Geth companion node did not sync within timeout. Test infra failure.", e); + } } private StartupConfig CreateCompanionNodeStartupConfig(GethBootstrapNodeInfo bootstrapNode) diff --git a/DistTestCore/Marketplace/MarketplaceAccess.cs b/DistTestCore/Marketplace/MarketplaceAccess.cs index 881ce93..e77635e 100644 --- a/DistTestCore/Marketplace/MarketplaceAccess.cs +++ b/DistTestCore/Marketplace/MarketplaceAccess.cs @@ -52,9 +52,14 @@ namespace DistTestCore.Marketplace var response = codexAccess.RequestStorage(request, contentId.Id); - Log($"Storage requested successfully. PurchaseId: {response.purchaseId}"); + if (response == "Purchasing not available") + { + throw new InvalidOperationException(response); + } - return response.purchaseId; + Log($"Storage requested successfully. PurchaseId: {response}"); + + return response; } public string MakeStorageAvailable(ByteSize size, TestToken minPricePerBytePerSecond, TestToken maxCollateral, TimeSpan maxDuration) diff --git a/DistTestCore/Tokens.cs b/DistTestCore/Tokens.cs index 07d1692..5593ffc 100644 --- a/DistTestCore/Tokens.cs +++ b/DistTestCore/Tokens.cs @@ -1,6 +1,6 @@ namespace DistTestCore { - public class Ether + public class Ether : IComparable { public Ether(decimal wei) { @@ -9,6 +9,11 @@ public decimal Wei { get; } + public int CompareTo(Ether? other) + { + return Wei.CompareTo(other!.Wei); + } + public override bool Equals(object? obj) { return obj is Ether ether && Wei == ether.Wei; @@ -25,7 +30,7 @@ } } - public class TestToken + public class TestToken : IComparable { public TestToken(decimal amount) { @@ -34,6 +39,11 @@ public decimal Amount { get; } + public int CompareTo(TestToken? other) + { + return Amount.CompareTo(other!.Amount); + } + public override bool Equals(object? obj) { return obj is TestToken token && Amount == token.Amount; diff --git a/Nethereum/NethereumInteraction.cs b/Nethereum/NethereumInteraction.cs index c7384a8..18823de 100644 --- a/Nethereum/NethereumInteraction.cs +++ b/Nethereum/NethereumInteraction.cs @@ -85,6 +85,19 @@ namespace NethereumWorkflow try { var contract = web3.Eth.GetContract(marketplaceAbi, marketplaceAddress); + + if (contract != null) + { + var aaa = 0; + + var func = contract.GetFunction("myRequests"); + var input = func.CreateCallInput(); + var result = Time.Wait(func.CallAsync(input)); + + var eeee = 0; + } + + return contract != null; } catch @@ -92,6 +105,8 @@ namespace NethereumWorkflow return false; } }, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(1)); + + Thread.Sleep(TimeSpan.FromMinutes(2)); } private HexBigInteger ToHexBig(decimal amount)