mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-31 11:54:24 +01:00
Replace entity upsert in PlannedTransaction by plain SQL (#6416)
* Replace entity upsert in PlannedTransaction by plain SQL * Fix flaky test from #6411
This commit is contained in:
@@ -404,10 +404,10 @@ namespace BTCPayServer.Tests
|
||||
Assert.False(paymentValueRowColumn.Text.Contains("payjoin",
|
||||
StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
s.GoToWallet(receiverWalletId, WalletsNavPages.Transactions);
|
||||
s.Driver.WaitForElement(By.CssSelector("#WalletTransactionsList tr"));
|
||||
TestUtils.Eventually(() =>
|
||||
{
|
||||
s.GoToWallet(receiverWalletId, WalletsNavPages.Transactions);
|
||||
s.Driver.WaitForElement(By.CssSelector("#WalletTransactionsList tr"));
|
||||
Assert.Contains("payjoin", s.Driver.PageSource);
|
||||
// Either the invoice id or the payjoin-exposed label, depending on the input having been used
|
||||
Assert.Matches(new Regex($"({invoiceId}|payjoin-exposed)"), s.Driver.PageSource);
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Data;
|
||||
using BTCPayServer.Logging;
|
||||
using Dapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NBitcoin;
|
||||
@@ -45,19 +46,18 @@ namespace BTCPayServer.Services
|
||||
ArgumentNullException.ThrowIfNull(transaction);
|
||||
ArgumentNullException.ThrowIfNull(network);
|
||||
using var db = _dbContextFactory.CreateContext();
|
||||
db.PlannedTransactions.Add(new PlannedTransaction()
|
||||
{
|
||||
Id = $"{network.CryptoCode}-{transaction.GetHash()}",
|
||||
BroadcastAt = broadcastTime,
|
||||
Blob = transaction.ToBytes()
|
||||
});
|
||||
try
|
||||
{
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateException)
|
||||
{
|
||||
}
|
||||
var conn = db.Database.GetDbConnection();
|
||||
await conn.ExecuteAsync(
|
||||
"""
|
||||
INSERT INTO "PlannedTransactions"("Id", "BroadcastAt", "Blob") VALUES(@Id, @BroadcastAt, @Blob)
|
||||
ON CONFLICT DO NOTHING
|
||||
""",
|
||||
new
|
||||
{
|
||||
Id = $"{network.CryptoCode}-{transaction.GetHash()}",
|
||||
BroadcastAt = broadcastTime,
|
||||
Blob = transaction.ToBytes()
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<int> ProcessAll(CancellationToken cancellationToken = default)
|
||||
|
||||
Reference in New Issue
Block a user