Elevate out 100participanttest and fix it.
MODIFY
WalletWasabi.Tests/NodeBuilding/CoreNode.cs
WalletWasabi.Tests/NodeBuilding/CoreNode.cs
@@ -112,7 +112,7 @@ namespace WalletWasabi.Tests.NodeBuilding
{"rest", "1"},
{"listenonion", "0"},
{"server", "1"},
- {"txindex", "0"},
+ {"txindex", "1"},
{"rpcuser", Creds.UserName},
{"rpcpassword", Creds.Password},
{"whitebind", "127.0.0.1:" + _ports[0].ToString()},

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -1460,7 +1460,7 @@ namespace WalletWasabi.Tests
}
[Fact]
- public async Task ChaumianCoinJoinTestsAsync() // These tests are taken from HiddenWallet, they were tests on the testnet.
+ public async Task ChaumianCoinJoinTestsAsync()
{
var rpc = Global.RpcClient;
var network = Global.RpcClient.Network;
@@ -2181,73 +2181,86 @@ namespace WalletWasabi.Tests
Assert.Contains(unsignedCoinJoin.GetHash(), mempooltxs);
#endregion
+ }
+ }
- #region 100Participants
- // <-------------------------->
- // 100 PARTICIPANT TEST
- // <-------------------------->
-
- roundConfig.AnonymitySet = 100;
- roundConfig.Denomination = new Money(0.1m, MoneyUnit.BTC);
+ [Fact]
+ public async Task ChaumianCoinJoin100ParticipantsTestsAsync()
+ {
+ var blindingKey = Global.Coordinator.RsaKey;
+ var rpc = Global.RpcClient;
+ var network = Global.RpcClient.Network;
+ var coordinator = Global.Coordinator;
+ Money denomination = new Money(0.1m, MoneyUnit.BTC);
+ decimal coordinatorFeePercent = 0.3m;
+ int anonymitySet = 100;
+ int connectionConfirmationTimeout = 50;
+ var roundConfig = new CcjRoundConfig(denomination, 2, coordinatorFeePercent, anonymitySet, 100, connectionConfirmationTimeout, 50, 50, 1);
coordinator.UpdateRoundConfig(roundConfig);
coordinator.FailAllRoundsInInputRegistration();
- await rpc.GenerateAsync(3);
+ using (var torClient = new TorHttpClient(new Uri(RegTestFixture.BackendEndPoint)))
+ {
+ await rpc.GenerateAsync(100); // So to make sure we have enough money.
+
+ var fundingTxCount = 0;
var users = new List<((BigInteger blindingFactor, byte[] blindedData) blinded, Script activeOutputScript, Script changeOutputScript, InputsRequest inputsRequest, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, Guid? uniqueId, string unblindedSigHex)>();
for (int i = 0; i < roundConfig.AnonymitySet; i++)
{
- var userInputData = new List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)>();
+ var userInputData = new List<(Key key, BitcoinWitPubKeyAddress inputAddress, uint256 txHash, Transaction tx, OutPoint input)>();
var activeOutputScript = new Key().ScriptPubKey;
var changeOutputScript = new Key().ScriptPubKey;
- var b = blindingKey.PubKey.Blind(activeOutputScript.ToBytes());
+ var blinded = blindingKey.PubKey.Blind(activeOutputScript.ToBytes());
var inputProofModels = new List<InputProofModel>();
int numberOfInputs = new Random().Next(1, 7);
- var recSatSum = 0;
+ var receiveSatoshiSum = 0;
for (int j = 0; j < numberOfInputs; j++)
{
- var k = new Key();
+ var key = new Key();
var receiveSatoshi = new Random().Next(1000, 100000000);
- recSatSum += receiveSatoshi;
+ receiveSatoshiSum += receiveSatoshi;
if (j == numberOfInputs - 1)
{
receiveSatoshi = 100000000;
}
- BitcoinWitPubKeyAddress ia = k.PubKey.GetSegwitAddress(network);
- var h = await rpc.SendToAddressAsync(ia, receiveSatoshi);
- var t = await rpc.GetRawTransactionAsync(h);
+ BitcoinWitPubKeyAddress inputAddress = key.PubKey.GetSegwitAddress(network);
+ uint256 txHash = await rpc.SendToAddressAsync(inputAddress, receiveSatoshi);
+ fundingTxCount++;
+ Assert.NotNull(txHash);
+ Transaction transaction = await rpc.GetRawTransactionAsync(txHash);
- var idx = 0;
+ var outputIndex = 0;
var hit = false;
- for (int l = 0; l < t.Outputs.Count; l++)
+ for (int k = 0; k < transaction.Outputs.Count; k++)
{
- var output = t.Outputs[l];
- if (output.ScriptPubKey == ia.ScriptPubKey)
+ var output = transaction.Outputs[k];
+ if (output.ScriptPubKey == inputAddress.ScriptPubKey)
{
- idx = i;
+ outputIndex = k;
hit = true;
}
}
Assert.True(hit);
- OutPoint inp = new OutPoint(h, idx);
- var ipr = new InputProofModel { Input = inp, Proof = k.SignMessage(ByteHelpers.ToHex(b.BlindedData)) };
- inputProofModels.Add(ipr);
+ OutPoint input = new OutPoint(txHash, outputIndex);
+ var inputProof = new InputProofModel { Input = input, Proof = key.SignMessage(ByteHelpers.ToHex(blinded.BlindedData)) };
+ inputProofModels.Add(inputProof);
- GetTxOutResponse getTxOutResponse = await rpc.GetTxOutAsync(inp.Hash, (int)inp.N, includeMempool: true);
+ GetTxOutResponse getTxOutResponse = await rpc.GetTxOutAsync(input.Hash, (int)input.N, includeMempool: true);
// Check if inputs are unspent.
Assert.NotNull(getTxOutResponse);
- userInputData.Add((k, ia, h, t, inp));
+ userInputData.Add((key, inputAddress, txHash, transaction, input));
}
- var ir = new InputsRequest
+ var inputsRequest = new InputsRequest
{
- BlindedOutputScriptHex = ByteHelpers.ToHex(b.BlindedData),
+ BlindedOutputScriptHex = ByteHelpers.ToHex(blinded.BlindedData),
Inputs = inputProofModels,
ChangeOutputScript = changeOutputScript.ToString()
};
- users.Add((b, activeOutputScript, changeOutputScript, ir, userInputData, null, null));
+ users.Add((blinded, activeOutputScript, changeOutputScript, inputsRequest, userInputData, null, null));
}
var mempool = await rpc.GetRawMempoolAsync();
@@ -2258,32 +2271,31 @@ namespace WalletWasabi.Tests
await rpc.GenerateAsync(1);
}
+ long roundId;
+
var inputsRequests = new List<Task<HttpResponseMessage>>();
- foreach(var u in users)
+ foreach (var user in users)
{
- inputsRequests.Add(client.SendAsync(HttpMethod.Post, "/api/v1/btc/chaumiancoinjoin/inputs/", u.inputsRequest.ToHttpStringContent()));
+ inputsRequests.Add(torClient.SendAsync(HttpMethod.Post, "/api/v1/btc/chaumiancoinjoin/inputs/", user.inputsRequest.ToHttpStringContent()));
}
for (int i = 0; i < users.Count; i++)
{
- var u = users[i];
- var r = inputsRequests[i];
+ var user = users[i];
+ var request = inputsRequests[i];
- using (var response = await r)
+ using (var response = await request)
{
var inputsResp = await response.Content.ReadAsJsonAsync<InputsResponse>();
- u.uniqueId = inputsResp.UniqueId;
+ user.uniqueId = inputsResp.UniqueId;
roundId = inputsResp.RoundId;
- u.unblindedSigHex = ByteHelpers.ToHex(blindingKey.PubKey.UnblindSignature(inputsResp.BlindedOutputSignature, u.blinded.blindingFactor));
+ user.unblindedSigHex = ByteHelpers.ToHex(blindingKey.PubKey.UnblindSignature(inputsResp.BlindedOutputSignature, user.blinded.blindingFactor));
}
}
-
- #endregion
}
}
#endregion
-
}
}

Elevate out 100participanttest and fix it.