Add tests and fix txprocessor search
MODIFY
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
@@ -81,6 +81,81 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
Assert.True(transactionProcessor.TransactionStore.ConfirmedStore.IsEmpty());
}
+ [Fact]
+ public async Task ProcessResultAfterConfirmationCorrectAsync()
+ {
+ var transactionProcessor = await CreateTransactionProcessorAsync();
+
+ // An unconfirmed segwit transaction for us
+ var key = transactionProcessor.KeyManager.GetKeys().First();
+
+ var tx1 = CreateCreditingTransaction(key.PubKey.WitHash.ScriptPubKey, Money.Coins(1.0m));
+ var res = transactionProcessor.Process(tx1);
+ Assert.False(res.IsLikelyOwnCoinJoin);
+ Assert.Empty(res.NewlyConfirmedReceivedCoins);
+ Assert.Empty(res.NewlyConfirmedSpentCoins);
+ Assert.Single(res.NewlyReceivedCoins);
+ Assert.Empty(res.NewlySpentCoins);
+ Assert.Single(res.ReceivedCoins);
+ Assert.Empty(res.SpentCoins);
+ Assert.Empty(res.ReceivedDusts);
+ Assert.Empty(res.ReplacedCoins);
+ Assert.Empty(res.RestoredCoins);
+ Assert.Empty(res.SuccessfullyDoubleSpentCoins);
+ Assert.True(res.IsNews);
+ Assert.NotNull(res.Transaction);
+
+ var blockHeight = new Height(77551);
+ tx1 = new SmartTransaction(tx1.Transaction, blockHeight);
+ res = transactionProcessor.Process(tx1);
+ Assert.False(res.IsLikelyOwnCoinJoin);
+ Assert.Single(res.NewlyConfirmedReceivedCoins);
+ Assert.Empty(res.NewlyConfirmedSpentCoins);
+ Assert.Empty(res.NewlyReceivedCoins);
+ Assert.Empty(res.NewlySpentCoins);
+ Assert.Single(res.ReceivedCoins);
+ Assert.Empty(res.SpentCoins);
+ Assert.Empty(res.ReceivedDusts);
+ Assert.Empty(res.ReplacedCoins);
+ Assert.Empty(res.RestoredCoins);
+ Assert.Empty(res.SuccessfullyDoubleSpentCoins);
+ Assert.True(res.IsNews);
+ Assert.NotNull(res.Transaction);
+
+ var tx2 = CreateSpendingTransaction(tx1.Transaction.Outputs.AsCoins().First(), new Key().PubKey.WitHash.ScriptPubKey);
+ res = transactionProcessor.Process(tx2);
+ Assert.False(res.IsLikelyOwnCoinJoin);
+ Assert.Empty(res.NewlyConfirmedReceivedCoins);
+ Assert.Empty(res.NewlyConfirmedSpentCoins);
+ Assert.Empty(res.NewlyReceivedCoins);
+ Assert.Single(res.NewlySpentCoins);
+ Assert.Empty(res.ReceivedCoins);
+ Assert.Single(res.SpentCoins);
+ Assert.Empty(res.ReceivedDusts);
+ Assert.Empty(res.ReplacedCoins);
+ Assert.Empty(res.RestoredCoins);
+ Assert.Empty(res.SuccessfullyDoubleSpentCoins);
+ Assert.True(res.IsNews);
+ Assert.NotNull(res.Transaction);
+
+ blockHeight = new Height(77552);
+ tx2 = new SmartTransaction(tx2.Transaction, blockHeight);
+ res = transactionProcessor.Process(tx2);
+ Assert.False(res.IsLikelyOwnCoinJoin);
+ Assert.Empty(res.NewlyConfirmedReceivedCoins);
+ Assert.Single(res.NewlyConfirmedSpentCoins);
+ Assert.Empty(res.NewlyReceivedCoins);
+ Assert.Empty(res.NewlySpentCoins);
+ Assert.Empty(res.ReceivedCoins);
+ Assert.Single(res.SpentCoins);
+ Assert.Empty(res.ReceivedDusts);
+ Assert.Empty(res.ReplacedCoins);
+ Assert.Empty(res.RestoredCoins);
+ Assert.Empty(res.SuccessfullyDoubleSpentCoins);
+ Assert.True(res.IsNews);
+ Assert.NotNull(res.Transaction);
+ }
+
[Fact]
public async Task UpdateTransactionHeightAfterConfirmationAsync()
{

MODIFY
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
@@ -227,7 +227,7 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
{
var input = tx.Transaction.Inputs[i];
- var foundCoin = Coins.GetByOutPoint(input.PrevOut);
+ var foundCoin = Coins.AsAllCoinsView().GetByOutPoint(input.PrevOut);
if (foundCoin != null)
{
var alreadyKnown = foundCoin.SpenderTransactionId == txId;

Add tests and fix txprocessor search