73 lines
2.3 KiB
C#
Raw Normal View History

2025-05-29 14:38:02 +02:00
using CodexClient;
2025-05-30 08:59:43 +02:00
using CodexReleaseTests.Utils;
2025-05-29 14:38:02 +02:00
using NUnit.Framework;
using Utils;
namespace CodexReleaseTests.MarketTests
{
[TestFixture]
2025-05-30 08:59:43 +02:00
public class StartTest : MarketplaceAutoBootstrapDistTest
2025-05-29 14:38:02 +02:00
{
private readonly PurchaseParams purchaseParams = new PurchaseParams(
nodes: 3,
tolerance: 1,
uploadFilesize: 3.MB()
);
2025-05-29 14:38:02 +02:00
private readonly TestToken pricePerBytePerSecond = 10.TstWei();
protected override int NumberOfHosts => 5;
protected override int NumberOfClients => 1;
protected override ByteSize HostAvailabilitySize => purchaseParams.SlotSize.Multiply(10.0);
2025-05-29 14:38:02 +02:00
protected override TimeSpan HostAvailabilityMaxDuration => Get8TimesConfiguredPeriodDuration() * 12;
[Test]
[Combinatorial]
public void Start(
2025-06-06 09:49:55 +02:00
[Rerun] int rerun
)
2025-05-29 14:38:02 +02:00
{
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(purchaseParams.UploadFilesize));
2025-05-29 14:38:02 +02:00
var config = GetContracts().Deployment.Config;
return client.Marketplace.RequestStorage(new StoragePurchaseRequest(cid)
{
Duration = GetContractDuration(),
Expiry = GetContractExpiry(),
MinRequiredNumberOfNodes = (uint)purchaseParams.Nodes,
NodeFailureTolerance = (uint)purchaseParams.Tolerance,
2025-05-29 14:38:02 +02:00
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;
}
}
}