Have min input count parameter
MODIFY
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
@@ -67,7 +67,7 @@ namespace WalletWasabi.Tests.Helpers
new InsecureRandom(),
new(100m)));
- public static async Task<Arena> CreateAndStartArenaAsync(params Round[] rounds)
+ public static async Task<Arena> CreateAndStartArenaAsync(WabiSabiConfig? cfg = null, params Round[] rounds)
{
var mockRpc = new MockRpcClient();
mockRpc.OnEstimateSmartFeeAsync = async (target, _) =>
@@ -76,7 +76,7 @@ namespace WalletWasabi.Tests.Helpers
Blocks = target,
FeeRate = new FeeRate(10m)
});
- Arena arena = new(TimeSpan.FromSeconds(1), rounds.FirstOrDefault()?.Network ?? Network.Main, new WabiSabiConfig(), mockRpc);
+ Arena arena = new(TimeSpan.FromSeconds(1), rounds.FirstOrDefault()?.Network ?? Network.Main, cfg ?? new WabiSabiConfig(), mockRpc);
foreach (var round in rounds)
{
arena.Rounds.Add(round.Id, round);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/AliceTimeoutTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/AliceTimeoutTests.cs
@@ -22,7 +22,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
// Alice times out when its deadline is reached.
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -48,7 +48,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
}
[Fact]
- public async Task AliceDoesntTimesoutInConnectionConfirmationAsync()
+ public async Task AliceDoesntTimeoutInConnectionConfirmationAsync()
{
// Alice does not time out when it's not input registration anymore,
// even though the deadline is reached.
@@ -57,7 +57,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
round.Phase = Phase.ConnectionConfirmation;
var alice = WabiSabiFactory.CreateAlice();
round.Alices.Add(alice);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
@@ -72,6 +72,56 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
await arena.StopAsync(CancellationToken.None);
}
+ [Fact]
+ public async Task AliceDoesntTimeoutIfInputRegistrationTimedoutAsync()
+ {
+ // Alice does not time out if input registration timed out,
+ // even though the deadline is reached and still in input reg.
+ WabiSabiConfig cfg = new() { InputRegistrationTimeout = TimeSpan.Zero };
+ var round = WabiSabiFactory.CreateRound(cfg);
+ var alice = WabiSabiFactory.CreateAlice();
+ round.Alices.Add(alice);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
+
+ var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);
+ await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
+
+ Assert.Single(round.Alices);
+ DateTimeOffset preDeadline = DateTimeOffset.UtcNow - TimeSpan.FromMilliseconds(1);
+ alice.Deadline = preDeadline;
+ await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
+ Assert.Single(round.Alices);
+ Assert.Equal(preDeadline, alice.Deadline);
+
+ await arena.StopAsync(CancellationToken.None);
+ }
+
+ [Fact]
+ public async Task AliceDoesntTimeoutIfMaxInputCountReachedAsync()
+ {
+ // Alice does not time out if input reg is full with alices,
+ // even though the deadline is reached and still in input reg.
+ WabiSabiConfig cfg = new() { MaxInputCountByRound = 3 };
+ var round = WabiSabiFactory.CreateRound(cfg);
+ var alice = WabiSabiFactory.CreateAlice();
+ round.Alices.Add(alice);
+ round.Alices.Add(WabiSabiFactory.CreateAlice());
+ round.Alices.Add(WabiSabiFactory.CreateAlice());
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
+
+ var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);
+ await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
+
+ Assert.Equal(3, round.Alices.Count);
+ DateTimeOffset preDeadline = DateTimeOffset.UtcNow - TimeSpan.FromMilliseconds(1);
+ alice.Deadline = preDeadline;
+ await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
+ Assert.Equal(3, round.Alices.Count);
+ Assert.Equal(preDeadline, alice.Deadline);
+
+ await arena.StopAsync(CancellationToken.None);
+ }
+
[Fact]
public async Task AliceDeadlineUpdatedAsync()
{
@@ -80,7 +130,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var round = WabiSabiFactory.CreateRound(cfg);
var alice = WabiSabiFactory.CreateAlice();
round.Alices.Add(alice);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/ConfirmConnectionTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/ConfirmConnectionTests.cs
@@ -26,7 +26,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var alice = WabiSabiFactory.CreateAlice();
var preDeadline = alice.Deadline;
round.Alices.Add(alice);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);
var minAliceDeadline = DateTimeOffset.UtcNow + cfg.ConnectionConfirmationTimeout * 0.9;
@@ -52,7 +52,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var alice = WabiSabiFactory.CreateAlice();
var preDeadline = alice.Deadline;
round.Alices.Add(alice);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
@@ -87,7 +87,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var alice = WabiSabiFactory.CreateAlice();
var preDeadline = alice.Deadline;
round.Alices.Add(alice);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);
foreach (Phase phase in Enum.GetValues(typeof(Phase)))
@@ -110,7 +110,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
@@ -128,7 +128,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
round.Phase = Phase.ConnectionConfirmation;
var alice = WabiSabiFactory.CreateAlice();
round.Alices.Add(alice);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);
req = new(
@@ -153,7 +153,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
round.Phase = Phase.ConnectionConfirmation;
var alice = WabiSabiFactory.CreateAlice();
round.Alices.Add(alice);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var req = WabiSabiFactory.CreateConnectionConfirmationRequest(round);
req = new(

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RegisterInputTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RegisterInputTests.cs
@@ -33,7 +33,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -59,7 +59,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -91,7 +91,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
var anotherRound = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round, anotherRound);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round, anotherRound);
MockRpcClient rpc = new();
using Key key = new();
@@ -145,7 +145,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -176,7 +176,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var inputSigPair = WabiSabiFactory.CreateInputRoundSignaturePair();
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
@@ -192,7 +192,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new() { MaxInputCountByAlice = 3 };
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -219,7 +219,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
prison.Punish(pair.Input, Punishment.Banned, Guid.NewGuid());
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
await using PostRequestHandler handler = new(cfg, prison, arena, new MockRpcClient());
var req = WabiSabiFactory.CreateInputsRegistrationRequest(pair, round);
var ex = await Assert.ThrowsAsync<WabiSabiProtocolException>(async () => await handler.RegisterInputAsync(req));
@@ -236,7 +236,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
prison.Punish(pair.Input, Punishment.Noted, Guid.NewGuid());
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
await using PostRequestHandler handler = new(cfg, prison, arena, new MockRpcClient());
var req = WabiSabiFactory.CreateInputsRegistrationRequest(pair, round);
@@ -257,7 +257,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
prison.Punish(pair.Input, Punishment.Noted, Guid.NewGuid());
WabiSabiConfig cfg = new() { AllowNotedInputRegistration = false };
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
await using PostRequestHandler handler = new(cfg, prison, arena, new MockRpcClient());
var req = WabiSabiFactory.CreateInputsRegistrationRequest(pair, round);
@@ -274,7 +274,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var round = WabiSabiFactory.CreateRound(cfg);
round.Alices.Add(WabiSabiFactory.CreateAlice());
Round blameRound = new(round);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round, blameRound);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round, blameRound);
MockRpcClient rpc = new();
using Key key = new();
@@ -301,7 +301,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var round = WabiSabiFactory.CreateRound(cfg);
round.Alices.Add(WabiSabiFactory.CreateAlice(pair));
Round blameRound = new(round);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round, blameRound);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round, blameRound);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
var req = WabiSabiFactory.CreateInputsRegistrationRequest(pair, blameRound);
@@ -325,7 +325,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var round = WabiSabiFactory.CreateRound(cfg);
round.Alices.Add(WabiSabiFactory.CreateAlice(pair));
Round blameRound = new(round);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round, blameRound);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round, blameRound);
await using PostRequestHandler handler = new(cfg, prison, arena, new MockRpcClient());
var req = WabiSabiFactory.CreateInputsRegistrationRequest(pair, blameRound);
@@ -340,7 +340,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
rpc.OnGetTxOutAsync = (_, _, _) => null;
@@ -357,7 +357,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
rpc.OnGetTxOutAsync = (_, _, _) => new GetTxOutResponse { Confirmations = 0 };
@@ -374,7 +374,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
var req = WabiSabiFactory.CreateInputsRegistrationRequest(round);
@@ -395,7 +395,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -418,7 +418,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -442,7 +442,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new() { MinRegistrableAmount = Money.Coins(2) };
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -466,7 +466,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new() { MaxRegistrableAmount = Money.Coins(0.9m) };
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -490,7 +490,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new() { RegistrableWeightCredentials = 1 };
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -514,7 +514,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
MockRpcClient rpc = new();
using Key key = new();
@@ -546,7 +546,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
var anotherRound = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round, anotherRound);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round, anotherRound);
MockRpcClient rpc = new();
using Key key = new();

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RegisterOutputTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RegisterOutputTests.cs
@@ -25,7 +25,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var round = WabiSabiFactory.CreateRound(cfg);
round.Phase = Phase.OutputRegistration;
round.Alices.Add(WabiSabiFactory.CreateAlice());
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
var req = WabiSabiFactory.CreateOutputRegistrationRequest(round);
@@ -57,7 +57,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
round.Phase = Phase.OutputRegistration;
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
using Key key = new();
var req = WabiSabiFactory.CreateOutputRegistrationRequest(round, key.PubKey.GetAddress(ScriptPubKeyType.Legacy, Network.Main).ScriptPubKey);
@@ -75,7 +75,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var round = WabiSabiFactory.CreateRound(cfg);
round.Phase = Phase.OutputRegistration;
round.Alices.Add(WabiSabiFactory.CreateAlice(value: Money.Coins(1)));
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
var req = WabiSabiFactory.CreateOutputRegistrationRequest(round);
@@ -93,7 +93,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var round = WabiSabiFactory.CreateRound(cfg);
round.Phase = Phase.OutputRegistration;
round.Alices.Add(WabiSabiFactory.CreateAlice(value: Money.Coins(2)));
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
var req = WabiSabiFactory.CreateOutputRegistrationRequest(round);
@@ -111,7 +111,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var round = WabiSabiFactory.CreateRound(cfg);
round.Phase = Phase.OutputRegistration;
round.Alices.Add(WabiSabiFactory.CreateAlice());
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
var req = WabiSabiFactory.CreateOutputRegistrationRequest(round, weight: 30);
@@ -128,7 +128,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
round.Alices.Add(WabiSabiFactory.CreateAlice());
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
foreach (Phase phase in Enum.GetValues(typeof(Phase)))

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RemoveInputTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RemoveInputTests.cs
@@ -24,7 +24,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var round = WabiSabiFactory.CreateRound(cfg);
var alice = WabiSabiFactory.CreateAlice();
round.Alices.Add(alice);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
@@ -57,7 +57,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var req = new InputsRemovalRequest(round.Id, Guid.NewGuid());
foreach (Phase phase in Enum.GetValues(typeof(Phase)))

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/SignTransactionTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/SignTransactionTests.cs
@@ -29,7 +29,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
var coinjoin = round.Coinjoin;
coinjoin.Inputs.Add(alice.Coins.First().Outpoint);
round.Phase = Phase.TransactionSigning;
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var signedCoinJoin = coinjoin.Clone();
signedCoinJoin.Sign(key.GetBitcoinSecret(Network.Main), alice.Coins.First());
@@ -57,7 +57,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
WabiSabiConfig cfg = new();
var round = WabiSabiFactory.CreateRound(cfg);
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
var req = new TransactionSignaturesRequest(round.Id, null!);
foreach (Phase phase in Enum.GetValues(typeof(Phase)))
@@ -88,7 +88,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
coinjoin.Inputs.Add(alice1.Coins.First().Outpoint);
coinjoin.Inputs.Add(alice2.Coins.First().Outpoint);
round.Phase = Phase.TransactionSigning;
- using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(round);
+ using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
// Submit the signature for the second alice to the first alice's input.
var signedCoinJoin = coinjoin.Clone();

MODIFY
WalletWasabi/WabiSabi/Backend/PostRequests/InputRegistrationHandler.cs
WalletWasabi/WabiSabi/Backend/PostRequests/InputRegistrationHandler.cs
@@ -70,7 +70,7 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
ZeroCredentialsRequest zeroWeightCredentialRequests,
IDictionary<Guid, Round> rounds,
Network network,
- uint maxInputCount,
+ uint maxInputCountByRound,
TimeSpan inputRegistrationTimeout)
{
if (!rounds.TryGetValue(roundId, out var round))
@@ -121,7 +121,7 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.TooMuchWeight);
}
- if (round.IsInputRegistrationEnded(maxInputCount, inputRegistrationTimeout))
+ if (round.IsInputRegistrationEnded(maxInputCountByRound, inputRegistrationTimeout))
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.WrongPhase);
}

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
@@ -52,13 +52,20 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
private void StepInputRegistrationPhase()
{
- foreach (var round in Rounds.Values.Where(x =>
+ foreach (var round in Rounds.Values.ToArray().Where(x =>
x.Phase == Phase.InputRegistration
- && x.IsInputRegistrationEnded(Config.MaxInputCount, Config.InputRegistrationTimeout)))
+ && x.IsInputRegistrationEnded(Config.MaxInputCountByRound, Config.InputRegistrationTimeout)))
+ {
+ if (round.InputCount < Config.MinInputCountByRound)
+ {
+ Rounds.Remove(round.Id);
+ }
+ else
{
round.Phase = Phase.ConnectionConfirmation;
}
}
+ }
private async Task CreateRoundsAsync()
{
@@ -74,7 +81,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
private void TimeoutAlices()
{
- foreach (var round in Rounds.Values.Where(x => !x.IsInputRegistrationEnded(Config.MaxInputCount, Config.InputRegistrationTimeout)))
+ foreach (var round in Rounds.Values.Where(x => !x.IsInputRegistrationEnded(Config.MaxInputCountByRound, Config.InputRegistrationTimeout)))
{
var removedAliceCount = round.RemoveAlices(x => x.Deadline < DateTimeOffset.UtcNow);
if (removedAliceCount > 0)
@@ -99,7 +106,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
zeroWeightCredentialRequests,
Rounds,
Network,
- Config.MaxInputCount,
+ Config.MaxInputCountByRound,
Config.InputRegistrationTimeout);
}
}

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
@@ -63,6 +63,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
public Guid Id { get; } = Guid.NewGuid();
public Phase Phase { get; set; } = Phase.InputRegistration;
public List<Alice> Alices { get; } = new();
+ public int InputCount => Alices.Sum(x => x.Coins.Count());
public List<Bob> Bobs { get; } = new();
public Round? BlameOf { get; } = null;
public bool IsBlameRound => BlameOf is not null;
@@ -88,7 +89,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
return true;
}
- if (Alices.Sum(x => x.Coins.Count()) >= maxInputCount)
+ if (InputCount >= maxInputCount)
{
return true;
}

MODIFY
WalletWasabi/WabiSabi/Backend/WabiSabiConfig.cs
WalletWasabi/WabiSabi/Backend/WabiSabiConfig.cs
@@ -70,10 +70,6 @@ namespace WalletWasabi.WabiSabi.Backend
[JsonConverter(typeof(TimeSpanJsonConverter))]
public TimeSpan InputRegistrationTimeout { get; set; } = TimeSpan.FromHours(1);
- [DefaultValue(100)]
- [JsonProperty(PropertyName = "MaxInputCount", DefaultValueHandling = DefaultValueHandling.Populate)]
- public uint MaxInputCount { get; set; } = 100;
-
[DefaultValueTimeSpan("0d 0h 1m 0s")]
[JsonProperty(PropertyName = "ConnectionConfirmationTimeout", DefaultValueHandling = DefaultValueHandling.Populate)]
[JsonConverter(typeof(TimeSpanJsonConverter))]
@@ -88,5 +84,15 @@ namespace WalletWasabi.WabiSabi.Backend
[JsonProperty(PropertyName = "TransactionSigningTimeout", DefaultValueHandling = DefaultValueHandling.Populate)]
[JsonConverter(typeof(TimeSpanJsonConverter))]
public TimeSpan TransactionSigningTimeout { get; set; } = TimeSpan.FromMinutes(1);
+
+ [DefaultValue(100)]
+ [JsonProperty(PropertyName = "MaxInputCountByRound", DefaultValueHandling = DefaultValueHandling.Populate)]
+ public uint MaxInputCountByRound { get; set; } = 100;
+
+ [DefaultValue(0.5)]
+ [JsonProperty(PropertyName = "MinInputCountByRoundMultiplier", DefaultValueHandling = DefaultValueHandling.Populate)]
+ public double MinInputCountByRoundMultiplier { get; set; } = 0.5;
+
+ public uint MinInputCountByRound => (uint)(MaxInputCountByRound * MinInputCountByRoundMultiplier);
}
}

Have min input count parameter