Updates usages of EnableMarketplace

This commit is contained in:
Ben 2024-03-13 10:29:26 +01:00
parent a6a8c3f1e7
commit 90b90be3cb
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
5 changed files with 20 additions and 18 deletions

View File

@ -128,14 +128,11 @@ namespace CodexPlugin
private void SetCommandOverride(MarketplaceSetup ms)
{
var persistenceRequired = ms.IsClientNode || ms.IsStorageNode || ms.IsValidator;
var proverRequired = ms.IsStorageNode;
if (persistenceRequired && proverRequired)
if (ms.IsStorageNode)
{
OverrideCommand("codex", "persistence", "prover");
}
else if (persistenceRequired)
else
{
OverrideCommand("codex", "persistence");
}

View File

@ -17,6 +17,7 @@ namespace CodexPlugin
ICodexSetup WithBlockMaintenanceInterval(TimeSpan duration);
ICodexSetup WithBlockMaintenanceNumber(int numberOfBlocks);
ICodexSetup EnableMetrics();
ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens);
ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens, Action<IMarketplaceSetup> marketplaceSetup);
/// <summary>
/// Provides an invalid proof every N proofs
@ -28,7 +29,6 @@ namespace CodexPlugin
public interface IMarketplaceSetup
{
IMarketplaceSetup AsStorageNode();
IMarketplaceSetup AsClientNode();
IMarketplaceSetup AsValidator();
}
@ -122,6 +122,11 @@ namespace CodexPlugin
return this;
}
public ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens)
{
return EnableMarketplace(gethNode, codexContracts, initialEth, initialTokens, s => { });
}
public ICodexSetup EnableMarketplace(IGethNode gethNode, ICodexContracts codexContracts, Ether initialEth, TestToken initialTokens, Action<IMarketplaceSetup> marketplaceSetup)
{
var ms = new MarketplaceSetup();
@ -162,16 +167,9 @@ namespace CodexPlugin
public class MarketplaceSetup : IMarketplaceSetup
{
public bool IsClientNode { get; private set; }
public bool IsStorageNode { get; private set; }
public bool IsValidator { get; private set; }
public IMarketplaceSetup AsClientNode()
{
IsClientNode = true;
return this;
}
public IMarketplaceSetup AsStorageNode()
{
IsStorageNode = true;
@ -186,8 +184,7 @@ namespace CodexPlugin
public override string ToString()
{
var result = "[";
result += IsClientNode ? "(clientNode)" : "()";
var result = "[(clientNode)"; // When marketplace is enabled, being a clientNode is implicit.
result += IsStorageNode ? "(storageNode)" : "()";
result += IsValidator ? "(validator)" : "()";
result += "]";

View File

@ -21,7 +21,9 @@ namespace CodexTests.BasicTests
var group = AddCodex(5, o => o
.EnableMetrics()
.EnableMarketplace(geth, contract, 10.Eth(), 100000.TestTokens(), isValidator: true)
.EnableMarketplace(geth, contract, 10.Eth(), 100000.TestTokens(), s => s
.AsStorageNode()
.AsValidator())
.WithBlockTTL(TimeSpan.FromMinutes(5))
.WithBlockMaintenanceInterval(TimeSpan.FromSeconds(10))
.WithBlockMaintenanceNumber(100)

View File

@ -64,7 +64,9 @@ namespace CodexTests.BasicTests
.WithName("Seller")
.WithLogLevel(CodexLogLevel.Trace, new CodexLogCustomTopics(CodexLogLevel.Error, CodexLogLevel.Error, CodexLogLevel.Warn))
.WithStorageQuota(11.GB())
.EnableMarketplace(geth, contracts, initialEth: 10.Eth(), initialTokens: sellerInitialBalance, isValidator: true)
.EnableMarketplace(geth, contracts, initialEth: 10.Eth(), initialTokens: sellerInitialBalance, s => s
.AsStorageNode()
.AsValidator())
.WithSimulateProofFailures(failEveryNProofs: 3));
AssertBalance(contracts, seller, Is.EqualTo(sellerInitialBalance));

View File

@ -41,7 +41,11 @@ namespace CodexNetDeployer
if (config.ShouldMakeStorageAvailable)
{
s.EnableMarketplace(gethNode, contracts, 100.Eth(), config.InitialTestTokens.TestTokens(), validatorsLeft > 0);
s.EnableMarketplace(gethNode, contracts, 100.Eth(), config.InitialTestTokens.TestTokens(), s =>
{
if (validatorsLeft > 0) s.AsValidator();
if (config.ShouldMakeStorageAvailable) s.AsStorageNode();
});
}
if (bootstrapNode != null) s.WithBootstrapNode(bootstrapNode);