mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-03 22:13:10 +00:00
73 lines
2.3 KiB
C#
73 lines
2.3 KiB
C#
using CodexClient;
|
|
using CodexReleaseTests.Utils;
|
|
using NUnit.Framework;
|
|
using Utils;
|
|
|
|
namespace CodexReleaseTests.MarketTests
|
|
{
|
|
[TestFixture]
|
|
public class StartTest : MarketplaceAutoBootstrapDistTest
|
|
{
|
|
private readonly PurchaseParams purchaseParams = new PurchaseParams(
|
|
nodes: 3,
|
|
tolerance: 1,
|
|
uploadFilesize: 3.MB()
|
|
);
|
|
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);
|
|
protected override TimeSpan HostAvailabilityMaxDuration => Get8TimesConfiguredPeriodDuration() * 12;
|
|
|
|
[Test]
|
|
[Combinatorial]
|
|
public void Start(
|
|
[Rerun] int rerun
|
|
)
|
|
{
|
|
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));
|
|
var config = GetContracts().Deployment.Config;
|
|
return client.Marketplace.RequestStorage(new StoragePurchaseRequest(cid)
|
|
{
|
|
Duration = GetContractDuration(),
|
|
Expiry = GetContractExpiry(),
|
|
MinRequiredNumberOfNodes = (uint)purchaseParams.Nodes,
|
|
NodeFailureTolerance = (uint)purchaseParams.Tolerance,
|
|
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;
|
|
}
|
|
}
|
|
}
|