Scream if round not found
ADD
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/InputRegistrationTests.cs
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WalletWasabi.WabiSabi.Backend;
+using WalletWasabi.WabiSabi.Backend.Banning;
+using WalletWasabi.WabiSabi.Backend.PostRequests;
+using WalletWasabi.WabiSabi.Models;
+using Xunit;
+
+namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
+{
+ public class InputRegistrationTests
+ {
+ [Fact]
+ public async Task RoundNotFoundAsync()
+ {
+ var rc = new MockRoundCollection();
+ rc.OnTryGetRound = (roundId) => null;
+
+ await using PostRequestHandler handler = new(new WabiSabiConfig(), new Prison(), rc);
+ var req = new InputsRegistrationRequest(
+ Guid.NewGuid(),
+ null!,
+ null!,
+ null!);
+ Assert.Throws<InvalidOperationException>(() => handler.RegisterInput(req));
+ }
+ }
+}

ADD
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/MockRoundCollection.cs
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WalletWasabi.WabiSabi.Backend.Rounds;
+
+namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
+{
+ public class MockRoundCollection : IRoundCollection
+ {
+ public Func<Guid, Round?> OnTryGetRound { get; set; } = (roundId) => null;
+
+ public bool TryGetRound(Guid roundId, [NotNullWhen(true)] out Round? round)
+ {
+ round = OnTryGetRound(roundId);
+ return round is not null;
+ }
+ }
+}

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RequestHandlerDisposeTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RequestHandlerDisposeTests.cs
@@ -16,7 +16,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
[Fact]
public async Task DisposeGuardAsync()
{
- PostRequestHandler handler = new(new WabiSabiConfig(), new Prison());
+ PostRequestHandler handler = new(new WabiSabiConfig(), new Prison(), new MockRoundCollection());
await handler.DisposeAsync();
Assert.Throws<ObjectDisposedException>(() => handler.RegisterInput(null!));
}

MODIFY
WalletWasabi/WabiSabi/Backend/PostRequests/PostRequestHandler.cs
WalletWasabi/WabiSabi/Backend/PostRequests/PostRequestHandler.cs
@@ -6,16 +6,18 @@ using System.Text;
using System.Threading.Tasks;
using WalletWasabi.Nito.AsyncEx;
using WalletWasabi.WabiSabi.Backend.Banning;
+using WalletWasabi.WabiSabi.Backend.Rounds;
using WalletWasabi.WabiSabi.Models;
namespace WalletWasabi.WabiSabi.Backend.PostRequests
{
public class PostRequestHandler : IAsyncDisposable
{
- public PostRequestHandler(WabiSabiConfig config, Prison prison)
+ public PostRequestHandler(WabiSabiConfig config, Prison prison, IRoundCollection roundCollection)
{
Config = config;
Prison = prison;
+ RoundCollection = roundCollection;
}
private bool DisposeStarted { get; set; } = false;
@@ -23,12 +25,18 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
private AbandonedTasks RunningRequests { get; } = new();
public WabiSabiConfig Config { get; }
public Prison Prison { get; }
+ public IRoundCollection RoundCollection { get; }
public InputsRegistrationResponse RegisterInput(InputsRegistrationRequest request)
{
DisposeGuard();
using (RunningTasks.RememberWith(RunningRequests))
{
+ if (!RoundCollection.TryGetRound(request.RoundId, out Round round))
+ {
+ throw new InvalidOperationException("Round not found.");
+ }
+
throw new NotImplementedException();
}
}

ADD
WalletWasabi/WabiSabi/Backend/Rounds/IRoundCollection.cs
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WalletWasabi.WabiSabi.Backend.Rounds
+{
+ public interface IRoundCollection
+ {
+ public bool TryGetRound(Guid roundId, [NotNullWhen(true)] out Round? round);
+ }
+}

ADD
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WalletWasabi.WabiSabi.Backend.Rounds
+{
+ public class Round
+ {
+ }
+}

ADD
WalletWasabi/WabiSabi/Backend/Rounds/RoundCollection.cs
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WalletWasabi.WabiSabi.Backend.Rounds
+{
+ public class RoundCollection : IRoundCollection
+ {
+ public bool TryGetRound(Guid roundId, [NotNullWhen(true)] out Round? round)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}

MODIFY
WalletWasabi/WabiSabi/WabiSabiCoordinator.cs
WalletWasabi/WabiSabi/WabiSabiCoordinator.cs
@@ -11,6 +11,7 @@ using WalletWasabi.Services;
using WalletWasabi.WabiSabi.Backend;
using WalletWasabi.WabiSabi.Backend.Banning;
using WalletWasabi.WabiSabi.Backend.PostRequests;
+using WalletWasabi.WabiSabi.Backend.Rounds;
namespace WalletWasabi.WabiSabi
{
@@ -23,7 +24,8 @@ namespace WalletWasabi.WabiSabi
Warden = new(parameters.UtxoWardenPeriod, parameters.PrisonFilePath, Config);
ConfigWatcher = new(parameters.ConfigChangeMonitoringPeriod, Config, () => Logger.LogInfo("WabiSabi configuration has changed."));
- Postman = new(Config, Prison);
+ Rounds = new();
+ Postman = new(Config, Prison, Rounds);
}
public ConfigWatcher ConfigWatcher { get; }
@@ -31,6 +33,7 @@ namespace WalletWasabi.WabiSabi
public CoordinatorParameters Parameters { get; }
public PostRequestHandler Postman { get; }
+ public RoundCollection Rounds { get; }
public string WorkDir => Parameters.CoordinatorDataDir;
public Prison Prison => Warden.Prison;

Scream if round not found