Cleanup marketplace tests

This commit is contained in:
ThatBen 2025-05-29 14:38:02 +02:00
parent 830c392995
commit de49328573
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
3 changed files with 70 additions and 11 deletions

View File

@ -5,8 +5,7 @@ using Utils;
namespace CodexReleaseTests.MarketTests
{
[TestFixture(5, 3, 1)]
//[TestFixture(10, 6, 3)]
//[TestFixture(10, 20, 10)]
[TestFixture(10, 20, 10)]
public class ContractSuccessfulTest : MarketplaceAutoBootstrapDistTest
{
public ContractSuccessfulTest(int hosts, int slots, int tolerance)

View File

@ -0,0 +1,68 @@
using CodexClient;
using NUnit.Framework;
using Utils;
namespace CodexReleaseTests.MarketTests
{
[TestFixture]
public class ContractsStartTest : MarketplaceAutoBootstrapDistTest
{
private const int FilesizeMb = 10;
private readonly TestToken pricePerBytePerSecond = 10.TstWei();
protected override int NumberOfHosts => 5;
protected override int NumberOfClients => 1;
protected override ByteSize HostAvailabilitySize => (5 * FilesizeMb).MB();
protected override TimeSpan HostAvailabilityMaxDuration => Get8TimesConfiguredPeriodDuration() * 12;
[Test]
[Combinatorial]
public void ContractStarts(
[Values(1, 2, 3)] int rerunA,
[Values(1, 2, 3)] int rerunB,
[Values(1, 2, 3)] int rerunC)
{
var hosts = StartHosts();
var client = StartClients().Single();
var request = CreateStorageRequest(client);
request.WaitForStorageContractSubmitted();
AssertContractIsOnChain(request);
WaitForContractStarted(request);
AssertContractSlotsAreFilledByHosts(request, 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(),
Expiry = GetContractExpiry(),
MinRequiredNumberOfNodes = 3,
NodeFailureTolerance = 1,
PricePerBytePerSecond = pricePerBytePerSecond,
ProofProbability = 20,
CollateralPerByte = 100.TstWei()
});
}
private TimeSpan GetContractExpiry()
{
return GetContractDuration() / 2;
}
private TimeSpan GetContractDuration()
{
return Get8TimesConfiguredPeriodDuration();
}
private TimeSpan Get8TimesConfiguredPeriodDuration()
{
return GetPeriodDuration() * 8.0;
}
}
}

View File

@ -5,11 +5,7 @@ using Utils;
namespace CodexReleaseTests.MarketTests
{
//[TestFixture(8, 3, 1)]
[TestFixture(12, 48, 12)]
//[TestFixture(10, 5, 1)]
//[TestFixture(10, 6, 1)]
//[TestFixture(10, 6, 3)]
public class MultipleContractsTest : MarketplaceAutoBootstrapDistTest
{
public MultipleContractsTest(int hosts, int slots, int tolerance)
@ -33,7 +29,7 @@ namespace CodexReleaseTests.MarketTests
[Test]
[Combinatorial]
public void MultipleContractGenerations(
[Values(50)] int numGenerations)
[Values(10)] int numGenerations)
{
var hosts = StartHosts();
var clients = StartClients();
@ -58,10 +54,6 @@ namespace CodexReleaseTests.MarketTests
});
All(requests, WaitForContractStarted);
// 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<T>(T[] items, Action<T> action)