From 9a52b217652ebf3c331645ba569030824d2f5056 Mon Sep 17 00:00:00 2001 From: ThatBen Date: Thu, 24 Apr 2025 15:34:31 +0200 Subject: [PATCH] extended multigeneration contract testing --- .../MarketTests/ContractSuccessfulTest.cs | 9 +++- .../MarketTests/MultipleContractsTest.cs | 51 ++++++++++++++----- .../NodeTests/BasicInfoTests.cs | 8 +-- Tests/CodexReleaseTests/Parallelism.cs | 2 +- 4 files changed, 47 insertions(+), 23 deletions(-) diff --git a/Tests/CodexReleaseTests/MarketTests/ContractSuccessfulTest.cs b/Tests/CodexReleaseTests/MarketTests/ContractSuccessfulTest.cs index 66fd6542..7750ede1 100644 --- a/Tests/CodexReleaseTests/MarketTests/ContractSuccessfulTest.cs +++ b/Tests/CodexReleaseTests/MarketTests/ContractSuccessfulTest.cs @@ -6,10 +6,15 @@ namespace CodexReleaseTests.MarketTests { [TestFixture(6, 3, 1)] [TestFixture(6, 4, 2)] + [TestFixture(8, 5, 1)] [TestFixture(8, 5, 2)] + [TestFixture(8, 6, 1)] + [TestFixture(8, 6, 2)] [TestFixture(8, 6, 3)] - [TestFixture(12, 8, 1)] - [TestFixture(12, 8, 4)] + [TestFixture(8, 8, 1)] + [TestFixture(8, 8, 2)] + [TestFixture(8, 8, 3)] + [TestFixture(8, 8, 4)] public class ContractSuccessfulTest : MarketplaceAutoBootstrapDistTest { public ContractSuccessfulTest(int hosts, int slots, int tolerance) diff --git a/Tests/CodexReleaseTests/MarketTests/MultipleContractsTest.cs b/Tests/CodexReleaseTests/MarketTests/MultipleContractsTest.cs index d91dec64..815c4697 100644 --- a/Tests/CodexReleaseTests/MarketTests/MultipleContractsTest.cs +++ b/Tests/CodexReleaseTests/MarketTests/MultipleContractsTest.cs @@ -5,22 +5,42 @@ using Utils; namespace CodexReleaseTests.MarketTests { - [TestFixture] + [TestFixture(6, 3, 1)] + [TestFixture(6, 4, 1)] + [TestFixture(6, 4, 2)] + [TestFixture(8, 5, 1)] + [TestFixture(8, 5, 2)] + [TestFixture(8, 6, 1)] + [TestFixture(8, 6, 2)] + [TestFixture(8, 6, 3)] + [TestFixture(8, 8, 1)] + [TestFixture(8, 8, 2)] + [TestFixture(8, 8, 3)] + [TestFixture(8, 8, 4)] public class MultipleContractsTest : MarketplaceAutoBootstrapDistTest { - private const int FilesizeMb = 10; + public MultipleContractsTest(int hosts, int slots, int tolerance) + { + this.hosts = hosts; + this.slots = slots; + this.tolerance = tolerance; + } - protected override int NumberOfHosts => 8; + private const int FilesizeMb = 10; + private readonly int hosts; + private readonly int slots; + private readonly int tolerance; + + protected override int NumberOfHosts => hosts; protected override int NumberOfClients => 3; - protected override ByteSize HostAvailabilitySize => (5 * FilesizeMb).MB(); - protected override TimeSpan HostAvailabilityMaxDuration => Get8TimesConfiguredPeriodDuration(); + protected override ByteSize HostAvailabilitySize => (100 * FilesizeMb).MB(); + protected override TimeSpan HostAvailabilityMaxDuration => Get8TimesConfiguredPeriodDuration() * 3; private readonly TestToken pricePerBytePerSecond = 10.TstWei(); [Test] - [Ignore("TODO - wip")] [Combinatorial] public void MultipleContractGenerations( - [Values(1, 5, 10)] int numGenerations) + [Values(5)] int numGenerations) { var hosts = StartHosts(); @@ -44,8 +64,13 @@ namespace CodexReleaseTests.MarketTests }); All(requests, r => r.WaitForStorageContractStarted()); - All(requests, r => AssertContractSlotsAreFilledByHosts(r, hosts)); - All(requests, r => r.WaitForStorageContractFinished()); + + Thread.Sleep(TimeSpan.FromSeconds(12.0)); + clients.Stop(waitTillStopped: false); + + // for the time being, we're only interested in whether these contracts start. + //All(requests, r => AssertContractSlotsAreFilledByHosts(r, hosts)); + //All(requests, r => r.WaitForStorageContractFinished()); } private void All(IStoragePurchaseContract[] requests, Action action) @@ -66,11 +91,11 @@ namespace CodexReleaseTests.MarketTests { Duration = GetContractDuration(), Expiry = GetContractExpiry(), - MinRequiredNumberOfNodes = (uint)NumberOfHosts / 2, - NodeFailureTolerance = (uint)(NumberOfHosts / 4), + MinRequiredNumberOfNodes = (uint)slots, + NodeFailureTolerance = (uint)tolerance, PricePerBytePerSecond = pricePerBytePerSecond, ProofProbability = 20, - CollateralPerByte = 1.Tst() + CollateralPerByte = 1.TstWei() }); } @@ -81,7 +106,7 @@ namespace CodexReleaseTests.MarketTests private TimeSpan GetContractDuration() { - return Get8TimesConfiguredPeriodDuration() / 2; + return Get8TimesConfiguredPeriodDuration(); } private TimeSpan Get8TimesConfiguredPeriodDuration() diff --git a/Tests/CodexReleaseTests/NodeTests/BasicInfoTests.cs b/Tests/CodexReleaseTests/NodeTests/BasicInfoTests.cs index 9b9f4bbf..f6cba228 100644 --- a/Tests/CodexReleaseTests/NodeTests/BasicInfoTests.cs +++ b/Tests/CodexReleaseTests/NodeTests/BasicInfoTests.cs @@ -1,11 +1,5 @@ -using CodexPlugin; -using CodexTests; +using CodexTests; using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Utils; namespace CodexReleaseTests.NodeTests diff --git a/Tests/CodexReleaseTests/Parallelism.cs b/Tests/CodexReleaseTests/Parallelism.cs index a1b26c73..ab6a11fb 100644 --- a/Tests/CodexReleaseTests/Parallelism.cs +++ b/Tests/CodexReleaseTests/Parallelism.cs @@ -1,6 +1,6 @@ using NUnit.Framework; -[assembly: LevelOfParallelism(1)] +[assembly: LevelOfParallelism(3)] namespace CodexReleaseTests.DataTests { }