Add P2P and RPC basic tests.
MODIFY
WalletWasabi.Tests/IntegrationTests/RegTests.cs
WalletWasabi.Tests/IntegrationTests/RegTests.cs
@@ -256,7 +256,7 @@ namespace WalletWasabi.Tests.IntegrationTests
{
(string password, RPCClient rpc, Network network, Coordinator coordinator, ServiceConfiguration serviceConfiguration, BitcoinStore bitcoinStore, Backend.Global global) = await InitializeTestEnvironmentAsync(1);
- Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync();
node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
node.VersionHandshake();
@@ -524,12 +524,12 @@ namespace WalletWasabi.Tests.IntegrationTests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync());
// 2. Create mempool service.
bitcoinStore.MempoolService.TransactionReceived += WalletTestsAsync_MempoolService_TransactionReceived;
- Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync();
node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
@@ -756,11 +756,11 @@ namespace WalletWasabi.Tests.IntegrationTests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync());
// 2. Create mempool service.
- Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync();
node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
@@ -1240,11 +1240,11 @@ namespace WalletWasabi.Tests.IntegrationTests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync());
// 2. Create mempool service.
- Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync();
node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
@@ -1403,11 +1403,11 @@ namespace WalletWasabi.Tests.IntegrationTests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync());
// 2. Create mempool service.
- Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync();
node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
@@ -1566,11 +1566,11 @@ namespace WalletWasabi.Tests.IntegrationTests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync());
// 2. Create mempool service.
- Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync();
node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
@@ -1734,11 +1734,11 @@ namespace WalletWasabi.Tests.IntegrationTests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync());
// 2. Create mempool service.
- Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync();
node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.
@@ -3318,17 +3318,17 @@ namespace WalletWasabi.Tests.IntegrationTests
// Create the services.
// 1. Create connection service.
var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
- nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
+ nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync());
var nodes2 = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
- nodes2.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync());
+ nodes2.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync());
// 2. Create mempool service.
- Node node = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
+ Node node = await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync();
node.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
- Node node2 = await RegTestFixture.BackendRegTestNode.CreateNodeClientAsync();
+ Node node2 = await RegTestFixture.BackendRegTestNode.CreateP2pNodeAsync();
node2.Behaviors.Add(bitcoinStore.CreateMempoolBehavior());
// 3. Create wasabi synchronizer service.

MODIFY
WalletWasabi.Tests/NodeBuilding/CoreNode.cs
WalletWasabi.Tests/NodeBuilding/CoreNode.cs
@@ -151,7 +151,7 @@ namespace WalletWasabi.Tests.NodeBuilding
return coreNode;
}
- public async Task<Node> CreateNodeClientAsync()
+ public async Task<Node> CreateP2pNodeAsync()
{
return await Node.ConnectAsync(Network.RegTest, P2pEndPoint);
}

MODIFY
WalletWasabi.Tests/UnitTests/BitcoinCore/NodeBuildingTests.cs
WalletWasabi.Tests/UnitTests/BitcoinCore/NodeBuildingTests.cs
+using NBitcoin;
using System;
using System.Collections.Generic;
using System.Text;
@@ -41,5 +42,38 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
await Task.WhenAll(node1.StopAsync(), node2.StopAsync());
}
}
+
+ [Fact]
+ public async Task RpcWorksAsync()
+ {
+ var coreNode = await CoreNode.CreateAsync();
+ try
+ {
+ var blockCount = await coreNode.RpcClient.GetBlockCountAsync();
+ Assert.Equal(0, blockCount);
+ }
+ finally
+ {
+ await coreNode.StopAsync();
+ }
+ }
+
+ [Fact]
+ public async Task P2pWorksAsync()
+ {
+ var coreNode = await CoreNode.CreateAsync();
+ using var node = await coreNode.CreateP2pNodeAsync();
+ try
+ {
+ var blocks = node.GetBlocks(new[] { Network.RegTest.GenesisHash });
+ var genesis = Assert.Single(blocks);
+ Assert.Equal(genesis.GetHash(), Network.RegTest.GenesisHash);
+ }
+ finally
+ {
+ node.Disconnect();
+ await coreNode.StopAsync();
+ }
+ }
}
}

Add P2P and RPC basic tests.