Merge pull request #6594 from NicolasDorier/bump-nbx

Bump NBX
This commit is contained in:
Nicolas Dorier
2025-02-10 16:00:36 +09:00
committed by GitHub
10 changed files with 25 additions and 15 deletions

View File

@@ -2,7 +2,7 @@
<Import Project="../Build/Version.csproj" Condition="Exists('../Build/Version.csproj')" />
<Import Project="../Build/Common.csproj" />
<ItemGroup>
<PackageReference Include="NBXplorer.Client" Version="4.3.6" />
<PackageReference Include="NBXplorer.Client" Version="4.3.9" />
<PackageReference Include="NicolasDorier.StandardConfiguration" Version="2.0.1" />
</ItemGroup>
</Project>

View File

@@ -19,6 +19,19 @@ namespace BTCPayServer.Tests
{
public static class Extensions
{
public static Task<NewTransactionEvent> WaitReceive(this NBXplorer.WebsocketNotificationSession notifications, DerivationStrategyBase target, Func<NewTransactionEvent, bool> predicate = null, CancellationToken cancellationToken = default)
=> WaitNext<NewTransactionEvent>(notifications, e => e.DerivationStrategy == target && (predicate is null || predicate(e)), cancellationToken);
public static async Task<TEvent> WaitNext<TEvent>(this NBXplorer.WebsocketNotificationSession notifications, Func<TEvent, bool> predicate, CancellationToken cancellationToken = default) where TEvent : NewEventBase
{
retry:
var evt = await notifications.NextEventAsync(cancellationToken);
if (evt is TEvent { } e)
{
if (predicate(e))
return e;
}
goto retry;
}
public static Task<KeyPathInformation> ReserveAddressAsync(this BTCPayWallet wallet, DerivationStrategyBase derivationStrategyBase)
{
return wallet.ReserveAddressAsync(null, derivationStrategyBase, "test");

View File

@@ -426,7 +426,6 @@ namespace BTCPayServer.Tests
var notifications = await nbx.CreateWebsocketNotificationSessionAsync();
var alice = tester.NewAccount();
await alice.RegisterDerivationSchemeAsync("BTC", ScriptPubKeyType.Segwit, true);
await notifications.ListenDerivationSchemesAsync(new[] { alice.DerivationScheme });
BitcoinAddress address = null;
for (int i = 0; i < 5; i++)
@@ -434,7 +433,7 @@ namespace BTCPayServer.Tests
address = (await nbx.GetUnusedAsync(alice.DerivationScheme, DerivationFeature.Deposit)).Address;
await tester.ExplorerNode.GenerateAsync(1);
tester.ExplorerNode.SendToAddress(address, Money.Coins(1.0m));
await notifications.NextEventAsync();
await notifications.WaitReceive(alice.DerivationScheme);
}
var paymentAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Legacy, Network.RegTest);
var otherAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Legacy, Network.RegTest);
@@ -569,10 +568,9 @@ namespace BTCPayServer.Tests
await notifications.DisposeAsync();
notifications = await nbx.CreateWebsocketNotificationSessionAsync();
await notifications.ListenDerivationSchemesAsync(new[] { bob.DerivationScheme });
address = (await nbx.GetUnusedAsync(bob.DerivationScheme, DerivationFeature.Deposit)).Address;
tester.ExplorerNode.SendToAddress(address, Money.Coins(1.1m));
await notifications.NextEventAsync();
await notifications.WaitReceive(bob.DerivationScheme);
await bob.ModifyOnchainPaymentSettings(p => p.PayJoinEnabled = true);
var invoice = bob.BitPay.CreateInvoice(
new Invoice { Price = 0.1m, Currency = "BTC", FullNotifications = true });
@@ -603,7 +601,7 @@ namespace BTCPayServer.Tests
proposal = proposal.SignAll(derivationSchemeSettings.AccountDerivation, alice.GenerateWalletResponseV.AccountHDKey, signingAccount.GetRootedKeyPath());
proposal.Finalize();
await tester.ExplorerNode.SendRawTransactionAsync(proposal.ExtractTransaction());
await notifications.NextEventAsync();
await notifications.WaitReceive(bob.DerivationScheme);
TestLogs.LogInformation("Abusing minFeeRate should give not enough money error");
invoice = bob.BitPay.CreateInvoice(

View File

@@ -32,6 +32,7 @@ using Microsoft.EntityFrameworkCore;
using NBitcoin;
using NBitcoin.DataEncoders;
using NBitcoin.Payment;
using NBXplorer.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OpenQA.Selenium;
@@ -1884,11 +1885,9 @@ namespace BTCPayServer.Tests
//send money to addr and ensure it changed
var sess = await s.Server.ExplorerClient.CreateWebsocketNotificationSessionAsync();
await sess.ListenAllTrackedSourceAsync();
var nextEvent = sess.NextEventAsync();
await s.Server.ExplorerNode.SendToAddressAsync(BitcoinAddress.Create(receiveAddr, Network.RegTest),
Money.Parse("0.1"));
await nextEvent;
await sess.WaitNext<NewTransactionEvent>(e => e.Outputs.FirstOrDefault()?.Address.ToString() == receiveAddr);
await Task.Delay(200);
s.Driver.Navigate().Refresh();
s.Driver.FindElement(By.CssSelector("button[value=generate-new-address]")).Click();
@@ -1898,6 +1897,7 @@ namespace BTCPayServer.Tests
// Check the label is applied to the tx
s.Driver.WaitWalletTransactionsLoaded();
// Sometimes this fails in local, but not CI
Assert.Equal("label2", s.Driver.FindElement(By.XPath("//*[@id=\"WalletTransactionsList\"]//*[contains(@class, 'transaction-label')]")).Text);
//change the wallet and ensure old address is not there and generating a new one does not result in the prev one

View File

@@ -967,7 +967,6 @@ namespace BTCPayServer.Tests
using (var cts = new CancellationTokenSource(10000))
using (var listener = tester.ExplorerClient.CreateWebsocketNotificationSession())
{
listener.ListenAllDerivationSchemes();
var replaced = tester.ExplorerNode.SignRawTransaction(tx);
Thread.Sleep(1000); // Make sure the replacement has a different timestamp
var tx2 = tester.ExplorerNode.SendRawTransaction(replaced);

View File

@@ -98,7 +98,7 @@ services:
custom:
nbxplorer:
image: nicolasdorier/nbxplorer:2.5.16
image: nicolasdorier/nbxplorer:2.5.22
restart: unless-stopped
ports:
- "32838:32838"

View File

@@ -62,7 +62,7 @@ services:
custom:
nbxplorer:
image: nicolasdorier/nbxplorer:2.5.16
image: nicolasdorier/nbxplorer:2.5.22
restart: unless-stopped
ports:
- "32838:32838"

View File

@@ -57,7 +57,7 @@ services:
custom:
nbxplorer:
image: nicolasdorier/nbxplorer:2.5.16
image: nicolasdorier/nbxplorer:2.5.22
restart: unless-stopped
ports:
- "32838:32838"

View File

@@ -95,7 +95,7 @@ services:
custom:
nbxplorer:
image: nicolasdorier/nbxplorer:2.5.16
image: nicolasdorier/nbxplorer:2.5.22
restart: unless-stopped
ports:
- "32838:32838"

View File

@@ -128,7 +128,7 @@ namespace BTCPayServer.Payments.Bitcoin
return;
if (_Cts.IsCancellationRequested)
return;
var session = await client.CreateWebsocketNotificationSessionAsync(_Cts.Token).ConfigureAwait(false);
var session = await client.CreateWebsocketNotificationSessionLegacyAsync(_Cts.Token).ConfigureAwait(false);
if (!_SessionsByCryptoCode.TryAdd(network.CryptoCode, session))
{
await session.DisposeAsync();