Skip to content

Commit

Permalink
Silince test in rare case (WalletWasabi#13390)
Browse files Browse the repository at this point in the history
* silent test

* --- Force run CI (empty commit)
  • Loading branch information
lontivero authored Sep 14, 2024
1 parent 3298a45 commit 8bb541f
Showing 1 changed file with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ public async Task SoloCoinJoinTestAsync(long[] amounts)
[Fact]
public async Task FailToRegisterOutputsCoinJoinTestAsync()
{
long[] amounts = new long[] { 10_000_000, 20_000_000, 30_000_000 };
long[] amounts = [10_000_000, 20_000_000, 30_000_000];
int inputCount = amounts.Length;

// At the end of the test a coinjoin transaction has to be created and broadcasted.
var transactionCompleted = new TaskCompletionSource<Transaction>();

// Create a key manager and use it to create fake coins.
_output.WriteLine("Creating key manager...");
KeyManager keyManager = KeyManager.CreateNew(out var _, password: "", Network.Main);
KeyManager keyManager = KeyManager.CreateNew(out _, password: "", Network.Main);

var coins = GenerateSmartCoins(keyManager, amounts, inputCount);

Expand All @@ -208,12 +208,12 @@ public async Task FailToRegisterOutputsCoinJoinTestAsync()

var httpClient = _apiApplicationFactory.WithWebHostBuilder(builder =>
builder
.AddMockRpcClient(coins, rpc => { })
.AddMockRpcClient(coins, _ => { })
.ConfigureServices(services =>
{
// Instruct the coordinator DI container to use this scoped
// services to build everything (WabiSabi controller, arena, etc)
services.AddSingleton(s => new WabiSabiConfig
services.AddSingleton(_ => new WabiSabiConfig
{
MaxInputCountByRound = inputCount,
StandardInputRegistrationTimeout = TimeSpan.FromSeconds(20),
Expand All @@ -225,7 +225,7 @@ public async Task FailToRegisterOutputsCoinJoinTestAsync()

// Emulate that all our outputs had been already used in the past.
// the server will prevent the registration and fail with a WabiSabiProtocolError.
services.AddSingleton(s => new CoinJoinScriptStore(outputScriptCandidates));
services.AddSingleton(_ => new CoinJoinScriptStore(outputScriptCandidates));
})).CreateClient();

// Create the coinjoin client
Expand Down Expand Up @@ -255,13 +255,20 @@ public async Task FailToRegisterOutputsCoinJoinTestAsync()
var finishedTask = await Task.WhenAny(coinjoinResultTask, blameRoundWaiterTask);
if (finishedTask == coinjoinResultTask)
{
var coinjoinResult = await coinjoinResultTask;
if (coinjoinResult is SuccessfulCoinJoinResult successfulCoinJoinResult)
try
{
var coinjoinResult = await coinjoinResultTask;
if (coinjoinResult is SuccessfulCoinJoinResult successfulCoinJoinResult)
{
var scripts = successfulCoinJoinResult.UnsignedCoinJoin.Outputs.Select(x => x.ScriptPubKey);
var common = outputScriptCandidates.Intersect(scripts);
Assert.Empty(common);
throw new Exception("Coinjoin should have never finished successfully.");
}
}
catch (InvalidOperationException e) when(e.Message.StartsWith("No valid output denominations found"))
{
var scripts = successfulCoinJoinResult.UnsignedCoinJoin.Outputs.Select(x => x.ScriptPubKey);
var common = outputScriptCandidates.Intersect(scripts);
Assert.Empty(common);
throw new Exception("Coinjoin should have never finished successfully.");
// ignore. There is a rare case for this
}
}
}
Expand Down

0 comments on commit 8bb541f

Please sign in to comment.