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
|
|
|
|
{
|
2025-06-02 13:32:03 +02:00
|
|
|
|
private readonly PurchaseParams purchaseParams = new PurchaseParams(
|
|
|
|
|
|
nodes: 3,
|
|
|
|
|
|
tolerance: 1,
|
2025-07-09 19:38:53 +02:00
|
|
|
|
uploadFilesize: 3.MB()
|
2025-06-02 13:32:03 +02:00
|
|
|
|
);
|
2025-05-29 14:38:02 +02:00
|
|
|
|
private readonly TestToken pricePerBytePerSecond = 10.TstWei();
|
|
|
|
|
|
|
|
|
|
|
|
protected override int NumberOfHosts => 5;
|
|
|
|
|
|
protected override int NumberOfClients => 1;
|
2025-06-02 13:32:03 +02:00
|
|
|
|
protected override ByteSize HostAvailabilitySize => purchaseParams.SlotSize.Multiply(10.0);
|
2025-05-29 14:38:02 +02:00
|
|
|
|
protected override TimeSpan HostAvailabilityMaxDuration => Get8TimesConfiguredPeriodDuration() * 12;
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
2025-05-30 09:57:21 +02:00
|
|
|
|
[Combinatorial]
|
|
|
|
|
|
public void Start(
|
2025-06-06 09:49:55 +02:00
|
|
|
|
[Rerun] int rerun
|
2025-05-30 09:57:21 +02:00
|
|
|
|
)
|
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)
|
|
|
|
|
|
{
|
2025-06-02 13:32:03 +02:00
|
|
|
|
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(),
|
2025-06-02 13:32:03 +02:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|