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) private void SetCommandOverride(MarketplaceSetup ms)
{ {
var persistenceRequired = ms.IsClientNode || ms.IsStorageNode || ms.IsValidator; if (ms.IsStorageNode)
var proverRequired = ms.IsStorageNode;
if (persistenceRequired && proverRequired)
{ {
OverrideCommand("codex", "persistence", "prover"); OverrideCommand("codex", "persistence", "prover");
} }
else if (persistenceRequired) else
{ {
OverrideCommand("codex", "persistence"); OverrideCommand("codex", "persistence");
} }

View File

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

View File

@ -21,7 +21,9 @@ namespace CodexTests.BasicTests
var group = AddCodex(5, o => o var group = AddCodex(5, o => o
.EnableMetrics() .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)) .WithBlockTTL(TimeSpan.FromMinutes(5))
.WithBlockMaintenanceInterval(TimeSpan.FromSeconds(10)) .WithBlockMaintenanceInterval(TimeSpan.FromSeconds(10))
.WithBlockMaintenanceNumber(100) .WithBlockMaintenanceNumber(100)

View File

@ -64,7 +64,9 @@ namespace CodexTests.BasicTests
.WithName("Seller") .WithName("Seller")
.WithLogLevel(CodexLogLevel.Trace, new CodexLogCustomTopics(CodexLogLevel.Error, CodexLogLevel.Error, CodexLogLevel.Warn)) .WithLogLevel(CodexLogLevel.Trace, new CodexLogCustomTopics(CodexLogLevel.Error, CodexLogLevel.Error, CodexLogLevel.Warn))
.WithStorageQuota(11.GB()) .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)); .WithSimulateProofFailures(failEveryNProofs: 3));
AssertBalance(contracts, seller, Is.EqualTo(sellerInitialBalance)); AssertBalance(contracts, seller, Is.EqualTo(sellerInitialBalance));

View File

@ -41,7 +41,11 @@ namespace CodexNetDeployer
if (config.ShouldMakeStorageAvailable) 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); if (bootstrapNode != null) s.WithBootstrapNode(bootstrapNode);