Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Fix command line help text for testnet and regtest flags #148

Merged
merged 1 commit into from
May 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 47 additions & 7 deletions Stratis.Bitcoin.Tests/Builder/FullNodeBuilderExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,65 @@ public void UseNodeSettingsConfiguresNodeBuilderWithNodeSettings()
Assert.Equal(NodeSettings.Default().DataDir, this.fullNodeBuilder.NodeSettings.DataDir);
Assert.NotNull(this.fullNodeBuilder.Network);
Assert.Equal(NodeSettings.Default().GetNetwork(),this.fullNodeBuilder.Network);
Assert.Equal(1, serviceCollectionDelegates.Count);
Assert.Equal(1, this.serviceCollectionDelegates.Count);
}

[Fact]
public void UseDefaultNodeSettingsConfiguresNodeBuilderWithDefaultSettings()
[Fact]
public void UseDefaultNodeSettingsConfiguresNodeBuilderWithDefaultSettings()
{
Logs.Configure(new LoggerFactory());

var nodeSettings = NodeSettings.Default();
nodeSettings.ConfigurationFile = "TestData/FullNodeBuilder/UseNodeSettingsConfFile";
nodeSettings.DataDir = "TestData/FullNodeBuilder/UseNodeSettings";
nodeSettings.Testnet = true;

FullNodeBuilderExtensions.UseNodeSettings(this.fullNodeBuilder, nodeSettings);

Assert.NotNull(this.fullNodeBuilder.NodeSettings);
Assert.Equal(nodeSettings.ConfigurationFile, this.fullNodeBuilder.NodeSettings.ConfigurationFile);
Assert.Equal(nodeSettings.DataDir, this.fullNodeBuilder.NodeSettings.DataDir);
Assert.NotNull(this.fullNodeBuilder.Network);
Assert.Equal(Network.Main, this.fullNodeBuilder.Network);
Assert.Equal(1, this.serviceCollectionDelegates.Count);
}

[Fact]
public void UseNodeSettingsUsingTestNetConfiguresNodeBuilderWithTestnetSettings()
{
Logs.Configure(new LoggerFactory());

var nodeSettings = NodeSettings.Default();
var nodeSettings = NodeSettings.FromArguments(new string[] { "-testnet" });
nodeSettings.ConfigurationFile = "TestData/FullNodeBuilder/UseNodeSettingsConfFile";
nodeSettings.DataDir = "TestData/FullNodeBuilder/UseNodeSettings";
nodeSettings.DataDir = "TestData/FullNodeBuilder/UseNodeSettings";

FullNodeBuilderExtensions.UseNodeSettings(this.fullNodeBuilder, nodeSettings);

Assert.NotNull(this.fullNodeBuilder.NodeSettings);
Assert.Equal(nodeSettings.ConfigurationFile, this.fullNodeBuilder.NodeSettings.ConfigurationFile);
Assert.Equal(nodeSettings.DataDir, this.fullNodeBuilder.NodeSettings.DataDir);
Assert.NotNull(this.fullNodeBuilder.Network);
Assert.Equal(1, serviceCollectionDelegates.Count);
Assert.Equal(Network.TestNet, this.fullNodeBuilder.Network);
Assert.Equal(1, this.serviceCollectionDelegates.Count);
}
}

[Fact]
public void UseNodeSettingsUsingRegTestNetConfiguresNodeBuilderWithRegTestNet()
{
Logs.Configure(new LoggerFactory());

var nodeSettings = NodeSettings.FromArguments(new string[] { "-regtest" });
nodeSettings.ConfigurationFile = "TestData/FullNodeBuilder/UseNodeSettingsConfFile";
nodeSettings.DataDir = "TestData/FullNodeBuilder/UseNodeSettings";

FullNodeBuilderExtensions.UseNodeSettings(this.fullNodeBuilder, nodeSettings);

Assert.NotNull(this.fullNodeBuilder.NodeSettings);
Assert.Equal(nodeSettings.ConfigurationFile, this.fullNodeBuilder.NodeSettings.ConfigurationFile);
Assert.Equal(nodeSettings.DataDir, this.fullNodeBuilder.NodeSettings.DataDir);
Assert.NotNull(this.fullNodeBuilder.Network);
Assert.Equal(Network.RegTest, this.fullNodeBuilder.Network);
Assert.Equal(1, this.serviceCollectionDelegates.Count);
}
}
}
10 changes: 5 additions & 5 deletions Stratis.Bitcoin/Configuration/NodeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public static NodeSettings FromArguments(string[] args, string name = "bitcoin"
nodeSettings.ConfigurationFile = Path.Combine(nodeSettings.DataDir, nodeSettings.ConfigurationFile);
}
}
nodeSettings.Testnet = args.Contains("-testnet", StringComparer.CurrentCultureIgnoreCase);
nodeSettings.RegTest = args.Contains("-regtest", StringComparer.CurrentCultureIgnoreCase);
nodeSettings.Testnet = args.Contains("-testnet", StringComparer.CurrentCultureIgnoreCase);
nodeSettings.RegTest = args.Contains("-regtest", StringComparer.CurrentCultureIgnoreCase);

if (nodeSettings.ConfigurationFile != null)
if (nodeSettings.ConfigurationFile != null)
{
AssetConfigFileExists(nodeSettings);
var configTemp = TextFileConfiguration.Parse(File.ReadAllText(nodeSettings.ConfigurationFile));
Expand Down Expand Up @@ -352,8 +352,8 @@ public static bool PrintHelp(string[] args, Network mainNet)
builder.AppendLine("-help/--help Show this help.");
builder.AppendLine($"-conf=<Path> Path to the configuration file. Default {defaults.ConfigurationFile}.");
builder.AppendLine($"-datadir=<Path> Path to the data directory. Default {defaults.DataDir}.");
builder.AppendLine($"-testnet=<0 or 1> Use the testnet chain. Default {defaults.Testnet}.");
builder.AppendLine($"-regtest=<0 or 1> Use the regtestnet chain. Default {defaults.RegTest}.");
builder.AppendLine($"-testnet Use the testnet chain.");
builder.AppendLine($"-regtest Use the regtestnet chain.");
builder.AppendLine($"-acceptnonstdtxn=<0 or 1> Accept non-standard transactions. Default {defaults.RequireStandard}.");
builder.AppendLine($"-maxtipage=<number> Max tip age. Default {DEFAULT_MAX_TIP_AGE}.");
builder.AppendLine($"-server=<0 or 1> Accept command line and JSON-RPC commands. Default {defaults.RPC != null}.");
Expand Down