Fix mocking.
MODIFY
WalletWasabi.Tests/UnitTests/Transactions/PayjoinTests.cs
WalletWasabi.Tests/UnitTests/Transactions/PayjoinTests.cs
@@ -464,7 +464,7 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
}
var coinsView = new CoinsView(scoins);
- var bitcoinStore = new BitcoinStoreMock();
+ var bitcoinStore = new BitcoinStore(null!, new AllTransactionStoreMock(workFolderPath: ".", Network.Main), null!, isMock: true);
return new TransactionFactory(Network.Main, keyManager, coinsView, bitcoinStore, password, allowUnconfirmed);
}

MODIFY
WalletWasabi.Tests/UnitTests/Transactions/TransactionFactoryTests.cs
WalletWasabi.Tests/UnitTests/Transactions/TransactionFactoryTests.cs
@@ -217,9 +217,7 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
}
var coinsView = new CoinsView(scoins.ToArray());
-
- var bitcoinStore = new BitcoinStoreMock();
-
+ var bitcoinStore = new BitcoinStore(null!, new AllTransactionStoreMock(workFolderPath: ".", Network.Main), null!, isMock: true);
var transactionFactory = new TransactionFactory(Network.Main, keyManager, coinsView, bitcoinStore, password);
// Two 0.9btc coins are enough
@@ -622,9 +620,7 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
}
}
var coinsView = new CoinsView(scoins);
-
- var bitcoinStore = new BitcoinStoreMock();
-
+ var bitcoinStore = new BitcoinStore(indexStore: null!, new AllTransactionStoreMock(workFolderPath: ".", Network.Main), mempoolService: null!, isMock: true);
var transactionFactory = new TransactionFactory(Network.Main, keyManager, coinsView, bitcoinStore, password);
return new TransactionFactory(Network.Main, keyManager, coinsView, bitcoinStore, password, allowUnconfirmed);

MODIFY
WalletWasabi/Blockchain/Transactions/AllTransactionStoreMock.cs
WalletWasabi/Blockchain/Transactions/AllTransactionStoreMock.cs
@@ -4,6 +4,10 @@ namespace WalletWasabi.Blockchain.Transactions
{
public class AllTransactionStoreMock : AllTransactionStore
{
+ public AllTransactionStoreMock(string workFolderPath, Network network) : base(workFolderPath, network)
+ {
+ }
+
public override bool TryGetTransaction(uint256 hash, out SmartTransaction sameStx)
{
sameStx = null;

MODIFY
WalletWasabi/Stores/BitcoinStore.cs
WalletWasabi/Stores/BitcoinStore.cs
+using System.IO;
using System.Threading.Tasks;
using WalletWasabi.Blockchain.Blocks;
using WalletWasabi.Blockchain.Mempool;
@@ -9,27 +10,29 @@ using WalletWasabi.Logging;
namespace WalletWasabi.Stores
{
/// <summary>
- /// The purpose of this class is to safely and performantly manage all the Bitcoin related data
- /// that's being serialized to disk, like transactions, wallet files, keys, blocks, index files, etc...
+ /// The purpose of this class is to safely and efficiently manage all the Bitcoin related data
+ /// that's being serialized to disk, like transactions, wallet files, keys, blocks, index files, etc.
/// </summary>
public class BitcoinStore
{
public BitcoinStore(
IndexStore indexStore,
AllTransactionStore transactionStore,
- MempoolService mempoolService)
+ MempoolService mempoolService,
+ bool isMock = false)
+ {
+ if (isMock)
+ {
+ IndexStore = indexStore;
+ TransactionStore = transactionStore;
+ MempoolService = mempoolService;
+ }
+ else
{
IndexStore = Guard.NotNull(nameof(indexStore), indexStore);
TransactionStore = Guard.NotNull(nameof(transactionStore), transactionStore);
MempoolService = Guard.NotNull(nameof(mempoolService), mempoolService);
}
-
- /// <summary>
- /// Special constructor used by the mock version.
- /// </summary>
- internal BitcoinStore()
- {
- TransactionStore = new AllTransactionStoreMock();
}
public bool IsInitialized { get; private set; }

DELETE
WalletWasabi/Stores/BitcoinStoreMock.cs
-namespace WalletWasabi.Stores
-{
- /// <summary>
- /// This class provides a Mock version of <see cref="BitcoinStore"/> for
- /// Unit tests that only need a dummy version of the class.
- /// </summary>
- public class BitcoinStoreMock : BitcoinStore
- {
- public BitcoinStoreMock() : base()
- {
- }
- }
-}

Fix mocking.