Rename CoordinatorClient to ArenaClient
RENAME
WalletWasabi.Tests/UnitTests/WabiSabi/Client/CoordinatorClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
@@ -16,7 +16,7 @@ using Xunit;
namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
{
- public class CoordinatorClientTests
+ public class ArenaClientTests
{
[Fact]
public async Task RegisterInputAsyncTest()
@@ -38,30 +38,41 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
await using var coordinator = new PostRequestHandler(config, new Prison(), arena, mockRpc.Object);
var rnd = new InsecureRandom();
- var amountClient = new WabiSabiClient(round.AmountCredentialIssuerParameters, 2, rnd, 4_300_000_000_000ul); // TODO: remove hardcoded max value
- var weightClient = new WabiSabiClient(round.WeightCredentialIssuerParameters, 2, rnd, 1_000ul); // TODO: remove hardcoded max value
+ var protocolCredentialNumber = 2;
+ var amountClient = new WabiSabiClient(round.AmountCredentialIssuerParameters, protocolCredentialNumber, rnd, 4_300_000_000_000ul); // TODO: remove hardcoded max value
+ var weightClient = new WabiSabiClient(round.WeightCredentialIssuerParameters, protocolCredentialNumber, rnd, 1_000ul); // TODO: remove hardcoded max value
- var apiClient = new CoordinatorClient(amountClient, weightClient, coordinator);
+ var apiClient = new ArenaClient(amountClient, weightClient, coordinator);
var aliceId = await apiClient.RegisterInputAsync(Money.Coins(1m), outpoint, key, round.Id, round.Hash);
Assert.NotEqual(Guid.Empty, aliceId);
- Assert.Empty(apiClient.WabiSabiClientAmount.Credentials.Valuable);
+ Assert.Empty(apiClient.AmountCredentialClient.Credentials.Valuable);
var reissuanceAmounts = new[] {
Money.Coins(.75m) - round.FeeRate.GetFee(/*Constants.P2wpkhInputVirtualSize*/ 68),
Money.Coins(.25m)
};
+ // Phase: Input Registration
+ await apiClient.ConfirmConnectionAsync(
+ round.Id,
+ aliceId,
+ apiClient.AmountCredentialClient.Credentials.ZeroValue.Take(protocolCredentialNumber),
+ reissuanceAmounts);
+
+ Assert.Empty(apiClient.AmountCredentialClient.Credentials.Valuable);
+
+ // Phase: Connection Confirmation
round.SetPhase(Phase.ConnectionConfirmation);
await apiClient.ConfirmConnectionAsync(
round.Id,
aliceId,
- apiClient.WabiSabiClientAmount.Credentials.ZeroValue,
+ apiClient.AmountCredentialClient.Credentials.ZeroValue.Take(protocolCredentialNumber),
reissuanceAmounts);
- Assert.Single(apiClient.WabiSabiClientAmount.Credentials.Valuable, x => x.Amount.ToMoney() == reissuanceAmounts.First());
- Assert.Single(apiClient.WabiSabiClientAmount.Credentials.Valuable, x => x.Amount.ToMoney() == reissuanceAmounts.Last());
+ Assert.Single(apiClient.AmountCredentialClient.Credentials.Valuable, x => x.Amount.ToMoney() == reissuanceAmounts.First());
+ Assert.Single(apiClient.AmountCredentialClient.Credentials.Valuable, x => x.Amount.ToMoney() == reissuanceAmounts.Last());
}
}
}

RENAME
WalletWasabi/WabiSabi/Client/CoordinatorClient.cs
WalletWasabi/WabiSabi/Client/ArenaClient.cs
@@ -12,17 +12,17 @@ using WalletWasabi.WabiSabi.Models;
namespace WalletWasabi.WabiSabi.Client
{
- public class CoordinatorClient
+ public class ArenaClient
{
- public CoordinatorClient(WabiSabiClient wabiSabiClientAmount, WabiSabiClient wabiSabiClientWeight, IRequestHandler requestHandler)
+ public ArenaClient(WabiSabiClient amountCredentialClient, WabiSabiClient weightCredentialClient, IRequestHandler requestHandler)
{
- WabiSabiClientAmount = wabiSabiClientAmount;
- WabiSabiClientWeight = wabiSabiClientWeight;
+ AmountCredentialClient = amountCredentialClient;
+ WeightCredentialClient = weightCredentialClient;
RequestHandler = requestHandler;
}
- public WabiSabiClient WabiSabiClientAmount { get; }
- public WabiSabiClient WabiSabiClientWeight { get; }
+ public WabiSabiClient AmountCredentialClient { get; }
+ public WabiSabiClient WeightCredentialClient { get; }
public IRequestHandler RequestHandler { get; }
public ValueTask<Guid> RegisterInputAsync(Money amount, OutPoint outPoint, Key key, Guid roundId, uint256 roundHash) =>
@@ -48,36 +48,36 @@ namespace WalletWasabi.WabiSabi.Client
.Zip(keys, (outPoint, key) => (outPoint, key))
.Select(x => new InputRoundSignaturePair(x.outPoint, GenerateOwnershipProof(x.key, roundHash)));
- var (zeroAmountCredentialRequest, zeroAmountCredentialResponseValidation) = WabiSabiClientAmount.CreateRequestForZeroAmount();
- var (zeroWeightCredentialRequest, zeroWeightCredentialResponseValidation) = WabiSabiClientWeight.CreateRequestForZeroAmount();
+ var (zeroAmountCredentialRequest, zeroAmountCredentialResponseValidation) = AmountCredentialClient.CreateRequestForZeroAmount();
+ var (zeroWeightCredentialRequest, zeroWeightCredentialResponseValidation) = WeightCredentialClient.CreateRequestForZeroAmount();
var inputRegistrationResponse = await RequestHandler.RegisterInputAsync(
new InputsRegistrationRequest(
roundId,
registrableInputs,
zeroAmountCredentialRequest,
- zeroWeightCredentialRequest));
+ zeroWeightCredentialRequest)).ConfigureAwait(false);
- WabiSabiClientAmount.HandleResponse(inputRegistrationResponse.AmountCredentials, zeroAmountCredentialResponseValidation);
- WabiSabiClientWeight.HandleResponse(inputRegistrationResponse.WeightCredentials, zeroWeightCredentialResponseValidation);
+ AmountCredentialClient.HandleResponse(inputRegistrationResponse.AmountCredentials, zeroAmountCredentialResponseValidation);
+ WeightCredentialClient.HandleResponse(inputRegistrationResponse.WeightCredentials, zeroWeightCredentialResponseValidation);
return inputRegistrationResponse.AliceId;
}
public async Task ConfirmConnectionAsync(Guid roundId, Guid aliceId, IEnumerable<Credential> credentialsToPresent, IEnumerable<Money> newAmount)
{
- var (realAmountCredentialRequest, realAmountCredentialResponseValidation) = WabiSabiClientAmount.CreateRequest(
+ var (realAmountCredentialRequest, realAmountCredentialResponseValidation) = AmountCredentialClient.CreateRequest(
newAmount.Select(x => x.Satoshi),
credentialsToPresent);
var inputsCount = 1; // ?
- var (realWeightCredentialRequest, realWeightCredentialResponseValidation) = WabiSabiClientWeight.CreateRequest(
+ var (realWeightCredentialRequest, realWeightCredentialResponseValidation) = WeightCredentialClient.CreateRequest(
new[] { 1_000L - (inputsCount) * 4 * Constants.P2wpkhInputVirtualSize },
- WabiSabiClientWeight.Credentials.ZeroValue.Take(2)
+ WeightCredentialClient.Credentials.ZeroValue.Take(2)
);
- var (zeroAmountCredentialRequest, zeroAmountCredentialResponseValidation) = WabiSabiClientAmount.CreateRequestForZeroAmount();
- var (zeroWeightCredentialRequest, zeroWeightCredentialResponseValidation) = WabiSabiClientWeight.CreateRequestForZeroAmount();
+ var (zeroAmountCredentialRequest, zeroAmountCredentialResponseValidation) = AmountCredentialClient.CreateRequestForZeroAmount();
+ var (zeroWeightCredentialRequest, zeroWeightCredentialResponseValidation) = WeightCredentialClient.CreateRequestForZeroAmount();
var confirmConnectionResponse = await RequestHandler.ConfirmConnectionAsync(
new ConnectionConfirmationRequest(
@@ -86,15 +86,15 @@ namespace WalletWasabi.WabiSabi.Client
zeroAmountCredentialRequest,
realAmountCredentialRequest,
zeroWeightCredentialRequest,
- realWeightCredentialRequest));
+ realWeightCredentialRequest)).ConfigureAwait(false);
if (confirmConnectionResponse is { RealAmountCredentials: {}, RealWeightCredentials: {} })
{
- WabiSabiClientAmount.HandleResponse(confirmConnectionResponse.RealAmountCredentials, realAmountCredentialResponseValidation);
- WabiSabiClientWeight.HandleResponse(confirmConnectionResponse.RealWeightCredentials, realWeightCredentialResponseValidation);
+ AmountCredentialClient.HandleResponse(confirmConnectionResponse.RealAmountCredentials, realAmountCredentialResponseValidation);
+ WeightCredentialClient.HandleResponse(confirmConnectionResponse.RealWeightCredentials, realWeightCredentialResponseValidation);
}
- WabiSabiClientAmount.HandleResponse(confirmConnectionResponse.ZeroAmountCredentials, zeroAmountCredentialResponseValidation);
- WabiSabiClientWeight.HandleResponse(confirmConnectionResponse.ZeroWeightCredentials, zeroWeightCredentialResponseValidation);
+ AmountCredentialClient.HandleResponse(confirmConnectionResponse.ZeroAmountCredentials, zeroAmountCredentialResponseValidation);
+ WeightCredentialClient.HandleResponse(confirmConnectionResponse.ZeroWeightCredentials, zeroWeightCredentialResponseValidation);
}
}
}

Rename CoordinatorClient to ArenaClient