diff --git a/.docfx/docs/quickstart/quickstart.md b/.docfx/docs/quickstart/quickstart.md index 58130667..3bc325b9 100644 --- a/.docfx/docs/quickstart/quickstart.md +++ b/.docfx/docs/quickstart/quickstart.md @@ -7,7 +7,7 @@ and testing purposes. Before you begin, ensure you have the following installed on your system: -- [.NET 9.0 SDK](https://dotnet.microsoft.com/download/dotnet/9.0) or later +- [.NET 10.0 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) or later - Git (for cloning the repository) ## Installation diff --git a/.github/workflows/combined-report.yml b/.github/workflows/combined-report.yml index 7c75919d..12d650f7 100644 --- a/.github/workflows/combined-report.yml +++ b/.github/workflows/combined-report.yml @@ -65,7 +65,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Download Standard Coverage uses: dawidd6/action-download-artifact@v3 diff --git a/.github/workflows/dotnet.native.yml b/.github/workflows/dotnet.native.yml index 0bd0d34f..3367ba32 100644 --- a/.github/workflows/dotnet.native.yml +++ b/.github/workflows/dotnet.native.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Build run: dotnet build --configuration Release.Native -p:MSBuildWarningsAsMessages=MSB4121 diff --git a/.github/workflows/dotnet.wasm.yml b/.github/workflows/dotnet.wasm.yml index 743209df..641e2fd8 100644 --- a/.github/workflows/dotnet.wasm.yml +++ b/.github/workflows/dotnet.wasm.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Build run: dotnet build --configuration Release.Wasm @@ -29,7 +29,7 @@ jobs: - name: Install Dependencies shell: pwsh - run: bin/Release.Wasm/net9.0/playwright.ps1 install chromium + run: bin/Release.Wasm/net10.0/playwright.ps1 install chromium working-directory: test/BlazorTests/NLightning.Blazor.Tests - name: Test diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 975f7342..b36a3061 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Build run: dotnet build --configuration Release -p:MSBuildWarningsAsMessages=MSB4121 diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index ae58039e..b001cdc2 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -27,31 +27,31 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Dotnet Setup - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 9.0.x - - - name: Download Coverage Reports - uses: dawidd6/action-download-artifact@v3 - continue-on-error: true # Allow the docs to build even if there are no coverage reports - with: - workflow: combined-report.yml - name: coverage-docfx - path: .docfx/docs/coverage-reports/ + - name: Checkout + uses: actions/checkout@v3 + - name: Dotnet Setup + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x - - run: dotnet tool update -g docfx - - run: docfx .docfx/docfx.json + - name: Download Coverage Reports + uses: dawidd6/action-download-artifact@v3 + continue-on-error: true # Allow the docs to build even if there are no coverage reports + with: + workflow: combined-report.yml + name: coverage-docfx + path: .docfx/docs/coverage-reports/ - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - # Upload entire repository - path: '.docfx/_site' - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + - run: dotnet tool update -g docfx + - run: docfx .docfx/docfx.json + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload entire repository + path: '.docfx/_site' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.github/workflows/pr.combined-report.yml b/.github/workflows/pr.combined-report.yml index 7dc7b6b3..711612c4 100644 --- a/.github/workflows/pr.combined-report.yml +++ b/.github/workflows/pr.combined-report.yml @@ -65,7 +65,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Download Standard Coverage uses: dawidd6/action-download-artifact@v3 diff --git a/.github/workflows/pr.native.yml b/.github/workflows/pr.native.yml index 90eb3142..19ad7cd2 100644 --- a/.github/workflows/pr.native.yml +++ b/.github/workflows/pr.native.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Build run: dotnet build --configuration Release.Native -p:MSBuildWarningsAsMessages=MSB4121 diff --git a/.github/workflows/pr.wasm.yml b/.github/workflows/pr.wasm.yml index 93be486d..ce99fb16 100644 --- a/.github/workflows/pr.wasm.yml +++ b/.github/workflows/pr.wasm.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Build run: dotnet build --configuration Release.Wasm @@ -29,7 +29,7 @@ jobs: - name: Install Dependencies shell: pwsh - run: bin/Release.Wasm/net9.0/playwright.ps1 install chromium + run: bin/Release.Wasm/net10.0/playwright.ps1 install chromium working-directory: test/BlazorTests/NLightning.Blazor.Tests - name: Test diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4ce488c0..e9724c64 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,11 +13,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - + - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Build run: dotnet build --configuration Release -p:MSBuildWarningsAsMessages=MSB4121 @@ -38,7 +38,7 @@ jobs: title: "Code Coverage" tag: "${{ github.run_number }}_${{ github.run_id }}" toolpath: "reportgeneratortool" - + - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action@v2.16.1 if: always() diff --git a/NLightning.sln b/NLightning.sln index 45d3754c..4074123b 100644 --- a/NLightning.sln +++ b/NLightning.sln @@ -11,6 +11,9 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLightning.Node", "src\NLightning.Node\NLightning.Node.csproj", "{A103C727-E983-4510-81FB-301625DC1A7F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{AF4411D4-8EE9-423E-8213-1C9D35E47882}" + ProjectSection(SolutionItems) = preProject + src\Directory.Build.props = src\Directory.Build.props + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLightning.Infrastructure.Persistence", "src\NLightning.Infrastructure.Persistence\NLightning.Infrastructure.Persistence.csproj", "{2EBE72E4-F20D-4668-B2A5-F7DCDECA0832}" EndProject @@ -25,6 +28,9 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLightning.BlazorTestApp", "test\BlazorTests\NLightning.BlazorTestApp\NLightning.BlazorTestApp.csproj", "{99E240CC-6381-40DF-B784-528D2EDBBDFC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BlazorTests", "BlazorTests", "{6F76E9AF-7E6D-42D8-918A-4C5B26BE07C1}" + ProjectSection(SolutionItems) = preProject + src\Directory.Build.props = src\Directory.Build.props + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLightning.Blazor.Tests", "test\BlazorTests\NLightning.Blazor.Tests\NLightning.Blazor.Tests.csproj", "{C0F21413-47D0-4584-84A5-B730909E7349}" EndProject diff --git a/README.md b/README.md index 23b84799..8ab0fe9a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@   [![MIT License](https://img.shields.io/github/license/ngoline/nlightning)](LICENSE)   -![.NET 9.0](https://img.shields.io/badge/Version-.NET%209.0-informational?style=flat&logo=dotnet) +![.NET 10.0](https://img.shields.io/badge/Version-.NET%2010.0-informational?style=flat&logo=dotnet) Welcome to the C# implementation of the Lightning Network! @@ -52,7 +52,7 @@ and testing purposes. Before you begin, ensure you have the following installed on your system: -- [.NET 9.0 SDK](https://dotnet.microsoft.com/download/dotnet/9.0) or any later 9.x version +- [.NET 10.0 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) or any later 9.x version - Git (for cloning the repository) This project uses a global.json file to pin the .NET SDK to version 9.0.0, but with rollForward: diff --git a/global.json b/global.json index 93681ff8..90e5a421 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.0", + "version": "10.0.0", "rollForward": "latestMinor", "allowPrerelease": false } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 584963f4..14437cfa 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,6 @@ - - net8.0;net9.0 + net10.0 latest enable enable diff --git a/src/NLightning.Application/NLightning.Application.csproj b/src/NLightning.Application/NLightning.Application.csproj index dc5779ed..b10d49b0 100644 --- a/src/NLightning.Application/NLightning.Application.csproj +++ b/src/NLightning.Application/NLightning.Application.csproj @@ -1,13 +1,8 @@  - net8.0;net9.0 - latest - enable - enable 0.0.1 Debug;Release;Debug.Native;Release.Native;Debug.Wasm;Release.Wasm - AnyCPU @@ -50,12 +45,11 @@ - - + + - diff --git a/src/NLightning.Bolt11/Models/Invoice.cs b/src/NLightning.Bolt11/Models/Invoice.cs index 0753d931..0d56f520 100644 --- a/src/NLightning.Bolt11/Models/Invoice.cs +++ b/src/NLightning.Bolt11/Models/Invoice.cs @@ -195,7 +195,8 @@ public List? FallbackAddresses get { return _taggedFields - .TryGetAll(TaggedFieldTypes.FallbackAddress, out List fallbackAddress) + .TryGetAll(TaggedFieldTypes.FallbackAddress, + out List? fallbackAddress) ? fallbackAddress.Select(x => x.Value).ToList() : null; } diff --git a/src/NLightning.Domain/Protocol/Payloads/PingPayload.cs b/src/NLightning.Domain/Protocol/Payloads/PingPayload.cs index 6131701b..68772166 100644 --- a/src/NLightning.Domain/Protocol/Payloads/PingPayload.cs +++ b/src/NLightning.Domain/Protocol/Payloads/PingPayload.cs @@ -36,7 +36,7 @@ public class PingPayload : IMessagePayload public PingPayload() { var randomGenerator = new Random(); - // Get number of bytes at random between HashConstants.SHA256_HASH_LEN and ushort.MaxValue + // Get the number of bytes at random between HashConstants.SHA256_HASH_LEN and ushort.MaxValue NumPongBytes = (ushort)randomGenerator.Next(byte.MaxValue, MaxLength); BytesLength = (ushort)randomGenerator.Next(CryptoConstants.Sha256HashLen, 4 * CryptoConstants.Sha256HashLen); diff --git a/src/NLightning.Infrastructure.Bitcoin/NLightning.Infrastructure.Bitcoin.csproj b/src/NLightning.Infrastructure.Bitcoin/NLightning.Infrastructure.Bitcoin.csproj index 029de70e..fe2b63fe 100644 --- a/src/NLightning.Infrastructure.Bitcoin/NLightning.Infrastructure.Bitcoin.csproj +++ b/src/NLightning.Infrastructure.Bitcoin/NLightning.Infrastructure.Bitcoin.csproj @@ -24,10 +24,10 @@ - - - - + + + + diff --git a/src/NLightning.Infrastructure.Bitcoin/Wallet/BlockchainMonitorService.cs b/src/NLightning.Infrastructure.Bitcoin/Wallet/BlockchainMonitorService.cs index 0ab9df6c..7bb0ecb1 100644 --- a/src/NLightning.Infrastructure.Bitcoin/Wallet/BlockchainMonitorService.cs +++ b/src/NLightning.Infrastructure.Bitcoin/Wallet/BlockchainMonitorService.cs @@ -28,12 +28,7 @@ public class BlockchainMonitorService : IBlockchainMonitor private readonly SemaphoreSlim _newBlockSemaphore = new(1, 1); private readonly SemaphoreSlim _blockBacklogSemaphore = new(1, 1); private readonly ConcurrentDictionary _watchedTransactions = new(); -#if NET9_0_OR_GREATER private readonly OrderedDictionary _blocksToProcess = new(); -#else - // TODO: Check if ordering is the same in .NET 8 - private readonly SortedDictionary _blocksToProcess = new(); -#endif private BlockchainState _blockchainState = new(0, Hash.Empty, DateTime.UtcNow); private CancellationTokenSource? _cts; diff --git a/src/NLightning.Infrastructure.Persistence.Postgres/NLightning.Infrastructure.Persistence.Postgres.csproj b/src/NLightning.Infrastructure.Persistence.Postgres/NLightning.Infrastructure.Persistence.Postgres.csproj index 2b251521..bf0f1010 100644 --- a/src/NLightning.Infrastructure.Persistence.Postgres/NLightning.Infrastructure.Persistence.Postgres.csproj +++ b/src/NLightning.Infrastructure.Persistence.Postgres/NLightning.Infrastructure.Persistence.Postgres.csproj @@ -1,13 +1,7 @@  - net8.0;net9.0 - enable - enable - ..\NLightning.Models\bin\ Debug;Release;Debug.Native;Debug.Wasm;Release.Wasm;Release.Native - AnyCPU - ..\NLightning.Infrastructure.Persistence\bin\ @@ -20,14 +14,14 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + diff --git a/src/NLightning.Infrastructure.Persistence.SqlServer/NLightning.Infrastructure.Persistence.SqlServer.csproj b/src/NLightning.Infrastructure.Persistence.SqlServer/NLightning.Infrastructure.Persistence.SqlServer.csproj index 8930f8f7..0d9dc468 100644 --- a/src/NLightning.Infrastructure.Persistence.SqlServer/NLightning.Infrastructure.Persistence.SqlServer.csproj +++ b/src/NLightning.Infrastructure.Persistence.SqlServer/NLightning.Infrastructure.Persistence.SqlServer.csproj @@ -1,13 +1,7 @@  - net8.0;net9.0 - enable - enable - ..\NLightning.Models\bin\ Debug;Release;Debug.Native;Debug.Wasm;Release.Wasm;Release.Native - AnyCPU - ..\NLightning.Infrastructure.Persistence\bin\ @@ -20,13 +14,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/src/NLightning.Infrastructure.Persistence.Sqlite/Migrations/NLightningDbContextModelSnapshot.cs b/src/NLightning.Infrastructure.Persistence.Sqlite/Migrations/NLightningDbContextModelSnapshot.cs index 7cdd1aab..3eb61e3a 100644 --- a/src/NLightning.Infrastructure.Persistence.Sqlite/Migrations/NLightningDbContextModelSnapshot.cs +++ b/src/NLightning.Infrastructure.Persistence.Sqlite/Migrations/NLightningDbContextModelSnapshot.cs @@ -15,7 +15,7 @@ partial class NLightningDbContextModelSnapshot : ModelSnapshot protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.12"); + modelBuilder.HasAnnotation("ProductVersion", "10.0.5"); modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Bitcoin.BlockchainStateEntity", b => { diff --git a/src/NLightning.Infrastructure.Persistence.Sqlite/NLightning.Infrastructure.Persistence.Sqlite.csproj b/src/NLightning.Infrastructure.Persistence.Sqlite/NLightning.Infrastructure.Persistence.Sqlite.csproj index 8e85130f..84ff9190 100644 --- a/src/NLightning.Infrastructure.Persistence.Sqlite/NLightning.Infrastructure.Persistence.Sqlite.csproj +++ b/src/NLightning.Infrastructure.Persistence.Sqlite/NLightning.Infrastructure.Persistence.Sqlite.csproj @@ -1,13 +1,7 @@  - net8.0;net9.0 - enable - enable - ..\NLightning.Models\bin\ Debug;Release;Debug.Native;Debug.Wasm;Release.Native;Release.Wasm - AnyCPU - ..\NLightning.Infrastructure.Persistence\bin\ @@ -20,13 +14,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/src/NLightning.Infrastructure.Persistence/NLightning.Infrastructure.Persistence.csproj b/src/NLightning.Infrastructure.Persistence/NLightning.Infrastructure.Persistence.csproj index 21a3b38d..e62990f3 100644 --- a/src/NLightning.Infrastructure.Persistence/NLightning.Infrastructure.Persistence.csproj +++ b/src/NLightning.Infrastructure.Persistence/NLightning.Infrastructure.Persistence.csproj @@ -1,11 +1,7 @@  - net8.0;net9.0 - enable - enable Debug;Release;Debug.Native;Debug.Wasm;Release.Native;Release.Wasm - AnyCPU @@ -17,17 +13,17 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - + + + - + diff --git a/src/NLightning.Infrastructure.Persistence/scripts/add_migration.sh b/src/NLightning.Infrastructure.Persistence/scripts/add_migration.sh index cff3042e..d090d8c2 100755 --- a/src/NLightning.Infrastructure.Persistence/scripts/add_migration.sh +++ b/src/NLightning.Infrastructure.Persistence/scripts/add_migration.sh @@ -3,25 +3,23 @@ MigrationName=$1 echo "Building projects first..." -dotnet build ../NLightning.Infrastructure.Persistence.Postgres --framework net9.0 -dotnet build ../NLightning.Infrastructure.Persistence.Sqlite --framework net9.0 -dotnet build ../NLightning.Infrastructure.Persistence.SqlServer --framework net9.0 +dotnet build ../NLightning.Infrastructure.Persistence.Postgres +dotnet build ../NLightning.Infrastructure.Persistence.Sqlite +dotnet build ../NLightning.Infrastructure.Persistence.SqlServer echo "Postgres" export NLIGHTNING_POSTGRES=${NLIGHTNING_POSTGRES:-'User ID=superuser;Password=superuser;Server=localhost;Port=15432;Database=nlightning;'} unset NLIGHTNING_SQLITE unset NLIGHTNING_SQLSERVER dotnet ef migrations add $MigrationName \ - --project ../NLightning.Infrastructure.Persistence.Postgres \ - --framework net9.0 + --project ../NLightning.Infrastructure.Persistence.Postgres dotnet ef database update echo "Sqlite" unset NLIGHTNING_POSTGRES export NLIGHTNING_SQLITE=${NLIGHTNING_SQLITE:-'Data Source=./nltg.db;Cache=Shared'} dotnet ef migrations add $MigrationName \ - --project ../NLightning.Infrastructure.Persistence.Sqlite \ - --framework net9.0 + --project ../NLightning.Infrastructure.Persistence.Sqlite dotnet ef database update echo "SqlServer" @@ -29,8 +27,7 @@ unset NLIGHTNING_POSTGRES unset NLIGHTNING_SQLITE export NLIGHTNING_SQLSERVER=${NLIGHTNING_SQLSERVER:-'Server=localhost;Database=nlightning;User Id=sa;Password=Superuser1234*;Encrypt=false;'} dotnet ef migrations add $MigrationName \ - --project ../NLightning.Infrastructure.Persistence.SqlServer \ - --framework net9.0 + --project ../NLightning.Infrastructure.Persistence.SqlServer dotnet ef database update # Clean up diff --git a/src/NLightning.Infrastructure.Persistence/scripts/remove_migration.sh b/src/NLightning.Infrastructure.Persistence/scripts/remove_migration.sh index 110b1b22..86569764 100755 --- a/src/NLightning.Infrastructure.Persistence/scripts/remove_migration.sh +++ b/src/NLightning.Infrastructure.Persistence/scripts/remove_migration.sh @@ -1,32 +1,29 @@ #!/bin/bash echo "Building projects first..." -dotnet build ../NLightning.Infrastructure.Persistence.Postgres --framework net9.0 -dotnet build ../NLightning.Infrastructure.Persistence.Sqlite --framework net9.0 -dotnet build ../NLightning.Infrastructure.Persistence.SqlServer --framework net9.0 +dotnet build ../NLightning.Infrastructure.Persistence.Postgres +dotnet build ../NLightning.Infrastructure.Persistence.Sqlite +dotnet build ../NLightning.Infrastructure.Persistence.SqlServer echo "Postgres" export NLIGHTNING_POSTGRES=${NLIGHTNING_POSTGRES:-'User ID=superuser;Password=superuser;Server=localhost;Port=15432;Database=nlightning;'} unset NLIGHTNING_SQLITE unset NLIGHTNING_SQLSERVER dotnet ef migrations remove \ - --project ../NLightning.Infrastructure.Persistence.Postgres \ - --framework net9.0 + --project ../NLightning.Infrastructure.Persistence.Postgres echo "Sqlite" unset NLIGHTNING_POSTGRES export NLIGHTNING_SQLITE=${NLIGHTNING_SQLITE:-'Data Source=./nltg.db;Cache=Shared'} dotnet ef migrations remove \ - --project ../NLightning.Infrastructure.Persistence.Sqlite \ - --framework net9.0 + --project ../NLightning.Infrastructure.Persistence.Sqlite echo "SqlServer" unset NLIGHTNING_POSTGRES unset NLIGHTNING_SQLITE export NLIGHTNING_SQLSERVER=${NLIGHTNING_SQLSERVER:-'Server=localhost;Database=nlightning;User Id=sa;Password=Superuser1234*;Encrypt=false;'} dotnet ef migrations remove \ - --project ../NLightning.Infrastructure.Persistence.SqlServer \ - --framework net9.0 + --project ../NLightning.Infrastructure.Persistence.SqlServer # Clean up unset NLIGHTNING_POSTGRES diff --git a/src/NLightning.Infrastructure.Repositories/Memory/ChannelMemoryRepository.cs b/src/NLightning.Infrastructure.Repositories/Memory/ChannelMemoryRepository.cs index 709cfba1..43c3a024 100644 --- a/src/NLightning.Infrastructure.Repositories/Memory/ChannelMemoryRepository.cs +++ b/src/NLightning.Infrastructure.Repositories/Memory/ChannelMemoryRepository.cs @@ -77,9 +77,6 @@ public bool TryGetTemporaryChannelState(CompactPubKey compactPubKey, ChannelId c public void AddTemporaryChannel(CompactPubKey compactPubKey, ChannelModel channel) { - ArgumentNullException.ThrowIfNull(compactPubKey); - ArgumentNullException.ThrowIfNull(channel.ChannelId); - if (!_temporaryChannels.TryAdd((compactPubKey, channel.ChannelId), channel)) throw new InvalidOperationException( $"Temporary channel with Id {channel.ChannelId} for CompactPubKey {compactPubKey} already exists."); @@ -89,9 +86,6 @@ public void AddTemporaryChannel(CompactPubKey compactPubKey, ChannelModel channe public void UpdateTemporaryChannel(CompactPubKey compactPubKey, ChannelModel channel) { - ArgumentNullException.ThrowIfNull(compactPubKey); - ArgumentNullException.ThrowIfNull(channel.ChannelId); - if (!_temporaryChannels.ContainsKey((compactPubKey, channel.ChannelId))) throw new KeyNotFoundException( $"Temporary channel with Id {channel.ChannelId} for CompactPubKey {compactPubKey} does not exist."); @@ -102,9 +96,6 @@ public void UpdateTemporaryChannel(CompactPubKey compactPubKey, ChannelModel cha public void RemoveTemporaryChannel(CompactPubKey compactPubKey, ChannelId channelId) { - ArgumentNullException.ThrowIfNull(compactPubKey); - ArgumentNullException.ThrowIfNull(channelId); - if (!_temporaryChannels.TryRemove((compactPubKey, channelId), out _)) throw new KeyNotFoundException( $"Temporary channel with Id {channelId} for CompactPubKey {compactPubKey} does not exist."); diff --git a/src/NLightning.Infrastructure.Repositories/NLightning.Infrastructure.Repositories.csproj b/src/NLightning.Infrastructure.Repositories/NLightning.Infrastructure.Repositories.csproj index d931f56e..1f7eeb9e 100644 --- a/src/NLightning.Infrastructure.Repositories/NLightning.Infrastructure.Repositories.csproj +++ b/src/NLightning.Infrastructure.Repositories/NLightning.Infrastructure.Repositories.csproj @@ -1,11 +1,5 @@  - - net8.0 - enable - enable - - diff --git a/src/NLightning.Infrastructure.Serialization/NLightning.Infrastructure.Serialization.csproj b/src/NLightning.Infrastructure.Serialization/NLightning.Infrastructure.Serialization.csproj index 2b517bba..d5768be7 100644 --- a/src/NLightning.Infrastructure.Serialization/NLightning.Infrastructure.Serialization.csproj +++ b/src/NLightning.Infrastructure.Serialization/NLightning.Infrastructure.Serialization.csproj @@ -1,35 +1,30 @@  - - net8.0;net9.0 - latest - enable - enable - Debug;Release;Debug.Native;Release.Native;Debug.Wasm;Release.Wasm - AnyCPU - + + Debug;Release;Debug.Native;Release.Native;Debug.Wasm;Release.Wasm + - - true - false - + + true + false + - - true - + + true + - - true - false - + + true + false + - - true - + + true + - - - - + + + + diff --git a/src/NLightning.Infrastructure.Serialization/ValueObjects/ShortChannelIdTypeSerializer.cs b/src/NLightning.Infrastructure.Serialization/ValueObjects/ShortChannelIdTypeSerializer.cs index ebfdb20c..dde0f40c 100644 --- a/src/NLightning.Infrastructure.Serialization/ValueObjects/ShortChannelIdTypeSerializer.cs +++ b/src/NLightning.Infrastructure.Serialization/ValueObjects/ShortChannelIdTypeSerializer.cs @@ -1,9 +1,11 @@ using System.Buffers; -using NLightning.Domain.Channels.ValueObjects; -using NLightning.Domain.Interfaces; -using NLightning.Domain.Serialization.Interfaces; namespace NLightning.Infrastructure.Serialization.ValueObjects; + +using Domain.Channels.ValueObjects; +using Domain.Interfaces; +using Domain.Serialization.Interfaces; + public class ShortChannelIdTypeSerializer : IValueObjectTypeSerializer { /// @@ -44,6 +46,7 @@ public async Task DeserializeAsync(Stream stream) ArrayPool.Shared.Return(buffer); } } + async Task IValueObjectTypeSerializer.DeserializeAsync(Stream stream) { return await DeserializeAsync(stream); diff --git a/src/NLightning.Infrastructure/NLightning.Infrastructure.csproj b/src/NLightning.Infrastructure/NLightning.Infrastructure.csproj index 8091b337..e2beb005 100644 --- a/src/NLightning.Infrastructure/NLightning.Infrastructure.csproj +++ b/src/NLightning.Infrastructure/NLightning.Infrastructure.csproj @@ -87,13 +87,13 @@ - + - - + + diff --git a/src/NLightning.Node/Helpers/AesGcmHelper.cs b/src/NLightning.Node/Helpers/AesGcmHelper.cs index 9e3a84cb..47676f15 100644 --- a/src/NLightning.Node/Helpers/AesGcmHelper.cs +++ b/src/NLightning.Node/Helpers/AesGcmHelper.cs @@ -8,8 +8,7 @@ public static class AesGcmHelper private static byte[] DeriveKey(string password, byte[] salt) { - using var kdf = new Rfc2898DeriveBytes(password, salt, 100_000, HashAlgorithmName.SHA256); - return kdf.GetBytes(32); + return Rfc2898DeriveBytes.Pbkdf2(password, salt, 100_000, HashAlgorithmName.SHA256, 32); } public static byte[] Encrypt(byte[] plaintext, string password) diff --git a/src/NLightning.Node/NLightning.Node.csproj b/src/NLightning.Node/NLightning.Node.csproj index 8ce4a85f..05a9c843 100644 --- a/src/NLightning.Node/NLightning.Node.csproj +++ b/src/NLightning.Node/NLightning.Node.csproj @@ -2,14 +2,9 @@ Exe - net9.0 - enable - enable 0.0.1 Debug;Release;Debug.Native;Debug.Wasm;Release.Native;Release.Wasm - AnyCPU true - default @@ -22,17 +17,17 @@ - - - - - - + + + + + + - - - + + + diff --git a/test/BlazorTests/NLightning.Blazor.Tests/Infrastructure/BlazorTestBase.cs b/test/BlazorTests/NLightning.Blazor.Tests/Infrastructure/BlazorTestBase.cs index a0dc2926..da66b09e 100644 --- a/test/BlazorTests/NLightning.Blazor.Tests/Infrastructure/BlazorTestBase.cs +++ b/test/BlazorTests/NLightning.Blazor.Tests/Infrastructure/BlazorTestBase.cs @@ -82,7 +82,7 @@ public BlazorTestBase() _server.RunAsync(); } - public async Task InitializeAsync() + public async ValueTask InitializeAsync() { // Playwright initialization logic to intercept HTTP requests var playwright = await Playwright.CreateAsync(); @@ -102,7 +102,7 @@ private static bool IsBlazorFile(string fileName) fileName.EndsWith("dat"); } - public async Task DisposeAsync() + public async ValueTask DisposeAsync() { await _server.StopAsync(); Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true }); diff --git a/test/BlazorTests/NLightning.Blazor.Tests/NLightning.Blazor.Tests.csproj b/test/BlazorTests/NLightning.Blazor.Tests/NLightning.Blazor.Tests.csproj index 31c2cb5c..b1bb6c28 100644 --- a/test/BlazorTests/NLightning.Blazor.Tests/NLightning.Blazor.Tests.csproj +++ b/test/BlazorTests/NLightning.Blazor.Tests/NLightning.Blazor.Tests.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable enable false @@ -27,14 +27,14 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + runtime; build; native; contentfiles; analyzers; buildtransitive all + diff --git a/test/BlazorTests/NLightning.BlazorTestApp/NLightning.BlazorTestApp.csproj b/test/BlazorTests/NLightning.BlazorTestApp/NLightning.BlazorTestApp.csproj index b8c851df..27098d4a 100644 --- a/test/BlazorTests/NLightning.BlazorTestApp/NLightning.BlazorTestApp.csproj +++ b/test/BlazorTests/NLightning.BlazorTestApp/NLightning.BlazorTestApp.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable enable Release.Wasm;Debug.Wasm @@ -27,9 +27,10 @@ - - - + + + + diff --git a/test/Docker/custom_lnd/Dockerfile b/test/Docker/custom_lnd/Dockerfile index d701c49e..3aae8912 100644 --- a/test/Docker/custom_lnd/Dockerfile +++ b/test/Docker/custom_lnd/Dockerfile @@ -1,6 +1,6 @@ FROM debian:stable-slim -ARG LND_VERSION=0.19.1-beta +ARG LND_VERSION=0.20.0-beta ENV PATH=/opt/lnd:$PATH RUN apt-get update -y \ diff --git a/test/NLightning.Application.Tests/NLightning.Application.Tests.csproj b/test/NLightning.Application.Tests/NLightning.Application.Tests.csproj index e5fc5985..d6333387 100644 --- a/test/NLightning.Application.Tests/NLightning.Application.Tests.csproj +++ b/test/NLightning.Application.Tests/NLightning.Application.Tests.csproj @@ -1,25 +1,25 @@  - net9.0 + net10.0 + latest enable enable + AnyCPU + true false + true - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/test/NLightning.Application.Tests/Node/Managers/PeerManagerTests.cs b/test/NLightning.Application.Tests/Node/Managers/PeerManagerTests.cs index defc3527..8492d76f 100644 --- a/test/NLightning.Application.Tests/Node/Managers/PeerManagerTests.cs +++ b/test/NLightning.Application.Tests/Node/Managers/PeerManagerTests.cs @@ -196,7 +196,7 @@ public async Task Given_NewPeerConnected_When_EventRaised_Then_PeerIsAddedThroug #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. // Wait a bit for the async continuation to complete - await Task.Delay(50); + await Task.Delay(50, TestContext.Current.CancellationToken); // Then _mockPeerServiceFactory.Verify(f => f.CreateConnectingPeerAsync(mockTcpClient.Object), Times.Once); @@ -302,7 +302,7 @@ public async Task Given_ChannelMessageWithResponse_When_Processed_Then_ResponseI handlePeerChannelMessageMethod!.Invoke(peerManager, [null!, eventArgs]); // Wait a bit for the async continuation to complete - await Task.Delay(50); + await Task.Delay(50, TestContext.Current.CancellationToken); // Then _mockPeerService.Verify(p => p.SendMessageAsync(_mockResponseMessage.Object), Times.Once); @@ -335,7 +335,7 @@ public async Task Given_ChannelErrorException_When_ProcessingChannelMessage_Then handlePeerChannelMessageMethod!.Invoke(peerManager, [null!, eventArgs]); // Wait a bit for the async continuation to complete - await Task.Delay(100); + await Task.Delay(100, TestContext.Current.CancellationToken); // Then _mockPeerService.Verify(p => p.Disconnect(), Times.Once); @@ -376,7 +376,7 @@ public async Task handlePeerChannelMessageMethod!.Invoke(peerManager, [null!, eventArgs]); // Wait a bit for the async continuation to complete - await Task.Delay(100); + await Task.Delay(100, TestContext.Current.CancellationToken); // Then _mockPeerService.Verify(p => p.Disconnect(), Times.Never); @@ -464,7 +464,7 @@ public async Task Given_PeerServiceFactoryThrowsException_When_CreatingConnectin #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. // Wait for the async continuation to complete - await Task.Delay(50); + await Task.Delay(50, TestContext.Current.CancellationToken); // Then _mockLogger.Verify( diff --git a/test/NLightning.Bolt11.Tests/Models/TaggedFieldListTests.cs b/test/NLightning.Bolt11.Tests/Models/TaggedFieldListTests.cs index 783df890..e93461b5 100644 --- a/test/NLightning.Bolt11.Tests/Models/TaggedFieldListTests.cs +++ b/test/NLightning.Bolt11.Tests/Models/TaggedFieldListTests.cs @@ -1,10 +1,9 @@ -using NLightning.Bolt11.Models.TaggedFields; -using NLightning.Domain.Protocol.ValueObjects; -using NLightning.Domain.Utils; - namespace NLightning.Bolt11.Tests.Models; using Bolt11.Models; +using Bolt11.Models.TaggedFields; +using Domain.Protocol.ValueObjects; +using Domain.Utils; using Enums; using Interfaces; using Mocks; diff --git a/test/NLightning.Bolt11.Tests/Models/TaggedFields/DescriptionTaggedFieldTests.cs b/test/NLightning.Bolt11.Tests/Models/TaggedFields/DescriptionTaggedFieldTests.cs index 267b8be0..a4a96618 100644 --- a/test/NLightning.Bolt11.Tests/Models/TaggedFields/DescriptionTaggedFieldTests.cs +++ b/test/NLightning.Bolt11.Tests/Models/TaggedFields/DescriptionTaggedFieldTests.cs @@ -1,8 +1,7 @@ -using NLightning.Domain.Utils; - namespace NLightning.Bolt11.Tests.Models.TaggedFields; using Bolt11.Models.TaggedFields; +using Domain.Utils; using Enums; public class DescriptionTaggedFieldTests @@ -25,11 +24,35 @@ public void Constructor_FromValue_SetsPropertiesCorrectly(string value, short ex } [Theory] - [InlineData("Test Description", new byte[] { 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x00 })] - [InlineData("Test Description1", new byte[] { 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x31, 0x00 })] - [InlineData("Test Description12", new byte[] { 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x31, 0x32, 0x00 })] - [InlineData("Test Description123", new byte[] { 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x31, 0x32, 0x33, 0x00 })] - [InlineData("Test Description1234", new byte[] { 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x31, 0x32, 0x33, 0x34 })] + [InlineData("Test Description", + new byte[] + { + 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x00 + })] + [InlineData("Test Description1", + new byte[] + { + 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, + 0x31, 0x00 + })] + [InlineData("Test Description12", + new byte[] + { + 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, + 0x31, 0x32, 0x00 + })] + [InlineData("Test Description123", + new byte[] + { + 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, + 0x31, 0x32, 0x33, 0x00 + })] + [InlineData("Test Description1234", + new byte[] + { + 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, + 0x31, 0x32, 0x33, 0x34 + })] public void WriteToBitWriter_WritesCorrectData(string value, byte[] expectedBytes) { // Arrange @@ -46,11 +69,35 @@ public void WriteToBitWriter_WritesCorrectData(string value, byte[] expectedByte } [Theory] - [InlineData("Test Description", 26, new byte[] { 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x00 })] - [InlineData("Test Description1", 28, new byte[] { 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x31, 0x00 })] - [InlineData("Test Description12", 29, new byte[] { 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x31, 0x32, 0x00 })] - [InlineData("Test Description123", 31, new byte[] { 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x31, 0x32, 0x33, 0x00 })] - [InlineData("Test Description1234", 32, new byte[] { 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x31, 0x32, 0x33, 0x34 })] + [InlineData("Test Description", 26, + new byte[] + { + 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x00 + })] + [InlineData("Test Description1", 28, + new byte[] + { + 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, + 0x31, 0x00 + })] + [InlineData("Test Description12", 29, + new byte[] + { + 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, + 0x31, 0x32, 0x00 + })] + [InlineData("Test Description123", 31, + new byte[] + { + 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, + 0x31, 0x32, 0x33, 0x00 + })] + [InlineData("Test Description1234", 32, + new byte[] + { + 0x54, 0x65, 0x73, 0x74, 0x20, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6F, 0x6E, + 0x31, 0x32, 0x33, 0x34 + })] public void FromBitReader_CreatesCorrectlyFromBitReader(string expectedValue, short bitLength, byte[] bytes) { // Arrange diff --git a/test/NLightning.Bolt11.Tests/Models/TaggedFields/ExpiryTimeTaggedFieldTests.cs b/test/NLightning.Bolt11.Tests/Models/TaggedFields/ExpiryTimeTaggedFieldTests.cs index 70514176..8550aedc 100644 --- a/test/NLightning.Bolt11.Tests/Models/TaggedFields/ExpiryTimeTaggedFieldTests.cs +++ b/test/NLightning.Bolt11.Tests/Models/TaggedFields/ExpiryTimeTaggedFieldTests.cs @@ -1,8 +1,7 @@ -using NLightning.Domain.Utils; - namespace NLightning.Bolt11.Tests.Models.TaggedFields; using Bolt11.Models.TaggedFields; +using Domain.Utils; using Enums; public class ExpiryTimeTaggedFieldTests diff --git a/test/NLightning.Bolt11.Tests/Models/TaggedFields/FeaturesTaggedFieldTests.cs b/test/NLightning.Bolt11.Tests/Models/TaggedFields/FeaturesTaggedFieldTests.cs index fa82cc1a..ef377800 100644 --- a/test/NLightning.Bolt11.Tests/Models/TaggedFields/FeaturesTaggedFieldTests.cs +++ b/test/NLightning.Bolt11.Tests/Models/TaggedFields/FeaturesTaggedFieldTests.cs @@ -1,9 +1,8 @@ -using NLightning.Domain.Utils; - namespace NLightning.Bolt11.Tests.Models.TaggedFields; using Bolt11.Models.TaggedFields; using Domain.Node; +using Domain.Utils; using Enums; public class FeaturesTaggedFieldTests @@ -33,7 +32,8 @@ public void Constructor_FromValue_SetsPropertiesCorrectly(byte[] featureBits, sh [Theory] [InlineData(new byte[] { 9, 15 }, new byte[] { 0x82, 0x00 })] [InlineData(new byte[] { 8, 14, 48 }, new byte[] { 0x40, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00 })] - [InlineData(new byte[] { 8, 14, 99 }, new byte[] { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x00 })] + [InlineData(new byte[] { 8, 14, 99 }, + new byte[] { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x00 })] public void WriteToBitWriter_WritesCorrectData(byte[] featureBits, byte[] expectedData) { // Arrange @@ -42,6 +42,7 @@ public void WriteToBitWriter_WritesCorrectData(byte[] featureBits, byte[] expect { features.SetFeature(featureBit, true); } + var taggedField = new FeaturesTaggedField(features); var bitWriter = new BitWriter(taggedField.Length * 5); @@ -57,7 +58,8 @@ public void WriteToBitWriter_WritesCorrectData(byte[] featureBits, byte[] expect [Theory] [InlineData(new byte[] { 9, 15 }, 3, new byte[] { 0x82, 0x00 })] [InlineData(new byte[] { 8, 14, 48 }, 10, new byte[] { 0x40, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00 })] - [InlineData(new byte[] { 8, 14, 99 }, 20, new byte[] { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x00 })] + [InlineData(new byte[] { 8, 14, 99 }, 20, + new byte[] { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x00 })] public void FromBitReader_CreatesCorrectlyFromBitReader(byte[] featureBits, short bitLength, byte[] bytes) { // Arrange diff --git a/test/NLightning.Bolt11.Tests/Models/TaggedFields/MetadataTaggedFieldTests.cs b/test/NLightning.Bolt11.Tests/Models/TaggedFields/MetadataTaggedFieldTests.cs index 96ce9592..be305db5 100644 --- a/test/NLightning.Bolt11.Tests/Models/TaggedFields/MetadataTaggedFieldTests.cs +++ b/test/NLightning.Bolt11.Tests/Models/TaggedFields/MetadataTaggedFieldTests.cs @@ -1,8 +1,7 @@ -using NLightning.Domain.Utils; - namespace NLightning.Bolt11.Tests.Models.TaggedFields; using Bolt11.Models.TaggedFields; +using Domain.Utils; using Enums; public class MetadataTaggedFieldTests diff --git a/test/NLightning.Bolt11.Tests/Models/TaggedFields/MinFinalCltvExpiryTaggedFieldTests.cs b/test/NLightning.Bolt11.Tests/Models/TaggedFields/MinFinalCltvExpiryTaggedFieldTests.cs index 48cacb9b..62cff0b6 100644 --- a/test/NLightning.Bolt11.Tests/Models/TaggedFields/MinFinalCltvExpiryTaggedFieldTests.cs +++ b/test/NLightning.Bolt11.Tests/Models/TaggedFields/MinFinalCltvExpiryTaggedFieldTests.cs @@ -1,8 +1,7 @@ -using NLightning.Domain.Utils; - namespace NLightning.Bolt11.Tests.Models.TaggedFields; using Bolt11.Models.TaggedFields; +using Domain.Utils; using Enums; public class MinFinalCltvExpiryTaggedFieldTests diff --git a/test/NLightning.Bolt11.Tests/NLightning.Bolt11.Tests.csproj b/test/NLightning.Bolt11.Tests/NLightning.Bolt11.Tests.csproj index 4441edb9..37e815cb 100644 --- a/test/NLightning.Bolt11.Tests/NLightning.Bolt11.Tests.csproj +++ b/test/NLightning.Bolt11.Tests/NLightning.Bolt11.Tests.csproj @@ -1,45 +1,48 @@  - - net9.0 - enable - enable - false - Debug;Release;Debug.Native;Release.Native - AnyCPU - + + net10.0 + latest + enable + enable + AnyCPU + true + false + true + Debug;Release;Debug.Native;Release.Native + - - true - false - + + true + false + - - true - + + true + - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - - + + + - - - - - + + + + + diff --git a/test/NLightning.Domain.Tests/NLightning.Domain.Tests.csproj b/test/NLightning.Domain.Tests/NLightning.Domain.Tests.csproj index 1076d28a..edbf2b95 100644 --- a/test/NLightning.Domain.Tests/NLightning.Domain.Tests.csproj +++ b/test/NLightning.Domain.Tests/NLightning.Domain.Tests.csproj @@ -1,12 +1,15 @@  - net9.0 + net10.0 + latest enable enable + AnyCPU + true false + true Debug;Release;Debug.Native;Release.Native - AnyCPU @@ -19,17 +22,17 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/test/NLightning.Domain.Tests/ValueObjects/BigSizeTests.cs b/test/NLightning.Domain.Tests/ValueObjects/BigSizeTests.cs index e2c53d89..8ac97649 100644 --- a/test/NLightning.Domain.Tests/ValueObjects/BigSizeTests.cs +++ b/test/NLightning.Domain.Tests/ValueObjects/BigSizeTests.cs @@ -1,6 +1,7 @@ -using NLightning.Domain.Protocol.ValueObjects; - namespace NLightning.Domain.Tests.ValueObjects; + +using Domain.Protocol.ValueObjects; + public class BigSizeTests { [Theory] @@ -47,11 +48,13 @@ public void Given_ImplicitConversion_When_CastToSmallerSize_Then_ThrowsException break; case not null when type == typeof(ushort): var ushortException = Assert.Throws(() => (ushort)bigSize); - Assert.Equal($"Cannot convert {bigSize.Value} to ushort because it's too large.", ushortException.Message); + Assert.Equal($"Cannot convert {bigSize.Value} to ushort because it's too large.", + ushortException.Message); break; case not null when type == typeof(short): var shortException = Assert.Throws(() => (short)bigSize); - Assert.Equal($"Cannot convert {bigSize.Value} to short because it's too large.", shortException.Message); + Assert.Equal($"Cannot convert {bigSize.Value} to short because it's too large.", + shortException.Message); break; case not null when type == typeof(byte): var byteException = Assert.Throws(() => (byte)bigSize); @@ -220,7 +223,8 @@ public void Given_BigSize_When_CompareGreaterThan_Then_ResultIsKnown(ulong value [InlineData(0, 1, false)] [InlineData(1, 0, true)] [InlineData(1, 1, true)] - public void Given_BigSize_When_CompareGreaterThanOrEqual_Then_ResultIsKnown(ulong value1, ulong value2, bool expected) + public void Given_BigSize_When_CompareGreaterThanOrEqual_Then_ResultIsKnown( + ulong value1, ulong value2, bool expected) { // Arrange var bigSize1 = new BigSize(value1); diff --git a/test/NLightning.Domain.Tests/ValueObjects/BitcoinNetworkTests.cs b/test/NLightning.Domain.Tests/ValueObjects/BitcoinNetworkTests.cs index 85d8a7b6..390cb3e3 100644 --- a/test/NLightning.Domain.Tests/ValueObjects/BitcoinNetworkTests.cs +++ b/test/NLightning.Domain.Tests/ValueObjects/BitcoinNetworkTests.cs @@ -131,10 +131,10 @@ public void Builtin_Networks_ChainHash_Matches() [Fact] public void Unregistered_CustomNetwork_Throws() { - var net = new BitcoinNetwork("mycustomnet"); + var net = new BitcoinNetwork("myinvelidnet"); Assert.Throws(() => { - var _ = net.ChainHash; + _ = net.ChainHash; }); } diff --git a/test/NLightning.Domain.Tests/ValueObjects/ChainHashTests.cs b/test/NLightning.Domain.Tests/ValueObjects/ChainHashTests.cs index ab3771a4..6b1be203 100644 --- a/test/NLightning.Domain.Tests/ValueObjects/ChainHashTests.cs +++ b/test/NLightning.Domain.Tests/ValueObjects/ChainHashTests.cs @@ -1,6 +1,7 @@ -using NLightning.Domain.Protocol.ValueObjects; - namespace NLightning.Domain.Tests.ValueObjects; + +using Domain.Protocol.ValueObjects; + public class ChainHashTests { [Fact] diff --git a/test/NLightning.Domain.Tests/ValueObjects/ChannelIdTests.cs b/test/NLightning.Domain.Tests/ValueObjects/ChannelIdTests.cs index 00b01611..371917d4 100644 --- a/test/NLightning.Domain.Tests/ValueObjects/ChannelIdTests.cs +++ b/test/NLightning.Domain.Tests/ValueObjects/ChannelIdTests.cs @@ -1,6 +1,7 @@ -using NLightning.Domain.Channels.ValueObjects; - namespace NLightning.Domain.Tests.ValueObjects; + +using Domain.Channels.ValueObjects; + public class ChannelIdTests { [Fact] @@ -23,7 +24,9 @@ public void Given_TwoDifferentChannelIds_When_Compared_Then_AreNotEqual() { // Given var channelId1 = new ChannelId(new byte[32]); - var channelId2 = new ChannelId([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]); + var channelId2 = new ChannelId([ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 + ]); // When & Then Assert.False(channelId1 == channelId2); diff --git a/test/NLightning.Infrastructure.Bitcoin.Tests/NLightning.Infrastructure.Bitcoin.Tests.csproj b/test/NLightning.Infrastructure.Bitcoin.Tests/NLightning.Infrastructure.Bitcoin.Tests.csproj index 4d76b496..27523b25 100644 --- a/test/NLightning.Infrastructure.Bitcoin.Tests/NLightning.Infrastructure.Bitcoin.Tests.csproj +++ b/test/NLightning.Infrastructure.Bitcoin.Tests/NLightning.Infrastructure.Bitcoin.Tests.csproj @@ -1,12 +1,15 @@  - net9.0 + net10.0 + latest enable enable + AnyCPU + true false + true Debug;Release;Debug.Native;Release.Native - AnyCPU @@ -19,17 +22,17 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/AcceptChannel2MessageTypeSerializerTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/AcceptChannel2MessageTypeSerializerTests.cs index dac1813e..b5584369 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/AcceptChannel2MessageTypeSerializerTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/AcceptChannel2MessageTypeSerializerTests.cs @@ -176,7 +176,7 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT await _acceptChannel2TypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); @@ -222,7 +222,7 @@ public async Task Given_ValidExtension_When_SerializeAsync_Then_WritesCorrectDat await _acceptChannel2TypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/ChannelReadyMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/ChannelReadyMessageTests.cs index 69efc668..ea5baca5 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/ChannelReadyMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/ChannelReadyMessageTests.cs @@ -94,7 +94,7 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT await _channelReadyMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); @@ -119,7 +119,7 @@ public async Task Given_ValidExtension_When_SerializeAsync_Then_WritesCorrectDat await _channelReadyMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/ClosingSignedMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/ClosingSignedMessageTests.cs index 9041bdda..2ab6f755 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/ClosingSignedMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/ClosingSignedMessageTests.cs @@ -89,7 +89,7 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT await _closingSignedMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/CommitmentSignedMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/CommitmentSignedMessageTests.cs index dc2679ee..3b2e646a 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/CommitmentSignedMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/CommitmentSignedMessageTests.cs @@ -63,7 +63,7 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect await _commitmentSignedMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/ErrorMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/ErrorMessageTests.cs index 48eb931d..aff8f7f9 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/ErrorMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/ErrorMessageTests.cs @@ -25,7 +25,8 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsErrorMessa var expectedChannelId = ChannelId.Zero; var errorMessage = "Error message!"; var expectedData = Encoding.UTF8.GetBytes(errorMessage); - var stream = new MemoryStream(Convert.FromHexString("0000000000000000000000000000000000000000000000000000000000000000000E4572726F72206D65737361676521")); + var stream = new MemoryStream(Convert.FromHexString( + "0000000000000000000000000000000000000000000000000000000000000000000E4572726F72206D65737361676521")); // Act var message = await _errorMessageTypeSerializer.DeserializeAsync(stream); @@ -42,13 +43,15 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT // Arrange var message = new ErrorMessage(new ErrorPayload("Error message!")); var stream = new MemoryStream(); - var expectedBytes = Convert.FromHexString("0000000000000000000000000000000000000000000000000000000000000000000E4572726F72206D65737361676521"); + var expectedBytes = + Convert.FromHexString( + "0000000000000000000000000000000000000000000000000000000000000000000E4572726F72206D65737361676521"); // Act await _errorMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/InitMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/InitMessageTests.cs index 3f086fc0..e9c5805e 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/InitMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/InitMessageTests.cs @@ -23,14 +23,18 @@ public InitMessageTests() } [Fact] - public async Task Given_ValidStreamWithPayloadAndExtension_When_DeserializeAsync_Then_ReturnsInitMessageWithCorrectData() + public async Task + Given_ValidStreamWithPayloadAndExtension_When_DeserializeAsync_Then_ReturnsInitMessageWithCorrectData() { // Arrange var expectedPayload = new InitPayload(new FeatureSet()); var expectedExtension = new TlvStream(); var expectedTlv = new NetworksTlv([ChainConstants.Main]); expectedExtension.Add(expectedTlv); - var stream = new MemoryStream(Convert.FromHexString("000202000002020001206FE28C0AB6F1B372C1A6A246AE63F74F931E8365E15A089C68D6190000000000")); + var stream = + new MemoryStream( + Convert.FromHexString( + "000202000002020001206FE28C0AB6F1B372C1A6A246AE63F74F931E8365E15A089C68D6190000000000")); // Act var initMessage = await _initMessageTypeSerializer.DeserializeAsync(stream); @@ -67,7 +71,8 @@ public async Task Given_InvalidStreamContent_When_DeserializeAsync_Then_ThrowsMe var invalidStream = new MemoryStream(Convert.FromHexString("00020200000202000102")); // Act & Assert - await Assert.ThrowsAsync(() => _initMessageTypeSerializer.DeserializeAsync(invalidStream)); + await Assert.ThrowsAsync(() => _initMessageTypeSerializer.DeserializeAsync( + invalidStream)); } [Fact] @@ -76,13 +81,15 @@ public async Task Given_ValidPayloadAndExtension_When_SerializeAsync_Then_Writes // Arrange var message = new InitMessage(new InitPayload(new FeatureSet()), new NetworksTlv([ChainConstants.Main])); var stream = new MemoryStream(); - var expectedBytes = Convert.FromHexString("000202000002020001206FE28C0AB6F1B372C1A6A246AE63F74F931E8365E15A089C68D6190000000000"); + var expectedBytes = + Convert.FromHexString( + "000202000002020001206FE28C0AB6F1B372C1A6A246AE63F74F931E8365E15A089C68D6190000000000"); // Act await _initMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); @@ -100,7 +107,7 @@ public async Task Given_ValidPayloadOnly_When_SerializeAsync_Then_WritesCorrectD await _initMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/OpenChannel2MessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/OpenChannel2MessageTests.cs index 30595f35..8e3769a3 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/OpenChannel2MessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/OpenChannel2MessageTests.cs @@ -202,7 +202,7 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT await _openChannel2TypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); @@ -253,7 +253,7 @@ public async Task Given_ValidExtension_When_SerializeAsync_Then_WritesCorrectDat await _openChannel2TypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/PingMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/PingMessageTests.cs index 83fd057b..702ce687 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/PingMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/PingMessageTests.cs @@ -53,7 +53,7 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT await _pingMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/PongMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/PongMessageTests.cs index fe406d5b..0a13f9a2 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/PongMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/PongMessageTests.cs @@ -46,7 +46,7 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT await _pongMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/RevokeAndAckMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/RevokeAndAckMessageTests.cs index 2ec201bc..6c301768 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/RevokeAndAckMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/RevokeAndAckMessageTests.cs @@ -59,7 +59,7 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect await _revokeAndAckMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/ShutdownMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/ShutdownMessageTests.cs index 70108c19..df9d4cea 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/ShutdownMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/ShutdownMessageTests.cs @@ -53,7 +53,7 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect await _shutdownMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/StfuMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/StfuMessageTests.cs index 47b3de57..4f6c8ec4 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/StfuMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/StfuMessageTests.cs @@ -24,7 +24,9 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsStfuMessag var expectedChannelId = ChannelId.Zero; var expectedInitiator = true; - var stream = new MemoryStream(Convert.FromHexString("000000000000000000000000000000000000000000000000000000000000000001")); + var stream = + new MemoryStream( + Convert.FromHexString("000000000000000000000000000000000000000000000000000000000000000001")); // Act var message = await _stfuMessageTypeSerializer.DeserializeAsync(stream); @@ -48,7 +50,7 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect await _stfuMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAbortMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAbortMessageTests.cs index 28d3b943..e865a18b 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAbortMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAbortMessageTests.cs @@ -23,7 +23,9 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsTxAbortMes // Arrange var expectedChannelId = ChannelId.Zero; var expectedData = "Some error"u8.ToArray(); - var stream = new MemoryStream(Convert.FromHexString("0000000000000000000000000000000000000000000000000000000000000000000A536F6D65206572726F72")); + var stream = + new MemoryStream(Convert.FromHexString( + "0000000000000000000000000000000000000000000000000000000000000000000A536F6D65206572726F72")); // Act var message = await _txAbortMessageTypeSerializer.DeserializeAsync(stream); @@ -42,13 +44,15 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect var data = "Some error"u8.ToArray(); var message = new TxAbortMessage(new TxAbortPayload(channelId, data)); var stream = new MemoryStream(); - var expectedBytes = Convert.FromHexString("0000000000000000000000000000000000000000000000000000000000000000000A536F6D65206572726F72"); + var expectedBytes = + Convert.FromHexString( + "0000000000000000000000000000000000000000000000000000000000000000000A536F6D65206572726F72"); // Act await _txAbortMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAckRbfMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAckRbfMessageTests.cs index 18fbf72b..0baa885d 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAckRbfMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAckRbfMessageTests.cs @@ -23,12 +23,14 @@ public TxAckRbfMessageTests() } #region Deserialize + [Fact] public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsTxAckRbfMessage() { // Arrange var expectedChannelId = ChannelId.Zero; - var stream = new MemoryStream(Convert.FromHexString("0000000000000000000000000000000000000000000000000000000000000000")); + var stream = + new MemoryStream(Convert.FromHexString("0000000000000000000000000000000000000000000000000000000000000000")); // Act var message = await _txAckRbfMessageTypeSerializer.DeserializeAsync(stream); @@ -45,7 +47,9 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsTxAckRbfMe // Arrange var expectedChannelId = ChannelId.Zero; var expectedTlv = new FundingOutputContributionTlv(LightningMoney.Satoshis(10)); - var stream = new MemoryStream(Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000008000000000000000A0200")); + var stream = + new MemoryStream(Convert.FromHexString( + "00000000000000000000000000000000000000000000000000000000000000000008000000000000000A0200")); // Act var message = await _txAckRbfMessageTypeSerializer.DeserializeAsync(stream); @@ -63,14 +67,19 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsTxAckRbfMe public async Task Given_InvalidStreamContent_When_DeserializeAsync_Then_ThrowsMessageSerializationException() { // Arrange - var invalidStream = new MemoryStream(Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000002")); + var invalidStream = + new MemoryStream( + Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000002")); // Act & Assert - await Assert.ThrowsAsync(() => _txAckRbfMessageTypeSerializer.DeserializeAsync(invalidStream)); + await Assert.ThrowsAsync(() => _txAckRbfMessageTypeSerializer.DeserializeAsync( + invalidStream)); } + #endregion #region Serialize + [Fact] public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataToStream() { @@ -84,7 +93,7 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT await _txAckRbfMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); @@ -97,18 +106,22 @@ public async Task Given_ValidExtensions_When_SerializeAsync_Then_WritesCorrectDa var channelId = ChannelId.Zero; var fundingOutputContributionTlv = new FundingOutputContributionTlv(LightningMoney.Satoshis(10)); var requireConfirmedInputsTlv = new RequireConfirmedInputsTlv(); - var message = new TxAckRbfMessage(new TxAckRbfPayload(channelId), fundingOutputContributionTlv, requireConfirmedInputsTlv); + var message = new TxAckRbfMessage(new TxAckRbfPayload(channelId), fundingOutputContributionTlv, + requireConfirmedInputsTlv); var stream = new MemoryStream(); - var expectedBytes = Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000008000000000000000A0200"); + var expectedBytes = + Convert.FromHexString( + "00000000000000000000000000000000000000000000000000000000000000000008000000000000000A0200"); // Act await _txAckRbfMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); } + #endregion } \ No newline at end of file diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAddInputMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAddInputMessageTests.cs index 308213cd..5bf54f53 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAddInputMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAddInputMessageTests.cs @@ -60,7 +60,7 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect await _txAddInputMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAddOutputMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAddOutputMessageTests.cs index 61bcff50..f3ac326e 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAddOutputMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxAddOutputMessageTests.cs @@ -58,7 +58,7 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect await _txAddOutputMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxChannelReestablishMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxChannelReestablishMessageTests.cs index e4ded44f..1db9fa3b 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxChannelReestablishMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxChannelReestablishMessageTests.cs @@ -118,7 +118,7 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT await _channelReestablishMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); @@ -149,7 +149,7 @@ public async Task Given_ValidExtensions_When_SerializeAsync_Then_WritesCorrectDa await _channelReestablishMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxCompleteMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxCompleteMessageTests.cs index 7fbaafac..ac9a87a4 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxCompleteMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxCompleteMessageTests.cs @@ -22,7 +22,8 @@ public async Task DeserializeAsync_GivenValidStream_ReturnsTxCompleteMessage() { // Arrange var expectedChannelId = ChannelId.Zero; - var stream = new MemoryStream(Convert.FromHexString("0000000000000000000000000000000000000000000000000000000000000000")); + var stream = + new MemoryStream(Convert.FromHexString("0000000000000000000000000000000000000000000000000000000000000000")); // Act var message = await _txCompleteMessageTypeSerializer.DeserializeAsync(stream); @@ -45,7 +46,7 @@ public async Task SerializeAsync_GivenValidPayload_WritesCorrectDataToStream() await _txCompleteMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxInitRbfMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxInitRbfMessageTests.cs index 584c4f26..72e5022c 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxInitRbfMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxInitRbfMessageTests.cs @@ -106,7 +106,7 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT await _txInitRbfMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); @@ -132,7 +132,7 @@ public async Task Given_ValidExtension_When_SerializeAsync_Then_WritesCorrectDat await _txInitRbfMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxRemoveInputMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxRemoveInputMessageTests.cs index e416bac0..dd7a17fe 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxRemoveInputMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxRemoveInputMessageTests.cs @@ -52,7 +52,7 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect await _txRemoveInputMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxRemoveOutputMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxRemoveOutputMessageTests.cs index 9287f5a2..afb8962a 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxRemoveOutputMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxRemoveOutputMessageTests.cs @@ -51,7 +51,7 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect await _txRemoveOutputMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxSignaturesMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxSignaturesMessageTests.cs index 4191d640..cf6764cd 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxSignaturesMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/TxSignaturesMessageTests.cs @@ -62,7 +62,7 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect await _txSignaturesMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateAddHtlcMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateAddHtlcMessageTests.cs index d558fec6..1aace563 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateAddHtlcMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateAddHtlcMessageTests.cs @@ -141,7 +141,7 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT await _updateAddHtlcMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); @@ -169,7 +169,7 @@ public async Task Given_ValidPayloadWithOnionPacket_When_SerializeAsync_Then_Wri await _updateAddHtlcMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); @@ -197,7 +197,7 @@ public async Task Given_ValidPayloadAndExtensions_When_SerializeAsync_Then_Write await _updateAddHtlcMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFailHtlcMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFailHtlcMessageTests.cs index d7a54ba2..3db1a8da 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFailHtlcMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFailHtlcMessageTests.cs @@ -18,6 +18,7 @@ public UpdateFailHtlcMessageTests() } #region Deserialize + [Fact] public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsUpdateFailHtlcMessage() { @@ -26,7 +27,8 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsUpdateFail var expectedId = 0UL; var expectedReason = Convert.FromHexString("567cbdadb00b825448b2e414487d73"); var expectedLen = expectedReason.Length; - var stream = new MemoryStream(Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000000000000000000000F567CBDADB00B825448B2E414487D73")); + var stream = new MemoryStream(Convert.FromHexString( + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000F567CBDADB00B825448B2E414487D73")); // Act var message = await _updateFailHtlcMessageTypeSerializer.DeserializeAsync(stream); @@ -38,9 +40,11 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsUpdateFail Assert.Equal(expectedReason, message.Payload.Reason); Assert.Null(message.Extension); } + #endregion #region Serialize + [Fact] public async Task Given_ValidPayloadWith_When_SerializeAsync_Then_WritesCorrectDataToStream() { @@ -50,16 +54,19 @@ public async Task Given_ValidPayloadWith_When_SerializeAsync_Then_WritesCorrectD var expectedReason = Convert.FromHexString("567cbdadb00b825448b2e414487d73"); var message = new UpdateFailHtlcMessage(new UpdateFailHtlcPayload(channelId, id, expectedReason)); var stream = new MemoryStream(); - var expectedBytes = Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000000000000000000000F567CBDADB00B825448B2E414487D73"); + var expectedBytes = + Convert.FromHexString( + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000F567CBDADB00B825448B2E414487D73"); // Act await _updateFailHtlcMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); } + #endregion } \ No newline at end of file diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFailMalformedHtlcMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFailMalformedHtlcMessageTests.cs index dd9d5ba0..ec574169 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFailMalformedHtlcMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFailMalformedHtlcMessageTests.cs @@ -18,6 +18,7 @@ public UpdateFailMalformedHtlcMessageTests() } #region Deserialize + [Fact] public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsUpdateFailMalformedHtlcMessage() { @@ -26,7 +27,8 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsUpdateFail var expectedId = 0UL; var expectedSha256OfOnion = new byte[32]; ushort expectedFailureCode = 1; - var stream = new MemoryStream(Convert.FromHexString("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001")); + var stream = new MemoryStream(Convert.FromHexString( + "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001")); // Act var message = await _updateFailMalformedHtlcMessageTypeSerializer.DeserializeAsync(stream); @@ -38,9 +40,11 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsUpdateFail Assert.Equal(expectedFailureCode, message.Payload.FailureCode); Assert.Null(message.Extension); } + #endregion #region Serialize + [Fact] public async Task Given_ValidPayloadWith_When_SerializeAsync_Then_WritesCorrectDataToStream() { @@ -50,18 +54,21 @@ public async Task Given_ValidPayloadWith_When_SerializeAsync_Then_WritesCorrectD var sha256OfOnion = new byte[32]; ushort failureCode = 1; var message = new UpdateFailMalformedHtlcMessage(new UpdateFailMalformedHtlcPayload(channelId, failureCode, id, - sha256OfOnion)); + sha256OfOnion)); var stream = new MemoryStream(); - var expectedBytes = Convert.FromHexString("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"); + var expectedBytes = + Convert.FromHexString( + "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"); // Act await _updateFailMalformedHtlcMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); } + #endregion } \ No newline at end of file diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFeeMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFeeMessageTests.cs index 6cd95acd..162735d3 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFeeMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFeeMessageTests.cs @@ -24,7 +24,9 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsUpdateFeeM var expectedChannelId = ChannelId.Zero; var expectedFeeratePerKw = 10U; - var stream = new MemoryStream(Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000000000A")); + var stream = + new MemoryStream( + Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000000000A")); // Act var message = await _updateFeeMessageTypeSerializer.DeserializeAsync(stream); @@ -43,13 +45,14 @@ public async Task Given_GivenValidPayload_When_SerializeAsync_Then_WritesCorrect var feeratePerKw = 10U; var message = new UpdateFeeMessage(new UpdateFeePayload(channelId, feeratePerKw)); var stream = new MemoryStream(); - var expectedBytes = Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000000000A"); + var expectedBytes = + Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000000000A"); // Act await _updateFeeMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFulfillHtlcMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFulfillHtlcMessageTests.cs index 94492fab..1ca9dbe2 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFulfillHtlcMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/UpdateFulfillHtlcMessageTests.cs @@ -18,14 +18,17 @@ public UpdateFulfillHtlcMessageTests() } #region Deserialize + [Fact] public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsUpdateFulfillHtlcMessage() { // Arrange var expectedChannelId = ChannelId.Zero; var expectedId = 0UL; - var expectedPaymentPreimage = Convert.FromHexString("567cbdadb00b825448b2e414487d73a97f657f0634166d3ab3f3a2cc1042eda5"); - var stream = new MemoryStream(Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000000000000000000567CBDADB00B825448B2E414487D73A97F657F0634166D3AB3F3A2CC1042EDA5")); + var expectedPaymentPreimage = + Convert.FromHexString("567cbdadb00b825448b2e414487d73a97f657f0634166d3ab3f3a2cc1042eda5"); + var stream = new MemoryStream(Convert.FromHexString( + "00000000000000000000000000000000000000000000000000000000000000000000000000000000567CBDADB00B825448B2E414487D73A97F657F0634166D3AB3F3A2CC1042EDA5")); // Act var message = await _fulfillHtlcMessageTypeSerializer.DeserializeAsync(stream); @@ -36,9 +39,11 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsUpdateFulf Assert.Equal(expectedPaymentPreimage, message.Payload.PaymentPreimage); Assert.Null(message.Extension); } + #endregion #region Serialize + [Fact] public async Task Given_ValidPayloadWith_When_SerializeAsync_Then_WritesCorrectDataToStream() { @@ -48,16 +53,19 @@ public async Task Given_ValidPayloadWith_When_SerializeAsync_Then_WritesCorrectD var paymentPreimage = Convert.FromHexString("567cbdadb00b825448b2e414487d73a97f657f0634166d3ab3f3a2cc1042eda5"); var message = new UpdateFulfillHtlcMessage(new UpdateFulfillHtlcPayload(channelId, id, paymentPreimage)); var stream = new MemoryStream(); - var expectedBytes = Convert.FromHexString("00000000000000000000000000000000000000000000000000000000000000000000000000000000567CBDADB00B825448B2E414487D73A97F657F0634166D3AB3F3A2CC1042EDA5"); + var expectedBytes = + Convert.FromHexString( + "00000000000000000000000000000000000000000000000000000000000000000000000000000000567CBDADB00B825448B2E414487D73A97F657F0634166D3AB3F3A2CC1042EDA5"); // Act await _fulfillHtlcMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); } + #endregion } \ No newline at end of file diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Messages/WarningMessageTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Messages/WarningMessageTests.cs index 34132747..7f3f3049 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Messages/WarningMessageTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Messages/WarningMessageTests.cs @@ -20,7 +20,8 @@ public async Task Given_ValidStream_When_DeserializeAsync_Then_ReturnsWarningMes { // Arrange var expectedPayload = new ErrorPayload("Warning message!"); - var stream = new MemoryStream(Convert.FromHexString("000000000000000000000000000000000000000000000000000000000000000000105761726E696E67206D65737361676521")); + var stream = new MemoryStream(Convert.FromHexString( + "000000000000000000000000000000000000000000000000000000000000000000105761726E696E67206D65737361676521")); // Act var errorMessage = await _warningMessageTypeSerializer.DeserializeAsync(stream); @@ -37,13 +38,15 @@ public async Task Given_ValidPayload_When_SerializeAsync_Then_WritesCorrectDataT // Arrange var message = new WarningMessage(new ErrorPayload("Warning message!")); var stream = new MemoryStream(); - var expectedBytes = Convert.FromHexString("000000000000000000000000000000000000000000000000000000000000000000105761726E696E67206D65737361676521"); + var expectedBytes = + Convert.FromHexString( + "000000000000000000000000000000000000000000000000000000000000000000105761726E696E67206D65737361676521"); // Act await _warningMessageTypeSerializer.SerializeAsync(message, stream); stream.Position = 0; var result = new byte[stream.Length]; - _ = await stream.ReadAsync(result); + _ = await stream.ReadAsync(result, TestContext.Current.CancellationToken); // Assert Assert.Equal(expectedBytes, result); diff --git a/test/NLightning.Infrastructure.Serialization.Tests/NLightning.Infrastructure.Serialization.Tests.csproj b/test/NLightning.Infrastructure.Serialization.Tests/NLightning.Infrastructure.Serialization.Tests.csproj index ea79d1d6..f504066e 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/NLightning.Infrastructure.Serialization.Tests.csproj +++ b/test/NLightning.Infrastructure.Serialization.Tests/NLightning.Infrastructure.Serialization.Tests.csproj @@ -1,12 +1,15 @@  - net9.0 + net10.0 + latest enable enable + AnyCPU + true false + true Debug;Release;Debug.Native;Release.Native - AnyCPU @@ -19,17 +22,17 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Payloads/ErrorPayloadSerializerTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Payloads/ErrorPayloadSerializerTests.cs index cd1494b7..55641464 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Payloads/ErrorPayloadSerializerTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Payloads/ErrorPayloadSerializerTests.cs @@ -23,7 +23,7 @@ public async Task Given_ValidPayload_When_Serializing_Then_ReturnsCorrectValues( // Then memoryStream.Seek(0, SeekOrigin.Begin); var expectedLengthBytes = new byte[2]; - _ = await memoryStream.ReadAsync(expectedLengthBytes.AsMemory(0, 2)); + _ = await memoryStream.ReadAsync(expectedLengthBytes.AsMemory(0, 2), TestContext.Current.CancellationToken); Assert.Equal(0, EndianBitConverter.ToUInt16BigEndian(expectedLengthBytes)); } diff --git a/test/NLightning.Infrastructure.Serialization.Tests/Tlv/TlvSerializerTests.cs b/test/NLightning.Infrastructure.Serialization.Tests/Tlv/TlvSerializerTests.cs index 1fb75286..87a7feee 100644 --- a/test/NLightning.Infrastructure.Serialization.Tests/Tlv/TlvSerializerTests.cs +++ b/test/NLightning.Infrastructure.Serialization.Tests/Tlv/TlvSerializerTests.cs @@ -26,7 +26,7 @@ public async Task Given_TlvSerializer_When_SerializingBaseTlv_Then_BufferIsCorre await _tlvSerializer.SerializeAsync(baseTlv, stream); stream.Position = 0; var buffer = new byte[stream.Length]; - await stream.ReadExactlyAsync(buffer, 0, (int)stream.Length); + await stream.ReadExactlyAsync(buffer, 0, (int)stream.Length, TestContext.Current.CancellationToken); // Then Assert.Equal(expectedBuffer, buffer); @@ -188,5 +188,4 @@ public async Task Given_TlvSerializer_When_DeserializingBaseTlv_Then_BufferIsCor // Assert.Equal(shortChannelIdTlv.ShortChannelId, deserializedTlv.ShortChannelId); // } // - } \ No newline at end of file diff --git a/test/NLightning.Infrastructure.Tests/NLightning.Infrastructure.Tests.csproj b/test/NLightning.Infrastructure.Tests/NLightning.Infrastructure.Tests.csproj index a92ef90d..436fbd4e 100644 --- a/test/NLightning.Infrastructure.Tests/NLightning.Infrastructure.Tests.csproj +++ b/test/NLightning.Infrastructure.Tests/NLightning.Infrastructure.Tests.csproj @@ -1,12 +1,15 @@  - net9.0 + net10.0 + latest enable enable + AnyCPU + true false + true Debug;Release;Debug.Native;Release.Native - AnyCPU @@ -20,17 +23,17 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/test/NLightning.Infrastructure.Tests/Protocol/Services/MessageServiceTests.cs b/test/NLightning.Infrastructure.Tests/Protocol/Services/MessageServiceTests.cs index ec765323..d3c76e9d 100644 --- a/test/NLightning.Infrastructure.Tests/Protocol/Services/MessageServiceTests.cs +++ b/test/NLightning.Infrastructure.Tests/Protocol/Services/MessageServiceTests.cs @@ -28,7 +28,8 @@ public async Task Given_Message_When_SendMessageAsync_IsCalled_Then_TransportSer var messageMock = new Mock(); // When - await messageService.SendMessageAsync(messageMock.Object); + await messageService.SendMessageAsync(messageMock.Object, + cancellationToken: TestContext.Current.CancellationToken); // Then transportServiceMock.Verify(t => t.WriteMessageAsync(messageMock.Object, It.IsAny()), @@ -108,7 +109,8 @@ public async Task Given_DisposedMessageService_When_SendMessageAsync_IsCalled_Th // Then var exception = await Assert.ThrowsAsync(() => messageService.SendMessageAsync( - messageMock.Object, true)); + messageMock.Object, true, + TestContext.Current.CancellationToken)); Assert.IsType(exception.InnerException); } } \ No newline at end of file diff --git a/test/NLightning.Infrastructure.Tests/Transport/Services/TransportServiceTests.cs b/test/NLightning.Infrastructure.Tests/Transport/Services/TransportServiceTests.cs index 9f045cd7..53c4cfae 100644 --- a/test/NLightning.Infrastructure.Tests/Transport/Services/TransportServiceTests.cs +++ b/test/NLightning.Infrastructure.Tests/Transport/Services/TransportServiceTests.cs @@ -78,8 +78,9 @@ public async Task buffer = new byte[66]; await stream.ReadExactlyAsync(buffer); - }); - await tcpClient1.ConnectAsync(IPEndPoint.Parse(tcpListener.LocalEndpoint.ToEndpointString())); + }, TestContext.Current.CancellationToken); + await tcpClient1.ConnectAsync(IPEndPoint.Parse(tcpListener.LocalEndpoint.ToEndpointString()), + TestContext.Current.CancellationToken); var transportService = new TransportService(_mockLogger.Object, messageSerializerMock.Object, TimeSpan.FromSeconds(30), handshakeServiceMock.Object, tcpClient1); @@ -160,8 +161,9 @@ public async Task Given_TransportService_When_TimeoutOccurs_Then_ThrowsConnectio await stream.ReadExactlyAsync(buffer); await stream.WriteAsync(buffer); - }); - await tcpClient1.ConnectAsync(IPEndPoint.Parse(tcpListener.LocalEndpoint.ToEndpointString())); + }, TestContext.Current.CancellationToken); + await tcpClient1.ConnectAsync(IPEndPoint.Parse(tcpListener.LocalEndpoint.ToEndpointString()), + TestContext.Current.CancellationToken); var transportService = new TransportService(_mockLogger.Object, messageSerializerMock.Object, TimeSpan.Zero, handshakeServiceMock.Object, tcpClient1); diff --git a/test/NLightning.Integration.Tests/Docker/AbcNetworkTests.cs b/test/NLightning.Integration.Tests/Docker/AbcNetworkTests.cs index 1f49a186..1068498c 100644 --- a/test/NLightning.Integration.Tests/Docker/AbcNetworkTests.cs +++ b/test/NLightning.Integration.Tests/Docker/AbcNetworkTests.cs @@ -14,7 +14,6 @@ using NLightning.Tests.Utils; using ServiceStack; using ServiceStack.Text; -using Xunit.Abstractions; namespace NLightning.Integration.Tests.Docker; @@ -180,13 +179,17 @@ public async Task NLightning_BOLT8_Test_Connect_Alice() var aliceHost = new IPEndPoint((await Dns.GetHostAddressesAsync(alice.Host .SplitOnFirst("//")[1] - .SplitOnFirst(":")[0])).First(), 9735); + .SplitOnFirst(":")[0], + TestContext.Current.CancellationToken)).First(), + 9735); // Act await _peerManager.ConnectToPeerAsync( new PeerAddressInfo( $"{Convert.ToHexString(alice.LocalNodePubKeyBytes)}@{aliceHost.Address}:{aliceHost.Port}")); - var alicePeers = alice.LightningClient.ListPeers(new ListPeersRequest()); + var alicePeers = + alice.LightningClient.ListPeers(new ListPeersRequest(), + cancellationToken: TestContext.Current.CancellationToken); // Assert Assert.NotNull(alicePeers.Peers.FirstOrDefault(x => x.PubKey @@ -225,8 +228,9 @@ await bob.LightningClient.ConnectPeerAsync(new ConnectPeerRequest Host = $"{hostAddress}:{_port}", Pubkey = hex } - }); - var bobPeers = bob.LightningClient.ListPeers(new ListPeersRequest()); + }, cancellationToken: TestContext.Current.CancellationToken); + var bobPeers = bob.LightningClient.ListPeers(new ListPeersRequest(), + cancellationToken: TestContext.Current.CancellationToken); // Assert Assert.True(await taskCompletionSource.Task); @@ -246,8 +250,12 @@ public async Task Verify_Alice_Bob_Carol_Setup() $"LND Nodes in Ready State: {nodeCount}".Print(); foreach (var node in readyNodes) { - var walletBalanceResponse = await node.LightningClient.WalletBalanceAsync(new WalletBalanceRequest()); - var channels = await node.LightningClient.ListChannelsAsync(new ListChannelsRequest()); + var walletBalanceResponse = + await node.LightningClient.WalletBalanceAsync(new WalletBalanceRequest(), + cancellationToken: TestContext.Current.CancellationToken); + var channels = + await node.LightningClient.ListChannelsAsync(new ListChannelsRequest(), + cancellationToken: TestContext.Current.CancellationToken); $"Node {node.LocalAlias} ({node.LocalNodePubKey})".Print(); walletBalanceResponse.PrintDump(); channels.PrintDump(); diff --git a/test/NLightning.Integration.Tests/Docker/Utils/TestOutputWriter.cs b/test/NLightning.Integration.Tests/Docker/Utils/TestOutputWriter.cs index b636afb9..5c600f45 100644 --- a/test/NLightning.Integration.Tests/Docker/Utils/TestOutputWriter.cs +++ b/test/NLightning.Integration.Tests/Docker/Utils/TestOutputWriter.cs @@ -1,5 +1,4 @@ using System.Text; -using Xunit.Abstractions; namespace NLightning.Integration.Tests.Docker.Utils; diff --git a/test/NLightning.Integration.Tests/NLightning.Integration.Tests.csproj b/test/NLightning.Integration.Tests/NLightning.Integration.Tests.csproj index d643320c..bcf81edc 100644 --- a/test/NLightning.Integration.Tests/NLightning.Integration.Tests.csproj +++ b/test/NLightning.Integration.Tests/NLightning.Integration.Tests.csproj @@ -1,12 +1,15 @@  - net9.0 + net10.0 + latest enable enable + AnyCPU + true false + true Debug;Release;Debug.Native;Release.Native - AnyCPU @@ -19,17 +22,17 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/test/NLightning.Node.Tests/Models/FeeRateCacheDataTests.cs b/test/NLightning.Node.Tests/Models/FeeRateCacheDataTests.cs index aa360d54..8b690458 100644 --- a/test/NLightning.Node.Tests/Models/FeeRateCacheDataTests.cs +++ b/test/NLightning.Node.Tests/Models/FeeRateCacheDataTests.cs @@ -32,8 +32,12 @@ public void Given_FeeRateCacheData_When_SerializedAndDeserialized_Then_DataIsPre }; // When - var serializedData = MessagePackSerializer.Serialize(originalData); - var deserializedData = MessagePackSerializer.Deserialize(serializedData); + var serializedData = + MessagePackSerializer.Serialize(originalData, cancellationToken: TestContext.Current.CancellationToken); + var deserializedData = + MessagePackSerializer.Deserialize(serializedData, + cancellationToken: TestContext.Current + .CancellationToken); // Then Assert.Equal(originalData.FeeRate, deserializedData.FeeRate); diff --git a/test/NLightning.Node.Tests/NLightning.Node.Tests.csproj b/test/NLightning.Node.Tests/NLightning.Node.Tests.csproj index 772832cd..17d679e0 100644 --- a/test/NLightning.Node.Tests/NLightning.Node.Tests.csproj +++ b/test/NLightning.Node.Tests/NLightning.Node.Tests.csproj @@ -1,28 +1,32 @@  - - net9.0 - enable - enable - false - + + net10.0 + latest + enable + enable + AnyCPU + true + false + true + - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - - + + + diff --git a/test/NLightning.Node.Tests/Services/FeeServiceTests.cs b/test/NLightning.Node.Tests/Services/FeeServiceTests.cs index a3fb631c..44c80807 100644 --- a/test/NLightning.Node.Tests/Services/FeeServiceTests.cs +++ b/test/NLightning.Node.Tests/Services/FeeServiceTests.cs @@ -35,7 +35,7 @@ public async Task GivenValidCache_WhenGetFeeRatePerKwAsync_ThenReturnsCachedValu ctsField.SetValue(feeService, null); // Act - var result = await feeService.GetFeeRatePerKwAsync(); + var result = await feeService.GetFeeRatePerKwAsync(TestContext.Current.CancellationToken); // Assert Assert.Equal(cachedFeeRate, result); @@ -65,7 +65,7 @@ public async Task GivenInvalidCache_WhenGetFeeRatePerKwAsync_ThenRefreshesAndRet Assert.NotNull(ctsField); ctsField.SetValue(feeService, null); // Act - var result = await feeService.GetFeeRatePerKwAsync(); + var result = await feeService.GetFeeRatePerKwAsync(TestContext.Current.CancellationToken); // Assert Assert.Equal(2000, result.Satoshi); diff --git a/test/NLightning.Tests.Utils/NLightning.Tests.Utils.csproj b/test/NLightning.Tests.Utils/NLightning.Tests.Utils.csproj index 842fe1c4..5d4e4036 100644 --- a/test/NLightning.Tests.Utils/NLightning.Tests.Utils.csproj +++ b/test/NLightning.Tests.Utils/NLightning.Tests.Utils.csproj @@ -1,13 +1,15 @@  - net9.0 + net10.0 latest enable enable + AnyCPU + true + false 0.0.1 Debug;Release;Debug.Native;Release.Native - AnyCPU @@ -30,8 +32,7 @@ - - +