diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 2985de2bf..25ce56b17 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -596,7 +596,7 @@ namespace BTCPayServer.Tests acc.RegisterDerivationScheme("BTC"); var btcDerivationScheme = acc.DerivationScheme; acc.RegisterDerivationScheme("LTC"); - + var walletController = tester.PayTester.GetController(acc.UserId); WalletId walletId = new WalletId(acc.StoreId, "LTC"); var rescan = Assert.IsType(Assert.IsType(walletController.WalletRescan(walletId).Result).Model); @@ -624,10 +624,10 @@ namespace BTCPayServer.Tests Assert.IsType(walletController.WalletRescan(walletId, rescan).Result); - while(true) + while (true) { rescan = Assert.IsType(Assert.IsType(walletController.WalletRescan(walletId).Result).Model); - if(rescan.Progress == null && rescan.LastSuccess != null) + if (rescan.Progress == null && rescan.LastSuccess != null) { if (rescan.LastSuccess.Found == 0) continue; @@ -790,7 +790,7 @@ namespace BTCPayServer.Tests output.Value = payment2; output.ScriptPubKey = invoiceAddress.ScriptPubKey; - using(var cts = new CancellationTokenSource(10000)) + using (var cts = new CancellationTokenSource(10000)) using (var listener = tester.ExplorerClient.CreateNotificationSession()) { listener.ListenAllDerivationSchemes(); @@ -1513,7 +1513,7 @@ namespace BTCPayServer.Tests var ctx = tester.PayTester.GetService().CreateContext(); Assert.Equal(0, invoice.CryptoInfo[0].TxCount); Assert.True(invoice.MinerFees.ContainsKey("BTC")); - Assert.Equal(100m, invoice.MinerFees["BTC"].SatoshiPerBytes); + Assert.Contains(invoice.MinerFees["BTC"].SatoshiPerBytes, new[] { 100.0m, 20.0m }); Eventually(() => { var textSearchResult = tester.PayTester.InvoiceRepository.GetInvoices(new InvoiceQuery() @@ -1625,7 +1625,7 @@ namespace BTCPayServer.Tests }, Facade.Merchant); invoiceAddress = BitcoinAddress.Create(invoice.BitcoinAddress, cashCow.Network); - cashCow.SendToAddress(invoiceAddress, invoice.BtcDue + Money.Coins(1)); + var txId = cashCow.SendToAddress(invoiceAddress, invoice.BtcDue + Money.Coins(1)); Eventually(() => { @@ -1633,6 +1633,13 @@ namespace BTCPayServer.Tests Assert.Equal("paid", localInvoice.Status); Assert.Equal(Money.Zero, localInvoice.BtcDue); Assert.Equal("paidOver", (string)((JValue)localInvoice.ExceptionStatus).Value); + + var textSearchResult = tester.PayTester.InvoiceRepository.GetInvoices(new InvoiceQuery() + { + StoreId = new[] { user.StoreId }, + TextSearch = txId.ToString() + }).GetAwaiter().GetResult(); + Assert.Single(textSearchResult); }); cashCow.Generate(1); @@ -1714,7 +1721,7 @@ namespace BTCPayServer.Tests } } - public static RateProviderFactory CreateBTCPayRateFactory() + public static RateProviderFactory CreateBTCPayRateFactory() { return new RateProviderFactory(CreateMemoryCache(), null, new CoinAverageSettings()); } diff --git a/BTCPayServer/Services/Invoices/InvoiceRepository.cs b/BTCPayServer/Services/Invoices/InvoiceRepository.cs index 55ccbf95c..34d78ebd6 100644 --- a/BTCPayServer/Services/Invoices/InvoiceRepository.cs +++ b/BTCPayServer/Services/Invoices/InvoiceRepository.cs @@ -295,6 +295,8 @@ namespace BTCPayServer.Services.Invoices { using (var tx = _Engine.GetTransaction()) { + var terms = searchTerms.Split(null); + searchTerms = string.Join(' ', terms.Select(t => t.Length > 50 ? t.Substring(0, 50) : t).ToArray()); return tx.TextSearch("InvoiceSearch").Block(searchTerms) .GetDocumentIDs() .Select(id => Encoders.Base58.EncodeData(id))