From cec27b2cf7307ff55b16ab57615f9e292a3d30ea Mon Sep 17 00:00:00 2001 From: ThatBen Date: Tue, 11 Mar 2025 15:00:27 +0100 Subject: [PATCH] wip --- ProjectPlugins/CodexClient/CodexAccess.cs | 2 +- ProjectPlugins/CodexClient/Mapper.cs | 12 ++- .../CodexClient/MarketplaceAccess.cs | 6 +- .../CodexClient/MarketplaceTypes.cs | 43 +++++++++-- .../ChainMonitor/ChainEvents.cs | 1 - .../ChainMonitor/ChainState.cs | 3 +- .../ChainMonitor/PeriodMonitor.cs | 22 +++++- .../CodexContractsAccess.cs | 3 - .../MarketTests/ChainMonitor.cs | 49 ++++++++++++ .../MarketTests/ContractFailedTest.cs | 21 +++--- .../MarketTests/ContractSuccessfulTest.cs | 3 +- .../MarketplaceAutoBootstrapDistTest.cs | 75 +++++++++++++++++-- Tests/CodexReleaseTests/Parallelism.cs | 2 +- Tests/DistTestCore/Helpers/AssertHelpers.cs | 1 - .../BasicTests/MarketplaceTests.cs | 2 +- Tests/ExperimentalTests/CodexDistTest.cs | 1 + .../UtilityTests/DiscordBotTests.cs | 2 +- Tools/CodexNetDeployer/CodexNodeStarter.cs | 2 +- Tools/TestNetRewarder/EventsFormatter.cs | 8 +- 19 files changed, 203 insertions(+), 55 deletions(-) create mode 100644 Tests/CodexReleaseTests/MarketTests/ChainMonitor.cs diff --git a/ProjectPlugins/CodexClient/CodexAccess.cs b/ProjectPlugins/CodexClient/CodexAccess.cs index 5627d631..ca11ebee 100644 --- a/ProjectPlugins/CodexClient/CodexAccess.cs +++ b/ProjectPlugins/CodexClient/CodexAccess.cs @@ -143,7 +143,7 @@ namespace CodexClient return mapper.Map(OnCodex(api => api.ListDataAsync())); } - public StorageAvailability SalesAvailability(StorageAvailability request) + public StorageAvailability SalesAvailability(CreateStorageAvailability request) { var body = mapper.Map(request); var read = OnCodex(api => api.OfferStorageAsync(body)); diff --git a/ProjectPlugins/CodexClient/Mapper.cs b/ProjectPlugins/CodexClient/Mapper.cs index af851f22..fdaf05db 100644 --- a/ProjectPlugins/CodexClient/Mapper.cs +++ b/ProjectPlugins/CodexClient/Mapper.cs @@ -37,7 +37,7 @@ namespace CodexClient }; } - public CodexOpenApi.SalesAvailabilityCREATE Map(StorageAvailability availability) + public CodexOpenApi.SalesAvailabilityCREATE Map(CreateStorageAvailability availability) { return new CodexOpenApi.SalesAvailabilityCREATE { @@ -71,15 +71,13 @@ namespace CodexClient { return new StorageAvailability ( + availability.Id, ToByteSize(availability.TotalSize), ToTimespan(availability.Duration), new TestToken(ToBigIng(availability.MinPricePerBytePerSecond)), - new TestToken(ToBigIng(availability.TotalCollateral)) - ) - { - Id = availability.Id, - FreeSpace = ToByteSize(availability.FreeSize), - }; + new TestToken(ToBigIng(availability.TotalCollateral)), + ToByteSize(availability.FreeSize) + ); } public StoragePurchase Map(CodexOpenApi.Purchase purchase) diff --git a/ProjectPlugins/CodexClient/MarketplaceAccess.cs b/ProjectPlugins/CodexClient/MarketplaceAccess.cs index b08acfcc..f1c5fddb 100644 --- a/ProjectPlugins/CodexClient/MarketplaceAccess.cs +++ b/ProjectPlugins/CodexClient/MarketplaceAccess.cs @@ -6,7 +6,7 @@ namespace CodexClient { public interface IMarketplaceAccess { - string MakeStorageAvailable(StorageAvailability availability); + string MakeStorageAvailable(CreateStorageAvailability availability); StorageAvailability[] GetAvailabilities(); IStoragePurchaseContract RequestStorage(StoragePurchaseRequest purchase); } @@ -49,7 +49,7 @@ namespace CodexClient return new StoragePurchaseContract(log, codexAccess, response, purchase, hooks); } - public string MakeStorageAvailable(StorageAvailability availability) + public string MakeStorageAvailable(CreateStorageAvailability availability) { availability.Log(log); @@ -77,7 +77,7 @@ namespace CodexClient public class MarketplaceUnavailable : IMarketplaceAccess { - public string MakeStorageAvailable(StorageAvailability availability) + public string MakeStorageAvailable(CreateStorageAvailability availability) { Unavailable(); throw new NotImplementedException(); diff --git a/ProjectPlugins/CodexClient/MarketplaceTypes.cs b/ProjectPlugins/CodexClient/MarketplaceTypes.cs index b9f80228..00214b83 100644 --- a/ProjectPlugins/CodexClient/MarketplaceTypes.cs +++ b/ProjectPlugins/CodexClient/MarketplaceTypes.cs @@ -84,9 +84,9 @@ namespace CodexClient //public PoRParameters Por { get; set; } } - public class StorageAvailability + public class CreateStorageAvailability { - public StorageAvailability(ByteSize totalSpace, TimeSpan maxDuration, TestToken minPricePerBytePerSecond, TestToken totalCollateral) + public CreateStorageAvailability(ByteSize totalSpace, TimeSpan maxDuration, TestToken minPricePerBytePerSecond, TestToken totalCollateral) { TotalSpace = totalSpace; MaxDuration = maxDuration; @@ -94,20 +94,49 @@ namespace CodexClient TotalCollateral = totalCollateral; } - public string Id { get; set; } = string.Empty; public ByteSize TotalSpace { get; } public TimeSpan MaxDuration { get; } public TestToken MinPricePerBytePerSecond { get; } - public TestToken TotalCollateral { get; } - public ByteSize FreeSpace { get; set; } = ByteSize.Zero; + public TestToken TotalCollateral { get; } public void Log(ILog log) { - log.Log($"Storage Availability: (" + + log.Log($"Create storage Availability: (" + $"totalSize: {TotalSpace}, " + - $"maxDuration: {Time.FormatDuration(MaxDuration)}, " + + $"maxDuration: {Time.FormatDuration(MaxDuration)}, " + $"minPricePerBytePerSecond: {MinPricePerBytePerSecond}, " + $"totalCollateral: {TotalCollateral})"); } } + + public class StorageAvailability + { + public StorageAvailability(string id, ByteSize totalSpace, TimeSpan maxDuration, TestToken minPricePerBytePerSecond, TestToken totalCollateral, ByteSize freeSpace) + { + Id = id; + TotalSpace = totalSpace; + MaxDuration = maxDuration; + MinPricePerBytePerSecond = minPricePerBytePerSecond; + TotalCollateral = totalCollateral; + FreeSpace = freeSpace; + } + + public string Id { get; } + public ByteSize TotalSpace { get; } + public TimeSpan MaxDuration { get; } + public TestToken MinPricePerBytePerSecond { get; } + public TestToken TotalCollateral { get; } + public ByteSize FreeSpace { get; } + + public void Log(ILog log) + { + log.Log($"Storage Availability: (" + + $"id: {Id}, " + + $"totalSize: {TotalSpace}, " + + $"maxDuration: {Time.FormatDuration(MaxDuration)}, " + + $"minPricePerBytePerSecond: {MinPricePerBytePerSecond}, " + + $"totalCollateral: {TotalCollateral}, " + + $"freeSpace: {FreeSpace})"); + } + } } diff --git a/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainEvents.cs b/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainEvents.cs index 8c2992da..6bbfa3cc 100644 --- a/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainEvents.cs +++ b/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainEvents.cs @@ -1,5 +1,4 @@ using CodexContractsPlugin.Marketplace; -using System.Collections.Generic; using Utils; namespace CodexContractsPlugin.ChainMonitor diff --git a/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainState.cs b/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainState.cs index 0035dc98..6b924585 100644 --- a/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainState.cs +++ b/ProjectPlugins/CodexContractsPlugin/ChainMonitor/ChainState.cs @@ -1,6 +1,5 @@ using BlockchainUtils; using CodexContractsPlugin.Marketplace; -using GethPlugin; using Logging; using System.Numerics; using Utils; @@ -79,7 +78,7 @@ namespace CodexContractsPlugin.ChainMonitor throw new Exception(msg); } - log.Log($"ChainState updating: {events.BlockInterval} = {events.All.Length} events."); + log.Debug($"ChainState updating: {events.BlockInterval} = {events.All.Length} events."); // Run through each block and apply the events to the state in order. var span = events.BlockInterval.TimeRange.Duration; diff --git a/ProjectPlugins/CodexContractsPlugin/ChainMonitor/PeriodMonitor.cs b/ProjectPlugins/CodexContractsPlugin/ChainMonitor/PeriodMonitor.cs index 538ae124..30403d2a 100644 --- a/ProjectPlugins/CodexContractsPlugin/ChainMonitor/PeriodMonitor.cs +++ b/ProjectPlugins/CodexContractsPlugin/ChainMonitor/PeriodMonitor.cs @@ -39,8 +39,6 @@ namespace CodexContractsPlugin.ChainMonitor private void CreateReportForPeriod(ulong lastBlockInPeriod, ulong periodNumber, IChainStateRequest[] requests) { - log.Log("Creating report for period " + periodNumber); - ulong total = 0; ulong required = 0; var missed = new List(); @@ -63,7 +61,9 @@ namespace CodexContractsPlugin.ChainMonitor } } } - reports.Add(new PeriodReport(periodNumber, total, required, missed.ToArray())); + var report = new PeriodReport(periodNumber, total, required, missed.ToArray()); + log.Log($"Period report: {report}"); + reports.Add(report); } } @@ -108,6 +108,16 @@ namespace CodexContractsPlugin.ChainMonitor public ulong TotalNumSlots { get; } public ulong TotalProofsRequired { get; } public PeriodProofMissed[] MissedProofs { get; } + + public override string ToString() + { + var missed = "None"; + if (MissedProofs.Length > 0) + { + missed = string.Join("+", MissedProofs.Select(p => $"{p.FormatHost()} missed {p.Request.Request.Id} slot {p.SlotIndex}")); + } + return $"Period:{PeriodNumber}=[Slots:{TotalNumSlots},ProofsRequired:{TotalProofsRequired},ProofsMissed:{missed}]"; + } } public class PeriodProofMissed @@ -122,5 +132,11 @@ namespace CodexContractsPlugin.ChainMonitor public EthAddress? Host { get; } public IChainStateRequest Request { get; } public int SlotIndex { get; } + + public string FormatHost() + { + if (Host == null) return "Unknown host"; + return Host.Address; + } } } diff --git a/ProjectPlugins/CodexContractsPlugin/CodexContractsAccess.cs b/ProjectPlugins/CodexContractsPlugin/CodexContractsAccess.cs index 120574b4..14143e11 100644 --- a/ProjectPlugins/CodexContractsPlugin/CodexContractsAccess.cs +++ b/ProjectPlugins/CodexContractsPlugin/CodexContractsAccess.cs @@ -3,11 +3,8 @@ using CodexContractsPlugin.Marketplace; using GethPlugin; using Logging; using Nethereum.ABI; -using Nethereum.ABI.FunctionEncoding.Attributes; using Nethereum.Contracts; -using Nethereum.Hex.HexConvertors.Extensions; using Nethereum.Util; -using NethereumWorkflow; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Utils; diff --git a/Tests/CodexReleaseTests/MarketTests/ChainMonitor.cs b/Tests/CodexReleaseTests/MarketTests/ChainMonitor.cs new file mode 100644 index 00000000..72b9da02 --- /dev/null +++ b/Tests/CodexReleaseTests/MarketTests/ChainMonitor.cs @@ -0,0 +1,49 @@ +using CodexContractsPlugin; +using CodexContractsPlugin.ChainMonitor; +using Logging; + +namespace CodexReleaseTests.MarketTests +{ + public class ChainMonitor + { + private readonly ChainState chainMonitor; + private readonly TimeSpan interval; + private CancellationTokenSource cts = new CancellationTokenSource(); + private Task worker = null!; + + public ChainMonitor(ILog log, ICodexContracts contracts, DateTime startUtc, TimeSpan interval) + { + chainMonitor = new ChainState(log, contracts, new DoNothingChainEventHandler(), startUtc, true); + this.interval = interval; + } + + public void Start() + { + cts = new CancellationTokenSource(); + worker = Task.Run(Worker); + } + + public void Stop() + { + cts.Cancel(); + worker.Wait(); + + worker = null!; + cts = null!; + } + + public PeriodMonitorResult GetPeriodReports() + { + return chainMonitor.PeriodMonitor.GetAndClearReports(); + } + + private void Worker() + { + while (!cts.IsCancellationRequested) + { + Thread.Sleep(interval); + chainMonitor.Update(); + } + } + } +} diff --git a/Tests/CodexReleaseTests/MarketTests/ContractFailedTest.cs b/Tests/CodexReleaseTests/MarketTests/ContractFailedTest.cs index caeaed9b..455306be 100644 --- a/Tests/CodexReleaseTests/MarketTests/ContractFailedTest.cs +++ b/Tests/CodexReleaseTests/MarketTests/ContractFailedTest.cs @@ -7,14 +7,16 @@ namespace CodexReleaseTests.MarketTests { public class ContractFailedTest : MarketplaceAutoBootstrapDistTest { - protected override int NumberOfHosts => 4; + private const int FilesizeMb = 10; + private const int NumberOfSlots = 3; + + protected override int NumberOfHosts => 6; protected override int NumberOfClients => 1; - protected override ByteSize HostAvailabilitySize => 1.GB(); - protected override TimeSpan HostAvailabilityMaxDuration => TimeSpan.FromDays(1.0); + protected override ByteSize HostAvailabilitySize => (5 * FilesizeMb).MB(); + protected override TimeSpan HostAvailabilityMaxDuration => TimeSpan.FromDays(5.0); private readonly TestToken pricePerBytePerSecond = 10.TstWei(); [Test] - [Ignore("Disabled for now: Test is unstable.")] public void ContractFailed() { var hosts = StartHosts(); @@ -32,6 +34,7 @@ namespace CodexReleaseTests.MarketTests hosts.Stop(waitTillStopped: true); WaitForSlotFreedEvents(); + AssertProofMissedReports(); request.WaitForContractFailed(); } @@ -47,7 +50,7 @@ namespace CodexReleaseTests.MarketTests { var events = GetContracts().GetEvents(GetTestRunTimeRange()); var slotFreed = events.GetSlotFreedEvents(); - if (slotFreed.Length == NumberOfHosts) + if (slotFreed.Length == NumberOfSlots) { Log($"{nameof(WaitForSlotFreedEvents)} took {Time.FormatDuration(DateTime.UtcNow - start)}"); return; @@ -86,16 +89,16 @@ namespace CodexReleaseTests.MarketTests private IStoragePurchaseContract CreateStorageRequest(ICodexNode client) { - var cid = client.UploadFile(GenerateTestFile(5.MB())); + var cid = client.UploadFile(GenerateTestFile(FilesizeMb.MB())); return client.Marketplace.RequestStorage(new StoragePurchaseRequest(cid) { Duration = TimeSpan.FromHours(1.0), Expiry = TimeSpan.FromHours(0.2), - MinRequiredNumberOfNodes = (uint)NumberOfHosts, - NodeFailureTolerance = (uint)(NumberOfHosts / 2), + MinRequiredNumberOfNodes = NumberOfSlots, + NodeFailureTolerance = 1, PricePerBytePerSecond = pricePerBytePerSecond, ProofProbability = 1, // Require a proof every period - CollateralPerByte = 1.Tst() + CollateralPerByte = 1.TstWei() }); } } diff --git a/Tests/CodexReleaseTests/MarketTests/ContractSuccessfulTest.cs b/Tests/CodexReleaseTests/MarketTests/ContractSuccessfulTest.cs index 8431d121..7b9dd82e 100644 --- a/Tests/CodexReleaseTests/MarketTests/ContractSuccessfulTest.cs +++ b/Tests/CodexReleaseTests/MarketTests/ContractSuccessfulTest.cs @@ -20,6 +20,7 @@ namespace CodexReleaseTests.MarketTests { var hosts = StartHosts(); var client = StartClients().Single(); + AssertHostAvailabilitiesAreEmpty(hosts); var request = CreateStorageRequest(client); @@ -34,12 +35,12 @@ namespace CodexReleaseTests.MarketTests AssertClientHasPaidForContract(pricePerBytePerSecond, client, request, hosts); AssertHostsWerePaidForContract(pricePerBytePerSecond, request, hosts); AssertHostsCollateralsAreUnchanged(hosts); + AssertHostAvailabilitiesAreEmpty(hosts); } private IStoragePurchaseContract CreateStorageRequest(ICodexNode client) { var cid = client.UploadFile(GenerateTestFile(FilesizeMb.MB())); - var config = GetContracts().Deployment.Config; return client.Marketplace.RequestStorage(new StoragePurchaseRequest(cid) { Duration = GetContractDuration(), diff --git a/Tests/CodexReleaseTests/MarketTests/MarketplaceAutoBootstrapDistTest.cs b/Tests/CodexReleaseTests/MarketTests/MarketplaceAutoBootstrapDistTest.cs index 6e898bfe..17d83e3a 100644 --- a/Tests/CodexReleaseTests/MarketTests/MarketplaceAutoBootstrapDistTest.cs +++ b/Tests/CodexReleaseTests/MarketTests/MarketplaceAutoBootstrapDistTest.cs @@ -1,5 +1,6 @@ using CodexClient; using CodexContractsPlugin; +using CodexContractsPlugin.ChainMonitor; using CodexContractsPlugin.Marketplace; using CodexPlugin; using CodexTests; @@ -22,13 +23,17 @@ namespace CodexReleaseTests.MarketTests base.LifecycleStart(lifecycle); var geth = StartGethNode(s => s.IsMiner()); var contracts = Ci.StartCodexContracts(geth); - handles.Add(lifecycle, new MarketplaceHandle(geth, contracts)); + var monitor = new ChainMonitor(lifecycle.Log, contracts, lifecycle.TestStart, TimeSpan.FromSeconds(1.0)); + monitor.Start(); + + handles.Add(lifecycle, new MarketplaceHandle(geth, contracts, monitor)); } protected override void LifecycleStop(TestLifecycle lifecycle, DistTestResult result) { - base.LifecycleStop(lifecycle, result); + handles[lifecycle].Monitor.Stop(); handles.Remove(lifecycle); + base.LifecycleStop(lifecycle, result); } protected IGethNode GetGeth() @@ -44,18 +49,27 @@ namespace CodexReleaseTests.MarketTests protected TimeSpan GetPeriodDuration() { var config = GetContracts().Deployment.Config; - return TimeSpan.FromSeconds(((double)config.Proofs.Period)); + return TimeSpan.FromSeconds(config.Proofs.Period); + } + + protected PeriodMonitorResult GetPeriodMonitorReports() + { + return handles[Get()].Monitor.GetPeriodReports(); } protected abstract int NumberOfHosts { get; } protected abstract int NumberOfClients { get; } protected abstract ByteSize HostAvailabilitySize { get; } protected abstract TimeSpan HostAvailabilityMaxDuration { get; } + protected TimeSpan HostBlockTTL { get; } = TimeSpan.FromMinutes(1.0); public ICodexNodeGroup StartHosts() { var hosts = StartCodex(NumberOfHosts, s => s .WithName("host") + .WithBlockTTL(HostBlockTTL) + .WithBlockMaintenanceNumber(100000) + .WithBlockMaintenanceInterval(HostBlockTTL / 4) .EnableMarketplace(GetGeth(), GetContracts(), m => m .WithInitial(StartingBalanceEth.Eth(), StartingBalanceTST.Tst()) .AsStorageNode() @@ -67,17 +81,49 @@ namespace CodexReleaseTests.MarketTests { AssertTstBalance(host, StartingBalanceTST.Tst(), nameof(StartHosts)); AssertEthBalance(host, StartingBalanceEth.Eth(), nameof(StartHosts)); - - host.Marketplace.MakeStorageAvailable(new StorageAvailability( + + var spaceBefore = host.Space(); + Assert.That(spaceBefore.QuotaReservedBytes, Is.EqualTo(0)); + Assert.That(spaceBefore.QuotaUsedBytes, Is.EqualTo(0)); + + host.Marketplace.MakeStorageAvailable(new CreateStorageAvailability( totalSpace: HostAvailabilitySize, maxDuration: HostAvailabilityMaxDuration, minPricePerBytePerSecond: 1.TstWei(), totalCollateral: 999999.Tst()) ); + + var spaceAfter = host.Space(); + Assert.That(spaceAfter.QuotaReservedBytes, Is.EqualTo(HostAvailabilitySize.SizeInBytes)); + Assert.That(spaceAfter.QuotaUsedBytes, Is.EqualTo(0)); } return hosts; } + public void AssertHostAvailabilitiesAreEmpty(IEnumerable hosts) + { + var retry = GetAvailabilitySpaceAssertRetry(); + retry.Run(() => + { + foreach (var host in hosts) + { + AssertHostAvailabilitiesAreEmpty(host); + } + }); + } + + private void AssertHostAvailabilitiesAreEmpty(ICodexNode host) + { + var availabilities = host.Marketplace.GetAvailabilities(); + foreach (var a in availabilities) + { + if (a.FreeSpace.SizeInBytes != a.TotalSpace.SizeInBytes) + { + throw new Exception(nameof(AssertHostAvailabilitiesAreEmpty) + $" free: {a.FreeSpace} total: {a.TotalSpace}"); + } + } + } + public void AssertTstBalance(ICodexNode node, TestToken expectedBalance, string message) { AssertTstBalance(node.EthAddress, expectedBalance, message); @@ -121,6 +167,14 @@ namespace CodexReleaseTests.MarketTests onFail: f => { }); } + private Retry GetAvailabilitySpaceAssertRetry() + { + return new Retry("AssertAvailabilitySpace", + maxTimeout: HostBlockTTL * 3, + sleepAfterFail: TimeSpan.FromSeconds(10.0), + onFail: f => { }); + } + private TestToken GetTstBalance(ICodexNode node) { return GetContracts().GetTestTokenBalance(node); @@ -305,6 +359,13 @@ namespace CodexReleaseTests.MarketTests }, description); } + protected void AssertEnoughProofMissedForSlotFree(ICodexNodeGroup hosts) + { + var slotFills = GetOnChainSlotFills(hosts); + + todo for each filled slot, there should be enough proofs missed to trigger the slot-free event. + } + public class SlotFill { public SlotFill(SlotFilledEventDTO slotFilledEvent, ICodexNode host) @@ -319,14 +380,16 @@ namespace CodexReleaseTests.MarketTests private class MarketplaceHandle { - public MarketplaceHandle(IGethNode geth, ICodexContracts contracts) + public MarketplaceHandle(IGethNode geth, ICodexContracts contracts, ChainMonitor monitor) { Geth = geth; Contracts = contracts; + Monitor = monitor; } public IGethNode Geth { get; } public ICodexContracts Contracts { get; } + public ChainMonitor Monitor { get; } } } } diff --git a/Tests/CodexReleaseTests/Parallelism.cs b/Tests/CodexReleaseTests/Parallelism.cs index a1b26c73..cd0a4299 100644 --- a/Tests/CodexReleaseTests/Parallelism.cs +++ b/Tests/CodexReleaseTests/Parallelism.cs @@ -1,6 +1,6 @@ using NUnit.Framework; -[assembly: LevelOfParallelism(1)] +[assembly: LevelOfParallelism(10)] namespace CodexReleaseTests.DataTests { } diff --git a/Tests/DistTestCore/Helpers/AssertHelpers.cs b/Tests/DistTestCore/Helpers/AssertHelpers.cs index c0f995d3..0b2efbbc 100644 --- a/Tests/DistTestCore/Helpers/AssertHelpers.cs +++ b/Tests/DistTestCore/Helpers/AssertHelpers.cs @@ -10,7 +10,6 @@ namespace DistTestCore.Helpers { try { - Time.WaitUntil(() => { var c = constraint.Resolve(); return c.ApplyTo(actual()).IsSuccess; diff --git a/Tests/ExperimentalTests/BasicTests/MarketplaceTests.cs b/Tests/ExperimentalTests/BasicTests/MarketplaceTests.cs index f8ef52d5..7ad08ad3 100644 --- a/Tests/ExperimentalTests/BasicTests/MarketplaceTests.cs +++ b/Tests/ExperimentalTests/BasicTests/MarketplaceTests.cs @@ -50,7 +50,7 @@ namespace ExperimentalTests.BasicTests { AssertBalance(contracts, host, Is.EqualTo(hostInitialBalance)); - var availability = new StorageAvailability( + var availability = new CreateStorageAvailability( totalSpace: 10.GB(), maxDuration: TimeSpan.FromMinutes(30), minPricePerBytePerSecond: 1.TstWei(), diff --git a/Tests/ExperimentalTests/CodexDistTest.cs b/Tests/ExperimentalTests/CodexDistTest.cs index 4cc9c707..922f5959 100644 --- a/Tests/ExperimentalTests/CodexDistTest.cs +++ b/Tests/ExperimentalTests/CodexDistTest.cs @@ -182,6 +182,7 @@ namespace CodexTests public void AssertBalance(ICodexContracts contracts, ICodexNode codexNode, Constraint constraint, string msg = "") { + Assert.Fail("Depricated, use MarketplaceAutobootstrapDistTest assertBalances instead."); AssertHelpers.RetryAssert(constraint, () => contracts.GetTestTokenBalance(codexNode), nameof(AssertBalance) + msg); } diff --git a/Tests/ExperimentalTests/UtilityTests/DiscordBotTests.cs b/Tests/ExperimentalTests/UtilityTests/DiscordBotTests.cs index abebac0c..8fdb79ec 100644 --- a/Tests/ExperimentalTests/UtilityTests/DiscordBotTests.cs +++ b/Tests/ExperimentalTests/UtilityTests/DiscordBotTests.cs @@ -198,7 +198,7 @@ namespace ExperimentalTests.UtilityTests .AsStorageNode() .AsValidator())); - var availability = new StorageAvailability( + var availability = new CreateStorageAvailability( totalSpace: Mult(GetMinFileSize(), GetNumberOfLiveHosts()), maxDuration: TimeSpan.FromMinutes(30), minPricePerBytePerSecond: 1.TstWei(), diff --git a/Tools/CodexNetDeployer/CodexNodeStarter.cs b/Tools/CodexNetDeployer/CodexNodeStarter.cs index 92fc77c0..77a09d32 100644 --- a/Tools/CodexNetDeployer/CodexNodeStarter.cs +++ b/Tools/CodexNetDeployer/CodexNodeStarter.cs @@ -69,7 +69,7 @@ namespace CodexNetDeployer if (config.ShouldMakeStorageAvailable) { - var availability = new StorageAvailability( + var availability = new CreateStorageAvailability( totalSpace: config.StorageSell!.Value.MB(), maxDuration: TimeSpan.FromSeconds(config.MaxDuration), minPricePerBytePerSecond: config.MinPricePerBytePerSecond.TstWei(), diff --git a/Tools/TestNetRewarder/EventsFormatter.cs b/Tools/TestNetRewarder/EventsFormatter.cs index 388515d3..7e363432 100644 --- a/Tools/TestNetRewarder/EventsFormatter.cs +++ b/Tools/TestNetRewarder/EventsFormatter.cs @@ -165,13 +165,7 @@ namespace TestNetRewarder private void DescribeMissedProof(List lines, PeriodProofMissed missedProof) { - lines.Add($"[{FormatHost(missedProof.Host)}] missed proof for {FormatRequestId(missedProof.Request)} (slotIndex: {missedProof.SlotIndex})"); - } - - private string FormatHost(EthAddress? host) - { - if (host == null) return "Unknown host"; - return host.Address; + lines.Add($"[{missedProof.FormatHost()}] missed proof for {FormatRequestId(missedProof.Request)} (slotIndex: {missedProof.SlotIndex})"); } private void AddRequestBlock(RequestEvent requestEvent, string eventName, params string[] content)