Inject CredentialPool into ArenaClient
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
@@ -15,6 +15,7 @@ using WalletWasabi.WabiSabi.Backend.Banning;
using WalletWasabi.WabiSabi.Backend.PostRequests;
using WalletWasabi.WabiSabi.Backend.Rounds;
using WalletWasabi.WabiSabi.Client;
+using WalletWasabi.WabiSabi.Crypto;
using Xunit;
namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
@@ -44,7 +45,10 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
});
await using var coordinator = new ArenaRequestHandler(config, new Prison(), arena, mockRpc.Object);
- var apiClient = new ArenaClient(round.AmountCredentialIssuerParameters, round.WeightCredentialIssuerParameters, coordinator, new InsecureRandom());
+
+ CredentialPool amountCredentialPool = new();
+ CredentialPool weightCredentialPool = new();
+ var apiClient = new ArenaClient(amountCredentialPool, weightCredentialPool, round.AmountCredentialIssuerParameters, round.WeightCredentialIssuerParameters, coordinator, new InsecureRandom());
Assert.Equal(Phase.InputRegistration, arena.Rounds.First().Value.Phase);
var bitcoinSecret = km.GetSecrets("", coin1.ScriptPubKey).Single().PrivateKey.GetBitcoinSecret(Network.Main);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
@@ -42,14 +42,14 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
});
await using var coordinator = new ArenaRequestHandler(config, new Prison(), arena, mockRpc.Object);
- var apiClient = new ArenaClient(round.AmountCredentialIssuerParameters, round.WeightCredentialIssuerParameters, coordinator, new InsecureRandom());
- var amountCredentials = apiClient.AmountCredentialClient.Credentials;
- var weightCredentials = apiClient.WeightCredentialClient.Credentials;
+ CredentialPool amountCredentialPool = new();
+ CredentialPool weightCredentialPool = new();
+ var aliceArenaClient = new ArenaClient(amountCredentialPool, weightCredentialPool, round.AmountCredentialIssuerParameters, round.WeightCredentialIssuerParameters, coordinator, new InsecureRandom());
- var aliceId = await apiClient.RegisterInputAsync(Money.Coins(1m), outpoint, key, round.Id, round.Hash);
+ var aliceId = await aliceArenaClient.RegisterInputAsync(Money.Coins(1m), outpoint, key, round.Id, round.Hash);
Assert.NotEqual(Guid.Empty, aliceId);
- Assert.Empty(amountCredentials.Valuable);
+ Assert.Empty(aliceArenaClient.AmountCredentialClient.Credentials.Valuable);
var reissuanceAmounts = new[]
{
@@ -63,49 +63,50 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
// Phase: Input Registration
Assert.Equal(Phase.InputRegistration, round.Phase);
- await apiClient.ConfirmConnectionAsync(
+ await aliceArenaClient.ConfirmConnectionAsync(
round.Id,
aliceId,
inputRemainingWeights,
- amountCredentials.ZeroValue.Take(ArenaClient.ProtocolCredentialNumber),
+ aliceArenaClient.AmountCredentialClient.Credentials.ZeroValue.Take(ArenaClient.ProtocolCredentialNumber),
reissuanceAmounts);
- Assert.Empty(amountCredentials.Valuable);
+ Assert.Empty(aliceArenaClient.AmountCredentialClient.Credentials.Valuable);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(1));
Assert.Equal(Phase.ConnectionConfirmation, round.Phase);
// Phase: Connection Confirmation
- await apiClient.ConfirmConnectionAsync(
+ await aliceArenaClient.ConfirmConnectionAsync(
round.Id,
aliceId,
inputRemainingWeights,
- amountCredentials.ZeroValue.Take(ArenaClient.ProtocolCredentialNumber),
+ aliceArenaClient.AmountCredentialClient.Credentials.ZeroValue.Take(ArenaClient.ProtocolCredentialNumber),
reissuanceAmounts);
- Assert.Single(apiClient.AmountCredentialClient.Credentials.Valuable, x => x.Amount.ToMoney() == reissuanceAmounts.First());
- Assert.Single(apiClient.AmountCredentialClient.Credentials.Valuable, x => x.Amount.ToMoney() == reissuanceAmounts.Last());
+ Assert.Single(aliceArenaClient.AmountCredentialClient.Credentials.Valuable, x => x.Amount.ToMoney() == reissuanceAmounts.First());
+ Assert.Single(aliceArenaClient.AmountCredentialClient.Credentials.Valuable, x => x.Amount.ToMoney() == reissuanceAmounts.Last());
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(1));
Assert.Equal(Phase.OutputRegistration, round.Phase);
+ var bobArenaClient = new ArenaClient(amountCredentialPool, weightCredentialPool, round.AmountCredentialIssuerParameters, round.WeightCredentialIssuerParameters, coordinator, new InsecureRandom());
// Phase: Output Registration
using var destinationKey1 = new Key();
using var destinationKey2 = new Key();
- await apiClient.RegisterOutputAsync(
+ await bobArenaClient.RegisterOutputAsync(
round.Id,
reissuanceAmounts[0],
destinationKey1.PubKey.WitHash.ScriptPubKey,
- apiClient.AmountCredentialClient.Credentials.Valuable,
- apiClient.WeightCredentialClient.Credentials.Valuable);
+ bobArenaClient.AmountCredentialClient.Credentials.Valuable,
+ bobArenaClient.WeightCredentialClient.Credentials.Valuable);
- await apiClient.RegisterOutputAsync(
+ await bobArenaClient.RegisterOutputAsync(
round.Id,
reissuanceAmounts[1],
destinationKey2.PubKey.WitHash.ScriptPubKey,
- apiClient.AmountCredentialClient.Credentials.Valuable,
- apiClient.WeightCredentialClient.Credentials.Valuable);
+ bobArenaClient.AmountCredentialClient.Credentials.Valuable,
+ bobArenaClient.WeightCredentialClient.Credentials.Valuable);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
Assert.Equal(Phase.TransactionSigning, round.Phase);

MODIFY
WalletWasabi/WabiSabi/Client/ArenaClient.cs
WalletWasabi/WabiSabi/Client/ArenaClient.cs
@@ -21,16 +21,15 @@ namespace WalletWasabi.WabiSabi.Client
public static readonly ulong ProtocolMaxWeightPerAlice = 1_000ul;
public ArenaClient(
+ CredentialPool amountCredentialPool,
+ CredentialPool weightCredentialPool,
CredentialIssuerParameters amountCredentialIssuerParameters,
CredentialIssuerParameters weightCredentialIssuerParameters,
IArenaRequestHandler requestHandler,
WasabiRandom random)
{
- var amountCredentials = new CredentialPool();
- var weightCredentials = new CredentialPool();
-
- AmountCredentialClient = new WabiSabiClient(amountCredentialIssuerParameters, ProtocolCredentialNumber, random, ProtocolMaxAmountPerAlice, amountCredentials);
- WeightCredentialClient = new WabiSabiClient(weightCredentialIssuerParameters, ProtocolCredentialNumber, random, ProtocolMaxWeightPerAlice, weightCredentials);
+ AmountCredentialClient = new WabiSabiClient(amountCredentialIssuerParameters, ProtocolCredentialNumber, random, ProtocolMaxAmountPerAlice, amountCredentialPool);
+ WeightCredentialClient = new WabiSabiClient(weightCredentialIssuerParameters, ProtocolCredentialNumber, random, ProtocolMaxWeightPerAlice, weightCredentialPool);
RequestHandler = requestHandler;
}

Inject CredentialPool into ArenaClient