mirror of
https://github.com/codex-storage/cs-codex-dist-tests.git
synced 2025-02-24 01:38:42 +00:00
setting up marketplace tests
This commit is contained in:
parent
f67e67c493
commit
fd3567347b
@ -1,24 +1,45 @@
|
|||||||
using CodexContractsPlugin;
|
using CodexContractsPlugin;
|
||||||
using CodexTests;
|
using CodexPlugin;
|
||||||
using GethPlugin;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Utils;
|
||||||
|
|
||||||
namespace CodexReleaseTests.MarketTests
|
namespace CodexReleaseTests.MarketTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ContractSuccessfulTest : AutoBootstrapDistTest
|
public class ContractSuccessfulTest : MarketplaceAutoBootstrapDistTest
|
||||||
{
|
{
|
||||||
|
private const int NumberOfHosts = 4;
|
||||||
|
private const int FilesizeMb = 10;
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ContractSuccessful()
|
public void ContractSuccessful()
|
||||||
{
|
{
|
||||||
var geth = Ci.StartGethNode(s => s.IsMiner());
|
var hosts = StartHosts();
|
||||||
var contracts = Ci.DeployCodexContracts(geth);
|
|
||||||
|
|
||||||
|
var client = StartCodex(s => s.WithName("client"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICodexNodeGroup StartHosts()
|
||||||
|
{
|
||||||
|
var hosts = StartCodex(NumberOfHosts, s => s.WithName("host"));
|
||||||
|
|
||||||
|
var config = GetContracts().Deployment.Config;
|
||||||
|
foreach (var host in hosts)
|
||||||
|
{
|
||||||
|
host.Marketplace.MakeStorageAvailable(new CodexPlugin.StorageAvailability(
|
||||||
|
totalSpace: (5 * FilesizeMb).MB(),
|
||||||
|
maxDuration: TimeSpan.FromSeconds(((double)config.Proofs.Period) * 5.0),
|
||||||
|
minPriceForTotalSpace: 1.TstWei(),
|
||||||
|
maxCollateral: 999999.Tst())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return hosts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
using CodexContractsPlugin;
|
||||||
|
using CodexPlugin;
|
||||||
|
using CodexTests;
|
||||||
|
using DistTestCore;
|
||||||
|
using GethPlugin;
|
||||||
|
|
||||||
|
namespace CodexReleaseTests.MarketTests
|
||||||
|
{
|
||||||
|
public abstract class MarketplaceAutoBootstrapDistTest : AutoBootstrapDistTest
|
||||||
|
{
|
||||||
|
private readonly Dictionary<TestLifecycle, MarketplaceHandle> handles = new Dictionary<TestLifecycle, MarketplaceHandle>();
|
||||||
|
protected const int StartingBalanceTST = 1000;
|
||||||
|
|
||||||
|
protected override void LifecycleStart(TestLifecycle lifecycle)
|
||||||
|
{
|
||||||
|
base.LifecycleStart(lifecycle);
|
||||||
|
var geth = Ci.StartGethNode(s => s.IsMiner());
|
||||||
|
var contracts = Ci.StartCodexContracts(geth);
|
||||||
|
handles.Add(lifecycle, new MarketplaceHandle(geth, contracts));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LifecycleStop(TestLifecycle lifecycle, DistTestResult result)
|
||||||
|
{
|
||||||
|
base.LifecycleStop(lifecycle, result);
|
||||||
|
handles.Remove(lifecycle);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnCodexSetup(ICodexSetup setup)
|
||||||
|
{
|
||||||
|
base.OnCodexSetup(setup);
|
||||||
|
setup.EnableMarketplace(GetGeth(), GetContracts(), m => m.WithInitial(10.Eth(), StartingBalanceTST.Tst()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IGethNode GetGeth()
|
||||||
|
{
|
||||||
|
return handles[Get()].Geth;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICodexContracts GetContracts()
|
||||||
|
{
|
||||||
|
return handles[Get()].Contracts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MarketplaceHandle
|
||||||
|
{
|
||||||
|
public MarketplaceHandle(IGethNode geth, ICodexContracts contracts)
|
||||||
|
{
|
||||||
|
Geth = geth;
|
||||||
|
Contracts = contracts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IGethNode Geth { get; }
|
||||||
|
public ICodexContracts Contracts { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user