Add ireg move tests for blames
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RoundCreationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RoundCreationTests.cs
@@ -81,6 +81,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var round = Assert.Single(arena.Rounds).Value;
round.SetPhase(Phase.ConnectionConfirmation);
+ round.Alices.Add(WabiSabiFactory.CreateAlice());
Round blameRound = WabiSabiFactory.CreateBlameRound(round, cfg);
Assert.Equal(Phase.InputRegistration, blameRound.Phase);
arena.Rounds.Add(blameRound.Id, blameRound);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/StepInputRegistrationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/StepInputRegistrationTests.cs
@@ -38,6 +38,40 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
await arena.StopAsync(CancellationToken.None);
}
+ [Fact]
+ public async Task BlameRoundFullAsync()
+ {
+ WabiSabiConfig cfg = new()
+ {
+ MaxInputCountByRound = 4,
+ MinInputCountByRoundMultiplier = 0.5
+ };
+ var round = WabiSabiFactory.CreateRound(cfg);
+ var alice1 = WabiSabiFactory.CreateAlice();
+ var alice2 = WabiSabiFactory.CreateAlice();
+ var alice3 = WabiSabiFactory.CreateAlice();
+ round.Alices.Add(alice1);
+ round.Alices.Add(alice2);
+ round.Alices.Add(alice3);
+ var blameRound = WabiSabiFactory.CreateBlameRound(round, cfg);
+
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, blameRound);
+
+ blameRound.Alices.Add(alice1);
+ await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
+ Assert.Equal(Phase.InputRegistration, blameRound.Phase);
+
+ blameRound.Alices.Add(alice2);
+ await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
+ Assert.Equal(Phase.InputRegistration, blameRound.Phase);
+
+ blameRound.Alices.Add(alice3);
+ await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
+ Assert.Equal(Phase.ConnectionConfirmation, blameRound.Phase);
+
+ await arena.StopAsync(CancellationToken.None);
+ }
+
[Fact]
public async Task RoundFullAliceMultiInputAsync()
{
@@ -76,6 +110,34 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
await arena.StopAsync(CancellationToken.None);
}
+ [Fact]
+ public async Task BlameRoundTimedoutWithSufficientInputsAsync()
+ {
+ WabiSabiConfig cfg = new()
+ {
+ BlameInputRegistrationTimeout = TimeSpan.Zero,
+ InputRegistrationTimeout = TimeSpan.FromHours(1), // Test that this is disregarded.
+ MaxInputCountByRound = 4,
+ MinInputCountByRoundMultiplier = 0.5
+ };
+ var round = WabiSabiFactory.CreateRound(cfg);
+ var alice1 = WabiSabiFactory.CreateAlice();
+ var alice2 = WabiSabiFactory.CreateAlice();
+ var alice3 = WabiSabiFactory.CreateAlice();
+ round.Alices.Add(alice1);
+ round.Alices.Add(alice2);
+ round.Alices.Add(alice3);
+ var blameRound = WabiSabiFactory.CreateBlameRound(round, cfg);
+ blameRound.Alices.Add(alice1);
+ blameRound.Alices.Add(alice2);
+
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, blameRound);
+ await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
+ Assert.Equal(Phase.ConnectionConfirmation, blameRound.Phase);
+
+ await arena.StopAsync(CancellationToken.None);
+ }
+
[Fact]
public async Task InputRegistrationTimedoutWithoutSufficientInputsAsync()
{
@@ -95,5 +157,34 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
await arena.StopAsync(CancellationToken.None);
}
+
+ [Fact]
+ public async Task BlameRoundTimedoutWithoutSufficientInputsAsync()
+ {
+ // This test also tests that the min input count multiplier is applied
+ // against the max input count by round number and not against the
+ // number of inputs awaited by the blame round intself.
+ WabiSabiConfig cfg = new()
+ {
+ BlameInputRegistrationTimeout = TimeSpan.Zero,
+ InputRegistrationTimeout = TimeSpan.FromHours(1), // Test that this is disregarded.
+ MaxInputCountByRound = 4,
+ MinInputCountByRoundMultiplier = 0.5
+ };
+ var round = WabiSabiFactory.CreateRound(cfg);
+ var alice1 = WabiSabiFactory.CreateAlice();
+ var alice2 = WabiSabiFactory.CreateAlice();
+ round.Alices.Add(alice1);
+ round.Alices.Add(alice2);
+ var blameRound = WabiSabiFactory.CreateBlameRound(round, cfg);
+ blameRound.Alices.Add(alice1);
+
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, blameRound);
+ await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
+ Assert.Equal(Phase.InputRegistration, blameRound.Phase);
+ Assert.DoesNotContain(blameRound.Id, arena.Rounds.Keys);
+
+ await arena.StopAsync(CancellationToken.None);
+ }
}
}

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
@@ -98,7 +98,14 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
return true;
}
- if (InputCount >= maxInputCount)
+ if (IsBlameRound)
+ {
+ if (BlameWhitelist.Count <= InputCount)
+ {
+ return true;
+ }
+ }
+ else if (InputCount >= maxInputCount)
{
return true;
}

Add ireg move tests for blames