Put SharedRegTestNode to a more consistent place.
Apply better naming.
MODIFY
MagicalCryptoWallet.Tests/RegTests.cs
MagicalCryptoWallet.Tests/RegTests.cs
@@ -27,20 +27,18 @@ namespace MagicalCryptoWallet.Tests
{
private SharedFixture Fixture { get; }
- private static CoreNode SharedRegTestNode { get; set; }
-
public RegTests(SharedFixture fixture)
{
Fixture = fixture;
- if (Fixture.BackEndNodeBuilder == null)
- {
- Fixture.BackEndNodeBuilder = NodeBuilder.Create();
- Fixture.BackEndNodeBuilder.CreateNode();
- Fixture.BackEndNodeBuilder.StartAll();
- SharedRegTestNode = Fixture.BackEndNodeBuilder.Nodes[0];
- SharedRegTestNode.Generate(101);
- var rpc = SharedRegTestNode.CreateRPCClient();
+ if (Fixture.BackendNodeBuilder == null)
+ {
+ Fixture.BackendNodeBuilder = NodeBuilder.Create();
+ Fixture.BackendNodeBuilder.CreateNode();
+ Fixture.BackendNodeBuilder.StartAll();
+ Fixture.BackendRegTestNode = Fixture.BackendNodeBuilder.Nodes[0];
+ Fixture.BackendRegTestNode.Generate(101);
+ var rpc = Fixture.BackendRegTestNode.CreateRPCClient();
var authString = rpc.Authentication.Split(':');
Global.InitializeAsync(rpc.Network, authString[0], authString[1], rpc).GetAwaiter().GetResult();
@@ -173,7 +171,7 @@ namespace MagicalCryptoWallet.Tests
MinVersion = ProtocolVersion.WITNESS_VERSION
}))
{
- nodes.ConnectedNodes.Add(SharedRegTestNode.CreateNodeClient());
+ nodes.ConnectedNodes.Add(Fixture.BackendRegTestNode.CreateNodeClient());
downloader = new BlockDownloader(nodes, blocksFolderPath);
downloader.Start();
@@ -221,7 +219,7 @@ namespace MagicalCryptoWallet.Tests
public async Task MempoolAsync()
{
var memPoolService = new MemPoolService();
- Node node = SharedRegTestNode.CreateNodeClient();
+ Node node = Fixture.BackendRegTestNode.CreateNodeClient();
node.Behaviors.Add(new MemPoolBehavior(memPoolService));
node.VersionHandshake();

MODIFY
MagicalCryptoWallet.Tests/SharedFixture.cs
MagicalCryptoWallet.Tests/SharedFixture.cs
@@ -30,7 +30,9 @@ namespace MagicalCryptoWallet.Tests
public IWebHost BackendHost { get; internal set; }
- public NodeBuilder BackEndNodeBuilder { get; internal set; }
+ public NodeBuilder BackendNodeBuilder { get; internal set; }
+
+ public CoreNode BackendRegTestNode { get; internal set; }
public SharedFixture()
{
@@ -38,7 +40,8 @@ namespace MagicalCryptoWallet.Tests
BackendEndPoint = null;
BackendHost = null;
- BackEndNodeBuilder = null;
+ BackendNodeBuilder = null;
+ BackendRegTestNode = null;
Logger.SetFilePath(Path.Combine(DataDir, "Logs.txt"));
Logger.SetMinimumLevel(LogLevel.Info);
@@ -51,7 +54,8 @@ namespace MagicalCryptoWallet.Tests
BackendHost?.StopAsync();
BackendHost?.Dispose();
- BackEndNodeBuilder?.Dispose();
+ BackendRegTestNode?.Kill(cleanFolder: true);
+ BackendNodeBuilder?.Dispose();
}
}
}

Put SharedRegTestNode to a more consistent place.
Apply better naming.