Add test of anonymity of coinjoin with sibling
MODIFY
WalletWasabi.Tests/UnitTests/BlockchainAnalysis/CoinJoinAnonscoreTests.cs
WalletWasabi.Tests/UnitTests/BlockchainAnalysis/CoinJoinAnonscoreTests.cs
@@ -3,6 +3,7 @@ using System.Linq;
using WalletWasabi.Blockchain.Analysis;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Tests.Helpers;
+using WalletWasabi.Tests.Helpers.AnalyzedTransaction;
using Xunit;
namespace WalletWasabi.Tests.UnitTests.BlockchainAnalysis;
@@ -256,4 +257,57 @@ public class CoinJoinAnonScoreTests
// 10 participants, 1 is you, your anonset would be 10 normally and now too:
Assert.Equal(10, tx.WalletOutputs.First().HdPubKey.AnonymitySet);
}
+
+ public void SiblingCoinjoinDoesntContributeToAnonScore()
+ {
+ var tx1 = new AnalyzedTransaction();
+ tx1.AddForeignInput();
+ tx1.AddWalletInput();
+ var A = tx1.AddForeignOutput();
+ var B = tx1.AddWalletOutput();
+
+ var tx2 = new AnalyzedTransaction();
+ tx2.AddForeignInput(A);
+ tx2.AddWalletInput(B);
+ tx2.AddForeignOutput();
+ var F = tx2.AddWalletOutput();
+
+ tx1.AnalyzeRecursively();
+
+ Assert.Equal(2, B.Anonymity);
+ Assert.Equal(2, F.Anonymity);
+ }
+
+ [Fact]
+ public void EarlierSiblingCoinjoinDoesntContributeToAnonScore()
+ {
+ var tx1 = new AnalyzedTransaction();
+ tx1.AddForeignInput();
+ tx1.AddWalletInput();
+ var A = tx1.AddForeignOutput();
+ var B = tx1.AddWalletOutput();
+
+ var tx2 = new AnalyzedTransaction();
+ tx2.AddForeignInput();
+ tx2.AddWalletInput(B);
+ var C = tx2.AddForeignOutput();
+ var D = tx2.AddWalletOutput();
+ var E = tx2.AddWalletOutput();
+
+ var tx3 = new AnalyzedTransaction();
+ tx3.AddForeignInput(A);
+ tx3.AddForeignInput(C);
+ tx3.AddWalletInput(D);
+ tx3.AddForeignOutput();
+ tx3.AddForeignOutput();
+ tx3.AddForeignOutput();
+ var L = tx3.AddWalletOutput();
+
+ tx3.AnalyzeRecursively();
+
+ Assert.Equal(2, B.Anonymity);
+ Assert.Equal(2, D.Anonymity);
+ Assert.Equal(2, E.Anonymity);
+ Assert.Equal(3, L.Anonymity);
+ }
}

Add test of anonymity of coinjoin with sibling