Adjust RegTests
MODIFY
WalletWasabi.Tests/RegressionTests/BackendTests.cs
WalletWasabi.Tests/RegressionTests/BackendTests.cs
@@ -60,7 +60,7 @@ namespace WalletWasabi.Tests.RegressionTests
[Fact]
public async Task GetClientVersionAsync()
{
- var client = new WasabiClient(BackendHttpClient);
+ WasabiClient client = new(BackendHttpClient);
var uptodate = await client.CheckUpdatesAsync(CancellationToken.None);
Assert.True(uptodate.BackendCompatible);
Assert.True(uptodate.ClientUpToDate);
@@ -111,7 +111,7 @@ namespace WalletWasabi.Tests.RegressionTests
var indexBuilderServiceDir = Helpers.Common.GetWorkDir();
var indexFilePath = Path.Combine(indexBuilderServiceDir, $"Index{rpc.Network}.dat");
- var indexBuilderService = new IndexBuilderService(rpc, global.HostedServices.Get<BlockNotifier>(), indexFilePath);
+ IndexBuilderService indexBuilderService = new(rpc, global.HostedServices.Get<BlockNotifier>(), indexFilePath);
try
{
indexBuilderService.Synchronize();

MODIFY
WalletWasabi.Tests/RegressionTests/BuildTests.cs
WalletWasabi.Tests/RegressionTests/BuildTests.cs
@@ -8,6 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.BitcoinCore.Rpc;
using WalletWasabi.Blockchain.Analysis.FeesEstimation;
+using WalletWasabi.Blockchain.BlockFilters;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionBroadcasting;
using WalletWasabi.Blockchain.TransactionBuilding;
@@ -44,7 +45,7 @@ namespace WalletWasabi.Tests.RegressionTests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
+ NodesGroup nodes = new(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNewP2pNodeAsync());
// 2. Create mempool service.
@@ -53,9 +54,10 @@ namespace WalletWasabi.Tests.RegressionTests
node.Behaviors.Add(bitcoinStore.CreateUntrustedP2pBehavior());
// 3. Create wasabi synchronizer service.
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
- using var feeProvider = new HybridFeeProvider(synchronizer, null);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
+ using FilterProcessor filterProcessor = new(synchronizer, bitcoinStore);
+ using HybridFeeProvider feeProvider = new(synchronizer, null);
// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);
@@ -71,10 +73,8 @@ namespace WalletWasabi.Tests.RegressionTests
var scp = new Key().ScriptPubKey;
- var validIntent = new PaymentIntent(scp, Money.Coins(1));
- var invalidIntent = new PaymentIntent(
- new DestinationRequest(scp, Money.Coins(10 * 1000 * 1000)),
- new DestinationRequest(scp, Money.Coins(12 * 1000 * 1000)));
+ PaymentIntent validIntent = new(scp, Money.Coins(1));
+ PaymentIntent invalidIntent = new(new DestinationRequest(scp, Money.Coins(10 * 1000 * 1000)), new DestinationRequest(scp, Money.Coins(12 * 1000 * 1000)));
Assert.Throws<OverflowException>(() => new PaymentIntent(
new DestinationRequest(scp, Money.Satoshis(long.MaxValue)),
@@ -142,9 +142,7 @@ namespace WalletWasabi.Tests.RegressionTests
}
// subtract Fee from amount index with no enough money
- var operations = new PaymentIntent(
- new DestinationRequest(scp, Money.Coins(1m), subtractFee: true),
- new DestinationRequest(scp, Money.Coins(0.5m)));
+ PaymentIntent operations = new(new DestinationRequest(scp, Money.Coins(1m), subtractFee: true), new DestinationRequest(scp, Money.Coins(0.5m)));
Assert.Throws<InsufficientBalanceException>(() => wallet.BuildTransaction(password, operations, FeeStrategy.TwentyMinutesConfirmationTargetStrategy, false));
// No enough money (only one confirmed coin, no unconfirmed allowed)
@@ -209,7 +207,7 @@ namespace WalletWasabi.Tests.RegressionTests
bitcoinStore.IndexStore.NewFilter += Common.Wallet_NewFilterProcessed;
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
+ NodesGroup nodes = new(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNewP2pNodeAsync());
// 2. Create mempool service.
@@ -217,9 +215,10 @@ namespace WalletWasabi.Tests.RegressionTests
node.Behaviors.Add(bitcoinStore.CreateUntrustedP2pBehavior());
// 3. Create wasabi synchronizer service.
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
- using var feeProvider = new HybridFeeProvider(synchronizer, null);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
+ using FilterProcessor filterProcessor = new(synchronizer, bitcoinStore);
+ using HybridFeeProvider feeProvider = new(synchronizer, null);
// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);
@@ -229,7 +228,7 @@ namespace WalletWasabi.Tests.RegressionTests
CachedBlockProvider blockProvider = new(
new P2pBlockProvider(nodes, null, httpClientFactory, serviceConfiguration, network),
bitcoinStore.BlockRepository);
- var walletManager = new WalletManager(network, workDir, new WalletDirectories(network, workDir));
+ WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir));
walletManager.RegisterServices(bitcoinStore, synchronizer, serviceConfiguration, feeProvider, blockProvider);
var baseTip = await rpc.GetBestBlockHashAsync();
@@ -256,11 +255,11 @@ namespace WalletWasabi.Tests.RegressionTests
using var wallet = await walletManager.AddAndStartWalletAsync(keyManager);
var coin = Assert.Single(wallet.Coins);
Assert.True(coin.Confirmed);
- var broadcaster = new TransactionBroadcaster(network, bitcoinStore, httpClientFactory, walletManager);
+ TransactionBroadcaster broadcaster = new(network, bitcoinStore, httpClientFactory, walletManager);
broadcaster.Initialize(nodes, rpc);
// Send money before reorg.
- var operations = new PaymentIntent(scp, Money.Coins(0.011m));
+ PaymentIntent operations = new(scp, Money.Coins(0.011m));
var btx1 = wallet.BuildTransaction(password, operations, FeeStrategy.TwentyMinutesConfirmationTargetStrategy);
await broadcaster.SendTransactionAsync(btx1.Transaction);
var coin2 = Assert.Single(wallet.Coins);

MODIFY
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
@@ -14,6 +14,7 @@ using System.Threading.Tasks;
using WalletWasabi.BitcoinCore.Rpc;
using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.Analysis.FeesEstimation;
+using WalletWasabi.Blockchain.BlockFilters;
using WalletWasabi.Blockchain.Blocks;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionOutputs;
@@ -85,7 +86,7 @@ namespace WalletWasabi.Tests.RegressionTests
Directory.CreateDirectory(folder);
File.WriteAllLines(cjfile, new[] { coinbaseTxId.ToString(), "This line is invalid (the file is corrupted)", offchainTxId.ToString() });
- var coordinatorToTest2 = new Coordinator(network, global.HostedServices.Get<BlockNotifier>(), folder, rpc, coordinatorToTest.RoundConfig);
+ Coordinator coordinatorToTest2 = new(network, global.HostedServices.Get<BlockNotifier>(), folder, rpc, coordinatorToTest.RoundConfig);
coordinatorToTest2?.Dispose();
txIds = await File.ReadAllLinesAsync(cjfile);
Assert.Single(txIds);
@@ -158,7 +159,7 @@ namespace WalletWasabi.Tests.RegressionTests
byte[] dummySignature = new byte[65];
- var nullBlindedScript = new BlindedOutputWithNonceIndex(0, uint256.One);
+ BlindedOutputWithNonceIndex nullBlindedScript = new(0, uint256.One);
inputsRequest.BlindedOutputScripts = Enumerable.Range(0, round.MixingLevels.Count() + 1).Select(x => nullBlindedScript);
inputsRequest.ChangeOutputAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
inputsRequest.Inputs = new List<InputProofModel> { new InputProofModel { Input = new OutPoint(uint256.One, 0), Proof = dummySignature } };
@@ -216,7 +217,7 @@ namespace WalletWasabi.Tests.RegressionTests
var requester = new Requester();
uint256 msg = new(NBitcoin.Crypto.Hashes.SHA256(network.Consensus.ConsensusFactory.CreateTransaction().ToBytes()));
var nonce = round.NonceProvider.GetNextNonce();
- var blindedData = new BlindedOutputWithNonceIndex(nonce.N, requester.BlindMessage(msg, nonce.R, round.MixingLevels.GetBaseLevel().SignerKey.PubKey));
+ BlindedOutputWithNonceIndex blindedData = new(nonce.N, requester.BlindMessage(msg, nonce.R, round.MixingLevels.GetBaseLevel().SignerKey.PubKey));
inputsRequest.BlindedOutputScripts = new[] { blindedData };
uint256 blindedOutputScriptsHash = new(NBitcoin.Crypto.Hashes.SHA256(blindedData.BlindedOutput.ToBytes()));
@@ -566,14 +567,14 @@ namespace WalletWasabi.Tests.RegressionTests
var requester1 = new Requester();
var requester2 = new Requester();
nonce = round.NonceProvider.GetNextNonce();
- var blinded1 = new BlindedOutputWithNonceIndex(nonce.N, requester1.BlindScript(round.MixingLevels.GetBaseLevel().SignerKey.PubKey, nonce.R, outputAddress1.ScriptPubKey));
+ BlindedOutputWithNonceIndex blinded1 = new(nonce.N, requester1.BlindScript(round.MixingLevels.GetBaseLevel().SignerKey.PubKey, nonce.R, outputAddress1.ScriptPubKey));
uint256 blindedOutputScriptsHash1 = new(NBitcoin.Crypto.Hashes.SHA256(blinded1.BlindedOutput.ToBytes()));
nonce = round.NonceProvider.GetNextNonce();
- var blinded2 = new BlindedOutputWithNonceIndex(nonce.N, requester2.BlindScript(round.MixingLevels.GetBaseLevel().Signer.Key.PubKey, nonce.R, outputAddress2.ScriptPubKey));
+ BlindedOutputWithNonceIndex blinded2 = new(nonce.N, requester2.BlindScript(round.MixingLevels.GetBaseLevel().Signer.Key.PubKey, nonce.R, outputAddress2.ScriptPubKey));
uint256 blindedOutputScriptsHash2 = new(NBitcoin.Crypto.Hashes.SHA256(blinded2.BlindedOutput.ToBytes()));
- var input1 = new OutPoint(hash1, index1);
- var input2 = new OutPoint(hash2, index2);
+ OutPoint input1 = new(hash1, index1);
+ OutPoint input2 = new(hash2, index2);
var inputRequest1 = new InputsRequest4
{
@@ -734,7 +735,7 @@ namespace WalletWasabi.Tests.RegressionTests
var scriptPubKey = outputsAddress.ScriptPubKey;
// We blind the scriptPubKey with a new requester by mixin level
var nonce = round.NonceProvider.GetNextNonce();
- var blindedScript = new BlindedOutputWithNonceIndex(nonce.N, requester.BlindScript(level.SignerKey.PubKey, nonce.R, scriptPubKey));
+ BlindedOutputWithNonceIndex blindedScript = new(nonce.N, requester.BlindScript(level.SignerKey.PubKey, nonce.R, scriptPubKey));
outputs.Add((requester, outputsAddress, blindedScript));
}
@@ -753,7 +754,7 @@ namespace WalletWasabi.Tests.RegressionTests
await rpc.GenerateAsync(1);
var tx = await rpc.GetRawTransactionAsync(hash);
var index = tx.Outputs.FindIndex(x => x.ScriptPubKey == outputAddress.ScriptPubKey);
- var input = new OutPoint(hash, index);
+ OutPoint input = new(hash, index);
inputs.Add((
input,
@@ -873,7 +874,7 @@ namespace WalletWasabi.Tests.RegressionTests
CoordinatorRound round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
var requester = new Requester();
var nonce = round.NonceProvider.GetNextNonce();
- var blinded = new BlindedOutputWithNonceIndex(nonce.N, requester.BlindScript(round.MixingLevels.GetBaseLevel().SignerKey.PubKey, nonce.R, activeOutputAddress.ScriptPubKey));
+ BlindedOutputWithNonceIndex blinded = new(nonce.N, requester.BlindScript(round.MixingLevels.GetBaseLevel().SignerKey.PubKey, nonce.R, activeOutputAddress.ScriptPubKey));
uint256 blindedOutputScriptsHash = new(NBitcoin.Crypto.Hashes.SHA256(blinded.BlindedOutput.ToBytes()));
var inputProofModels = new List<InputProofModel>();
@@ -1073,8 +1074,8 @@ namespace WalletWasabi.Tests.RegressionTests
{
(string password, IRPCClient rpc, Network network, Coordinator coordinator, _, BitcoinStore bitcoinStore, _) = await Common.InitializeTestEnvironmentAsync(RegTestFixture, 1);
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
synchronizer.Start(requestInterval: TimeSpan.FromSeconds(3), 10000); // Start wasabi synchronizer service.
Money denomination = Money.Coins(0.9m);
@@ -1111,13 +1112,13 @@ namespace WalletWasabi.Tests.RegressionTests
key.SetKeyState(KeyState.Used);
var tx = await rpc.GetRawTransactionAsync(txId);
var height = await rpc.GetBlockCountAsync();
- var stx = new SmartTransaction(tx, height + 1);
+ SmartTransaction stx = new(tx, height + 1);
var bechCoin = tx.Outputs.GetCoins(bech.ScriptPubKey).Single();
- var smartCoin = new SmartCoin(stx, bechCoin.Outpoint.N, key);
+ SmartCoin smartCoin = new(stx, bechCoin.Outpoint.N, key);
key.SetAnonymitySet(tx.GetAnonymitySet(bechCoin.Outpoint.N), tx.GetHash());
- var chaumianClient = new CoinJoinClient(synchronizer, rpc.Network, keyManager, new Kitchen());
+ CoinJoinClient chaumianClient = new(synchronizer, rpc.Network, keyManager, new Kitchen());
participants.Add((smartCoin, chaumianClient));
}
@@ -1179,8 +1180,8 @@ namespace WalletWasabi.Tests.RegressionTests
{
(string password, IRPCClient rpc, Network network, Coordinator coordinator, _, BitcoinStore bitcoinStore, _) = await Common.InitializeTestEnvironmentAsync(RegTestFixture, 1);
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
synchronizer.Start(requestInterval: TimeSpan.FromSeconds(3), 10000); // Start wasabi synchronizer service.
Money denomination = Money.Coins(0.1m);
@@ -1218,27 +1219,27 @@ namespace WalletWasabi.Tests.RegressionTests
var tx4 = await rpc.GetRawTransactionAsync(txId4);
await rpc.GenerateAsync(1);
var height = await rpc.GetBlockCountAsync();
- var stx1 = new SmartTransaction(tx1, height);
- var stx2 = new SmartTransaction(tx2, height);
- var stx3 = new SmartTransaction(tx3, height);
- var stx4 = new SmartTransaction(tx4, height);
+ SmartTransaction stx1 = new(tx1, height);
+ SmartTransaction stx2 = new(tx2, height);
+ SmartTransaction stx3 = new(tx3, height);
+ SmartTransaction stx4 = new(tx4, height);
var bech1Coin = tx1.Outputs.GetCoins(bech1.ScriptPubKey).Single();
var bech2Coin = tx2.Outputs.GetCoins(bech2.ScriptPubKey).Single();
var bech3Coin = tx3.Outputs.GetCoins(bech3.ScriptPubKey).Single();
var bech4Coin = tx4.Outputs.GetCoins(bech4.ScriptPubKey).Single();
- var smartCoin1 = new SmartCoin(stx1, bech1Coin.Outpoint.N, key1);
- var smartCoin2 = new SmartCoin(stx2, bech2Coin.Outpoint.N, key2);
- var smartCoin3 = new SmartCoin(stx3, bech3Coin.Outpoint.N, key3);
- var smartCoin4 = new SmartCoin(stx4, bech4Coin.Outpoint.N, key4);
+ SmartCoin smartCoin1 = new(stx1, bech1Coin.Outpoint.N, key1);
+ SmartCoin smartCoin2 = new(stx2, bech2Coin.Outpoint.N, key2);
+ SmartCoin smartCoin3 = new(stx3, bech3Coin.Outpoint.N, key3);
+ SmartCoin smartCoin4 = new(stx4, bech4Coin.Outpoint.N, key4);
key1.SetAnonymitySet(tx1.GetAnonymitySet(bech1Coin.Outpoint.N), tx1.GetHash());
key2.SetAnonymitySet(tx2.GetAnonymitySet(bech2Coin.Outpoint.N), tx2.GetHash());
key3.SetAnonymitySet(tx3.GetAnonymitySet(bech3Coin.Outpoint.N), tx3.GetHash());
key4.SetAnonymitySet(tx4.GetAnonymitySet(bech4Coin.Outpoint.N), tx4.GetHash());
- var chaumianClient1 = new CoinJoinClient(synchronizer, rpc.Network, keyManager, new Kitchen());
- var chaumianClient2 = new CoinJoinClient(synchronizer, rpc.Network, keyManager, new Kitchen());
+ CoinJoinClient chaumianClient1 = new(synchronizer, rpc.Network, keyManager, new Kitchen());
+ CoinJoinClient chaumianClient2 = new(synchronizer, rpc.Network, keyManager, new Kitchen());
try
{
chaumianClient1.Start(); // Exactly delay it for 2 seconds, this will make sure of timeout later.
@@ -1261,7 +1262,7 @@ namespace WalletWasabi.Tests.RegressionTests
// Make sure it does not throw.
var randomTx = network.Consensus.ConsensusFactory.CreateTransaction();
randomTx.Outputs.Add(new TxOut(Money.Coins(3m), randomKey.P2wpkhScript));
- var randomStx = new SmartTransaction(randomTx, Height.Mempool);
+ SmartTransaction randomStx = new(randomTx, Height.Mempool);
await chaumianClient1.DequeueCoinsFromMixAsync(new SmartCoin(randomStx, 0, randomKey), DequeueReason.UserRequested);
randomKey.SetAnonymitySet(1, randomStx.GetHash());
@@ -1296,7 +1297,7 @@ namespace WalletWasabi.Tests.RegressionTests
var cjHash = (await rpc.GetRawMempoolAsync()).Single();
var cj = await rpc.GetRawTransactionAsync(cjHash);
- var sCj = new SmartTransaction(cj, Height.Mempool);
+ SmartTransaction sCj = new(cj, Height.Mempool);
smartCoin1.SpenderTransaction = sCj;
smartCoin2.SpenderTransaction = sCj;
smartCoin3.SpenderTransaction = sCj;
@@ -1362,10 +1363,10 @@ namespace WalletWasabi.Tests.RegressionTests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(global.Config.Network, requirements: WalletWasabi.Helpers.Constants.NodeRequirements);
+ NodesGroup nodes = new(global.Config.Network, requirements: WalletWasabi.Helpers.Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNewP2pNodeAsync());
- var nodes2 = new NodesGroup(global.Config.Network, requirements: WalletWasabi.Helpers.Constants.NodeRequirements);
+ NodesGroup nodes2 = new(global.Config.Network, requirements: WalletWasabi.Helpers.Constants.NodeRequirements);
nodes2.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNewP2pNodeAsync());
// 2. Create mempool service.
@@ -1377,13 +1378,15 @@ namespace WalletWasabi.Tests.RegressionTests
node2.Behaviors.Add(bitcoinStore.CreateUntrustedP2pBehavior());
// 3. Create wasabi synchronizer service.
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
- using var feeProvider = new HybridFeeProvider(synchronizer, null);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
+ using FilterProcessor filterProcessor = new(synchronizer, bitcoinStore);
+ using HybridFeeProvider feeProvider = new(synchronizer, null);
var indexFilePath2 = Path.Combine(Helpers.Common.GetWorkDir(), $"Index{network}2.dat");
- var synchronizer2 = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
- using var feeProvider2 = new HybridFeeProvider(synchronizer2, null);
+ WasabiSynchronizer synchronizer2 = new(bitcoinStore, httpClientFactory);
+ using FilterProcessor filterProcessor2 = new(synchronizer2, bitcoinStore);
+ using HybridFeeProvider feeProvider2 = new(synchronizer2, null);
// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);

MODIFY
WalletWasabi.Tests/RegressionTests/DosTests.cs
WalletWasabi.Tests/RegressionTests/DosTests.cs
@@ -65,26 +65,26 @@ namespace WalletWasabi.Tests.RegressionTests
Uri baseUri = new(RegTestFixture.BackendEndPoint);
var fundingTxCount = 0;
- var inputRegistrationUsers = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData)>();
+ List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData)> inputRegistrationUsers = new();
CoordinatorRound round = null;
for (int i = 0; i < roundConfig.AnonymitySet; i++)
{
- var userInputData = new List<(Key key, BitcoinWitPubKeyAddress inputAddress, uint256 txHash, Transaction tx, OutPoint input)>();
+ List<(Key key, BitcoinWitPubKeyAddress inputAddress, uint256 txHash, Transaction tx, OutPoint input)> userInputData = new();
var activeOutputAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
var changeOutputAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
Requester requester = new();
var nonce = round.NonceProvider.GetNextNonce();
- var blinded = new BlindedOutputWithNonceIndex(nonce.N, requester.BlindScript(round.MixingLevels.GetBaseLevel().SignerKey.PubKey, nonce.R, activeOutputAddress.ScriptPubKey));
+ BlindedOutputWithNonceIndex blinded = new(nonce.N, requester.BlindScript(round.MixingLevels.GetBaseLevel().SignerKey.PubKey, nonce.R, activeOutputAddress.ScriptPubKey));
uint256 blindedOutputScriptsHash = new(Hashes.SHA256(blinded.BlindedOutput.ToBytes()));
- var inputProofModels = new List<InputProofModel>();
+ List<InputProofModel> inputProofModels = new();
int numberOfInputs = CryptoHelpers.RandomInt(1, 6);
var receiveSatoshiSum = 0;
for (int j = 0; j < numberOfInputs; j++)
{
- var key = new Key();
+ Key key = new();
var receiveSatoshi = CryptoHelpers.RandomInt(1000, 100000000);
receiveSatoshiSum += receiveSatoshi;
if (j == numberOfInputs - 1)
@@ -122,7 +122,7 @@ namespace WalletWasabi.Tests.RegressionTests
await rpc.GenerateAsync(1);
}
- var aliceClients = new List<Task<AliceClient4>>();
+ List<Task<AliceClient4>> aliceClients = new();
foreach (var user in inputRegistrationUsers)
{
@@ -130,7 +130,7 @@ namespace WalletWasabi.Tests.RegressionTests
}
long roundId = 0;
- var users = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient4 aliceClient, UnblindedSignature unblindedSignature)>();
+ List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient4 aliceClient, UnblindedSignature unblindedSignature)> users = new();
for (int i = 0; i < inputRegistrationUsers.Count; i++)
{
var user = inputRegistrationUsers[i];
@@ -153,7 +153,7 @@ namespace WalletWasabi.Tests.RegressionTests
Assert.Equal(users.Count, roundConfig.AnonymitySet);
- var confirmationRequests = new List<Task<(RoundPhase currentPhase, IEnumerable<ActiveOutput>)>>();
+ List<Task<(RoundPhase currentPhase, IEnumerable<ActiveOutput>)>> confirmationRequests = new();
foreach (var user in users)
{
@@ -269,7 +269,7 @@ namespace WalletWasabi.Tests.RegressionTests
Uri baseUri = new(RegTestFixture.BackendEndPoint);
- var registerRequests = new List<(BitcoinWitPubKeyAddress changeOutputAddress, BlindedOutputWithNonceIndex blindedData, InputProofModel[] inputsProofs)>();
+ List<(BitcoinWitPubKeyAddress changeOutputAddress, BlindedOutputWithNonceIndex blindedData, InputProofModel[] inputsProofs)> registerRequests = new();
AliceClient4 aliceClientBackup = null;
CoordinatorRound round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
for (int i = 0; i < roundConfig.AnonymitySet; i++)
@@ -279,10 +279,10 @@ namespace WalletWasabi.Tests.RegressionTests
Key inputKey = new();
BitcoinWitPubKeyAddress inputAddress = inputKey.PubKey.GetSegwitAddress(network);
- var requester = new Requester();
+ Requester requester = new();
var nonce = round.NonceProvider.GetNextNonce();
- var blinded = new BlindedOutputWithNonceIndex(nonce.N, requester.BlindScript(round.MixingLevels.GetBaseLevel().SignerKey.PubKey, nonce.R, activeOutputAddress.ScriptPubKey));
+ BlindedOutputWithNonceIndex blinded = new(nonce.N, requester.BlindScript(round.MixingLevels.GetBaseLevel().SignerKey.PubKey, nonce.R, activeOutputAddress.ScriptPubKey));
uint256 blindedOutputScriptsHash = new(Hashes.SHA256(blinded.BlindedOutput.ToBytes()));
uint256 txHash = await rpc.SendToAddressAsync(inputAddress, Money.Coins(2));

MODIFY
WalletWasabi.Tests/RegressionTests/SendTests.cs
WalletWasabi.Tests/RegressionTests/SendTests.cs
@@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.BitcoinCore.Rpc;
using WalletWasabi.Blockchain.Analysis.FeesEstimation;
+using WalletWasabi.Blockchain.BlockFilters;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionBroadcasting;
using WalletWasabi.Blockchain.TransactionBuilding;
@@ -41,7 +42,7 @@ namespace WalletWasabi.Tests.RegressionTests
bitcoinStore.IndexStore.NewFilter += Common.Wallet_NewFilterProcessed;
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
+ NodesGroup nodes = new(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNewP2pNodeAsync());
// 2. Create mempool service.
@@ -50,9 +51,10 @@ namespace WalletWasabi.Tests.RegressionTests
node.Behaviors.Add(bitcoinStore.CreateUntrustedP2pBehavior());
// 3. Create wasabi synchronizer service.
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
- using var feeProvider = new HybridFeeProvider(synchronizer, null);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
+ using FilterProcessor filterProcessor = new(synchronizer, bitcoinStore);
+ using HybridFeeProvider feeProvider = new(synchronizer, null);
// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);
@@ -64,7 +66,7 @@ namespace WalletWasabi.Tests.RegressionTests
new P2pBlockProvider(nodes, null, httpClientFactory, serviceConfiguration, network),
bitcoinStore.BlockRepository);
- var walletManager = new WalletManager(network, workDir, new WalletDirectories(network, workDir));
+ WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir));
walletManager.RegisterServices(bitcoinStore, synchronizer, serviceConfiguration, feeProvider, blockProvider);
// Get some money, make it confirm.
@@ -89,7 +91,7 @@ namespace WalletWasabi.Tests.RegressionTests
await Common.WaitForFiltersToBeProcessedAsync(TimeSpan.FromSeconds(120), blockCount);
var wallet = await walletManager.AddAndStartWalletAsync(keyManager);
- var broadcaster = new TransactionBroadcaster(network, bitcoinStore, httpClientFactory, walletManager);
+ TransactionBroadcaster broadcaster = new(network, bitcoinStore, httpClientFactory, walletManager);
broadcaster.Initialize(nodes, rpc);
var waitCount = 0;
@@ -425,7 +427,7 @@ namespace WalletWasabi.Tests.RegressionTests
receive = keyManager.GetNextReceiveKey("AllowedInputsDisallowUnconfirmed", out _).P2wpkhScript;
var allowedInputs = wallet.Coins.Where(x => x.IsAvailable()).Select(x => x.OutPoint).Take(1);
- var toSend = new PaymentIntent(receive, MoneyRequest.CreateAllRemaining(), "fizz");
+ PaymentIntent toSend = new(receive, MoneyRequest.CreateAllRemaining(), "fizz");
// covers:
// disallow unconfirmed with allowed inputs
@@ -523,7 +525,7 @@ namespace WalletWasabi.Tests.RegressionTests
bitcoinStore.IndexStore.NewFilter += Common.Wallet_NewFilterProcessed;
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
+ NodesGroup nodes = new(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNewP2pNodeAsync());
// 2. Create mempool service.
@@ -532,9 +534,10 @@ namespace WalletWasabi.Tests.RegressionTests
node.Behaviors.Add(bitcoinStore.CreateUntrustedP2pBehavior());
// 3. Create wasabi synchronizer service.
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
- using var feeProvider = new HybridFeeProvider(synchronizer, null);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
+ using FilterProcessor filterProcessor = new(synchronizer, bitcoinStore);
+ using HybridFeeProvider feeProvider = new(synchronizer, null);
// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);
@@ -546,7 +549,7 @@ namespace WalletWasabi.Tests.RegressionTests
new P2pBlockProvider(nodes, null, httpClientFactory, serviceConfiguration, network),
bitcoinStore.BlockRepository);
- var walletManager = new WalletManager(network, workDir, new WalletDirectories(network, workDir));
+ WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir));
walletManager.RegisterServices(bitcoinStore, synchronizer, serviceConfiguration, feeProvider, blockProvider);
// Get some money, make it confirm.
@@ -578,13 +581,10 @@ namespace WalletWasabi.Tests.RegressionTests
Assert.Equal(tx0Id, eventArgs.NewlyReceivedCoins.Single().TransactionId);
Assert.Single(wallet.Coins);
- var broadcaster = new TransactionBroadcaster(network, bitcoinStore, httpClientFactory, walletManager);
+ TransactionBroadcaster broadcaster = new(network, bitcoinStore, httpClientFactory, walletManager);
broadcaster.Initialize(nodes, rpc);
- var operations = new PaymentIntent(
- new DestinationRequest(key.P2wpkhScript, Money.Coins(0.01m)),
- new DestinationRequest(new Key().ScriptPubKey, Money.Coins(0.01m)),
- new DestinationRequest(new Key().ScriptPubKey, Money.Coins(0.01m)));
+ PaymentIntent operations = new(new DestinationRequest(key.P2wpkhScript, Money.Coins(0.01m)), new DestinationRequest(new Key().ScriptPubKey, Money.Coins(0.01m)), new DestinationRequest(new Key().ScriptPubKey, Money.Coins(0.01m)));
var tx1Res = wallet.BuildTransaction(password, operations, FeeStrategy.TwentyMinutesConfirmationTargetStrategy, allowUnconfirmed: true);
Assert.Equal(2, tx1Res.InnerWalletOutputs.Count());
Assert.Equal(2, tx1Res.OuterWalletOutputs.Count());
@@ -699,7 +699,7 @@ namespace WalletWasabi.Tests.RegressionTests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
+ NodesGroup nodes = new(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNewP2pNodeAsync());
// 2. Create mempool service.
@@ -708,9 +708,10 @@ namespace WalletWasabi.Tests.RegressionTests
node.Behaviors.Add(bitcoinStore.CreateUntrustedP2pBehavior());
// 3. Create wasabi synchronizer service.
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
- using var feeProvider = new HybridFeeProvider(synchronizer, null);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
+ using FilterProcessor filterProcessor = new(synchronizer, bitcoinStore);
+ using HybridFeeProvider feeProvider = new(synchronizer, null);
// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);

MODIFY
WalletWasabi.Tests/RegressionTests/WalletTests.cs
WalletWasabi.Tests/RegressionTests/WalletTests.cs
@@ -53,8 +53,9 @@ namespace WalletWasabi.Tests.RegressionTests
{
(_, IRPCClient rpc, _, _, _, BitcoinStore bitcoinStore, _) = await Common.InitializeTestEnvironmentAsync(RegTestFixture, 1);
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
+ using FilterProcessor filterProcessor = new(synchronizer, bitcoinStore);
try
{
synchronizer.Start(requestInterval: TimeSpan.FromSeconds(1), 1000);
@@ -139,8 +140,9 @@ namespace WalletWasabi.Tests.RegressionTests
var node = RegTestFixture.BackendRegTestNode;
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
+ using FilterProcessor filterProcessor = new(synchronizer, bitcoinStore);
try
{
@@ -237,16 +239,17 @@ namespace WalletWasabi.Tests.RegressionTests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(global.Config.Network, requirements: Constants.NodeRequirements);
+ NodesGroup nodes = new(global.Config.Network, requirements: Constants.NodeRequirements);
nodes.ConnectedNodes.Add(await RegTestFixture.BackendRegTestNode.CreateNewP2pNodeAsync());
Node node = await RegTestFixture.BackendRegTestNode.CreateNewP2pNodeAsync();
node.Behaviors.Add(bitcoinStore.CreateUntrustedP2pBehavior());
// 2. Create wasabi synchronizer service.
- var httpClientFactory = new HttpClientFactory(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
- var synchronizer = new WasabiSynchronizer(bitcoinStore, httpClientFactory);
- using var feeProvider = new HybridFeeProvider(synchronizer, null);
+ HttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
+ WasabiSynchronizer synchronizer = new(bitcoinStore, httpClientFactory);
+ using FilterProcessor filterProcessor = new(synchronizer, bitcoinStore);
+ using HybridFeeProvider feeProvider = new(synchronizer, null);
// 3. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);

MODIFY
WalletWasabi/Blockchain/BlockFilters/FilterProcessor.cs
WalletWasabi/Blockchain/BlockFilters/FilterProcessor.cs
@@ -13,7 +13,7 @@ using WalletWasabi.Stores;
namespace WalletWasabi.Blockchain.BlockFilters
{
- public class FilterProcessor
+ public class FilterProcessor : IDisposable
{
private volatile bool _disposedValue = false; // To detect redundant calls

Adjust RegTests