Fix NRE in CoordinatorTests
MODIFY
WalletWasabi.Tests/UnitTests/Wabisabi/Backend/CoordinatorTests.cs
WalletWasabi.Tests/UnitTests/Wabisabi/Backend/CoordinatorTests.cs
@@ -5,6 +5,10 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Moq;
+using NBitcoin;
+using NBitcoin.RPC;
+using WalletWasabi.BitcoinCore.Rpc;
using WalletWasabi.Tests.Helpers;
using WalletWasabi.WabiSabi;
using WalletWasabi.WabiSabi.Backend;
@@ -20,7 +24,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var workDir = Common.GetWorkDir();
await IoHelpers.TryDeleteDirectoryAsync(workDir);
CoordinatorParameters coordinatorParameters = new(workDir);
- using WabiSabiCoordinator coordinator = new(coordinatorParameters, new MockRpcClient());
+ using WabiSabiCoordinator coordinator = new(coordinatorParameters, NewMockRpcClient());
await coordinator.StartAsync(CancellationToken.None);
await coordinator.StopAsync(CancellationToken.None);
}
@@ -32,37 +36,46 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
await IoHelpers.TryDeleteDirectoryAsync(workDir);
CoordinatorParameters coordinatorParameters = new(workDir);
- using WabiSabiCoordinator coordinator = new(coordinatorParameters, new MockRpcClient());
+ using WabiSabiCoordinator coordinator = new(coordinatorParameters, NewMockRpcClient());
using CancellationTokenSource cts = new();
cts.Cancel();
await coordinator.StartAsync(cts.Token);
await coordinator.StopAsync(CancellationToken.None);
- using WabiSabiCoordinator coordinator2 = new(coordinatorParameters, new MockRpcClient());
+ using WabiSabiCoordinator coordinator2 = new(coordinatorParameters, NewMockRpcClient());
using CancellationTokenSource cts2 = new();
await coordinator2.StartAsync(cts2.Token);
cts2.Cancel();
await coordinator2.StopAsync(CancellationToken.None);
- using WabiSabiCoordinator coordinator3 = new(coordinatorParameters, new MockRpcClient());
+ using WabiSabiCoordinator coordinator3 = new(coordinatorParameters, NewMockRpcClient());
using CancellationTokenSource cts3 = new();
var t = coordinator3.StartAsync(cts3.Token);
cts3.Cancel();
await t;
await coordinator3.StopAsync(CancellationToken.None);
- using WabiSabiCoordinator coordinator4 = new(coordinatorParameters, new MockRpcClient());
+ using WabiSabiCoordinator coordinator4 = new(coordinatorParameters, NewMockRpcClient());
await coordinator4.StartAsync(CancellationToken.None);
using CancellationTokenSource cts4 = new();
cts4.Cancel();
await coordinator4.StopAsync(cts4.Token);
- using WabiSabiCoordinator coordinator5 = new(coordinatorParameters, new MockRpcClient());
+ using WabiSabiCoordinator coordinator5 = new(coordinatorParameters, NewMockRpcClient());
await coordinator5.StartAsync(CancellationToken.None);
using CancellationTokenSource cts5 = new();
t = coordinator5.StopAsync(cts5.Token);
cts5.Cancel();
await t;
}
+
+ private static IRPCClient NewMockRpcClient()
+ {
+ var mockRpcClient = new Mock<IRPCClient>();
+ mockRpcClient.Setup(c => c.Network).Returns(Network.Main);
+ mockRpcClient.Setup(c => c.EstimateSmartFeeAsync(It.IsAny<int>(), It.IsAny<EstimateSmartFeeMode>()))
+ .ReturnsAsync(new EstimateSmartFeeResponse { Blocks = 5, FeeRate = new FeeRate(100m) });
+ return mockRpcClient.Object;
+ }
}
}

Fix NRE in CoordinatorTests