From fe121ce40c673a50b053c7d7ca42ecf948a940cf Mon Sep 17 00:00:00 2001 From: Apolixit Date: Sat, 20 Apr 2024 15:30:06 +0200 Subject: [PATCH 1/2] Update nuget package versions --- .../MetadataServiceV10Test.cs | 4 ++-- .../MetadataServiceV11Test.cs | 4 ++-- .../MetadataServiceV12Test.cs | 22 +++++++++---------- .../MetadataServiceV13Test.cs | 18 +++++++-------- .../MetadataServiceV14Test.cs | 20 ++++++++--------- .../MetadataServiceV9Test.cs | 4 ++-- .../Substrate.NET.Metadata.Tests.csproj | 18 ++++++++++----- .../Substrate.NET.Metadata.csproj | 4 ++-- 8 files changed, 50 insertions(+), 44 deletions(-) diff --git a/Substrate.NET.Metadata.Tests/MetadataServiceV10Test.cs b/Substrate.NET.Metadata.Tests/MetadataServiceV10Test.cs index a54526f..ca3579e 100644 --- a/Substrate.NET.Metadata.Tests/MetadataServiceV10Test.cs +++ b/Substrate.NET.Metadata.Tests/MetadataServiceV10Test.cs @@ -58,8 +58,8 @@ public void MetadataV10_V1039_And_V1040_PalletHasChanged_ShouldSucceed() var metadataSource = readMetadataFromFile("V10\\MetadataV10_Kusama_1039"); var metadataDestination = readMetadataFromFile("V10\\MetadataV10_Kusama_1040"); - Assert.IsFalse(_metadataService.HasPalletChangedVersionBetween("Society", metadataSource, metadataDestination)); - Assert.IsFalse(_metadataService.HasPalletChangedVersionBetween("Balances", metadataSource, metadataDestination)); + Assert.That(_metadataService.HasPalletChangedVersionBetween("Society", metadataSource, metadataDestination), Is.False); + Assert.That(_metadataService.HasPalletChangedVersionBetween("Balances", metadataSource, metadataDestination), Is.False); } } } diff --git a/Substrate.NET.Metadata.Tests/MetadataServiceV11Test.cs b/Substrate.NET.Metadata.Tests/MetadataServiceV11Test.cs index a72ca4c..5c5c0d0 100644 --- a/Substrate.NET.Metadata.Tests/MetadataServiceV11Test.cs +++ b/Substrate.NET.Metadata.Tests/MetadataServiceV11Test.cs @@ -133,10 +133,10 @@ public void MetadataV11_V23_And_V24_PalletHasChanged_ShouldSucceed() var metadataSource = readMetadataFromFile("V11\\MetadataV11_23"); var metadataDestination = readMetadataFromFile("V11\\MetadataV11_24"); - Assert.IsTrue(_metadataService.HasPalletChangedVersionBetween("Multisig", metadataSource, metadataDestination)); + Assert.That(_metadataService.HasPalletChangedVersionBetween("Multisig", metadataSource, metadataDestination), Is.True); // Purschase has been removed, but does not count as changed - Assert.IsFalse(_metadataService.HasPalletChangedVersionBetween("Purchase", metadataSource, metadataDestination)); + Assert.That(_metadataService.HasPalletChangedVersionBetween("Purchase", metadataSource, metadataDestination), Is.False); } } } diff --git a/Substrate.NET.Metadata.Tests/MetadataServiceV12Test.cs b/Substrate.NET.Metadata.Tests/MetadataServiceV12Test.cs index 264efe1..47c169c 100644 --- a/Substrate.NET.Metadata.Tests/MetadataServiceV12Test.cs +++ b/Substrate.NET.Metadata.Tests/MetadataServiceV12Test.cs @@ -40,7 +40,7 @@ public void MetadataV12_SpecVersionCompare_V27_And_V28_ShouldSucceed() Assert.That(changedModules[0].ModuleName, Is.EqualTo("Babe")); Assert.That(changedModules[0].Storage.First().Item2.status, Is.EqualTo(CompareStatus.Added)); Assert.That(changedModules[0].Storage.First().Item2.storage.Name.Value, Is.EqualTo("NextAuthorities")); - Assert.IsTrue(changedModules[0].HasStorageAdded("NextAuthorities")); + Assert.That(changedModules[0].HasStorageAdded("NextAuthorities"), Is.True); // Now let's test ElectionsPhragmen which changed a lot var electionPhragmenModule = changedModules[1]; @@ -53,32 +53,32 @@ public void MetadataV12_SpecVersionCompare_V27_And_V28_ShouldSucceed() var electionPhragmenCalls = electionPhragmenModule.Calls.ToList(); Assert.That(electionPhragmenCalls[0].Item1, Is.EqualTo(CompareStatus.Added)); Assert.That(electionPhragmenCalls[0].Item2.Name.Value, Is.EqualTo("clean_defunct_voters")); - Assert.IsTrue(electionPhragmenModule.HasCallAdded("clean_defunct_voters")); + Assert.That(electionPhragmenModule.HasCallAdded("clean_defunct_voters"), Is.True); Assert.That(electionPhragmenCalls[1].Item1, Is.EqualTo(CompareStatus.Removed)); Assert.That(electionPhragmenCalls[1].Item2.Name.Value, Is.EqualTo("report_defunct_voter")); - Assert.IsTrue(electionPhragmenModule.HasCallRemoved("report_defunct_voter")); + Assert.That(electionPhragmenModule.HasCallRemoved("report_defunct_voter"), Is.True); var electionPhragmenConstants = electionPhragmenModule.Constants.ToList(); Assert.That(electionPhragmenConstants[0].Item1, Is.EqualTo(CompareStatus.Added)); Assert.That(electionPhragmenConstants[0].Item2.Name.Value, Is.EqualTo("VotingBondBase")); - Assert.IsTrue(electionPhragmenModule.HasConstantAdded("VotingBondBase")); + Assert.That(electionPhragmenModule.HasConstantAdded("VotingBondBase"), Is.True); Assert.That(electionPhragmenConstants[1].Item1, Is.EqualTo(CompareStatus.Added)); Assert.That(electionPhragmenConstants[1].Item2.Name.Value, Is.EqualTo("VotingBondFactor")); Assert.That(electionPhragmenConstants[2].Item1, Is.EqualTo(CompareStatus.Removed)); Assert.That(electionPhragmenConstants[2].Item2.Name.Value, Is.EqualTo("VotingBond")); - Assert.IsTrue(electionPhragmenModule.HasConstantRemoved("VotingBond")); + Assert.That(electionPhragmenModule.HasConstantRemoved("VotingBond"), Is.True); var electionPhragmenEvents = electionPhragmenModule.Events.ToList(); Assert.That(electionPhragmenEvents[0].Item1, Is.EqualTo(CompareStatus.Added)); Assert.That(electionPhragmenEvents[0].Item2.Name.Value, Is.EqualTo("Renounced")); - Assert.IsTrue(electionPhragmenModule.HasEventAdded("Renounced")); + Assert.That(electionPhragmenModule.HasEventAdded("Renounced"), Is.True); Assert.That(electionPhragmenEvents[1].Item1, Is.EqualTo(CompareStatus.Removed)); Assert.That(electionPhragmenEvents[1].Item2.Name.Value, Is.EqualTo("MemberRenounced")); - Assert.IsTrue(electionPhragmenModule.HasEventRemoved("MemberRenounced")); + Assert.That(electionPhragmenModule.HasEventRemoved("MemberRenounced"), Is.True); Assert.That(electionPhragmenEvents[2].Item1, Is.EqualTo(CompareStatus.Removed)); Assert.That(electionPhragmenEvents[2].Item2.Name.Value, Is.EqualTo("VoterReported")); @@ -86,7 +86,7 @@ public void MetadataV12_SpecVersionCompare_V27_And_V28_ShouldSucceed() var electionPhragmenErrors = electionPhragmenModule.Errors.ToList(); Assert.That(electionPhragmenErrors[0].Item1, Is.EqualTo(CompareStatus.Added)); Assert.That(electionPhragmenErrors[0].Item2.Name.Value, Is.EqualTo("RunnerUpSubmit")); - Assert.IsTrue(electionPhragmenModule.HasErrorAdded("RunnerUpSubmit")); + Assert.That(electionPhragmenModule.HasErrorAdded("RunnerUpSubmit"), Is.True); Assert.That(electionPhragmenErrors[1].Item1, Is.EqualTo(CompareStatus.Added)); Assert.That(electionPhragmenErrors[1].Item2.Name.Value, Is.EqualTo("InvalidWitnessData")); @@ -96,7 +96,7 @@ public void MetadataV12_SpecVersionCompare_V27_And_V28_ShouldSucceed() Assert.That(electionPhragmenErrors[3].Item1, Is.EqualTo(CompareStatus.Removed)); Assert.That(electionPhragmenErrors[3].Item2.Name.Value, Is.EqualTo("InvalidCandidateCount")); - Assert.IsTrue(electionPhragmenModule.HasErrorRemoved("InvalidCandidateCount")); + Assert.That(electionPhragmenModule.HasErrorRemoved("InvalidCandidateCount"), Is.True); } [Test] @@ -105,9 +105,9 @@ public void MetadataV12_V27_And_V28_PalletHasChanged_ShouldSucceed() var metadataSource = readMetadataFromFile("V12\\MetadataV12_27"); var metadataDestination = readMetadataFromFile("V12\\MetadataV12_28"); - Assert.IsTrue(_metadataService.HasPalletChangedVersionBetween("ElectionsPhragmen", metadataSource, metadataDestination)); + Assert.That(_metadataService.HasPalletChangedVersionBetween("ElectionsPhragmen", metadataSource, metadataDestination), Is.True); - Assert.IsFalse(_metadataService.HasPalletChangedVersionBetween("Balances", metadataSource, metadataDestination)); + Assert.That(_metadataService.HasPalletChangedVersionBetween("Balances", metadataSource, metadataDestination), Is.False); } } } diff --git a/Substrate.NET.Metadata.Tests/MetadataServiceV13Test.cs b/Substrate.NET.Metadata.Tests/MetadataServiceV13Test.cs index e99c287..7b0e717 100644 --- a/Substrate.NET.Metadata.Tests/MetadataServiceV13Test.cs +++ b/Substrate.NET.Metadata.Tests/MetadataServiceV13Test.cs @@ -30,19 +30,19 @@ public void MetadataV13_SpecVersionCompare_V9080_And_V9090_ShouldSucceed() var changedModules = res.ChangedModules.ToList(); Assert.That(changedModules[0].ModuleName, Is.EqualTo("Authorship")); - Assert.IsTrue(changedModules[0].HasConstantAdded("UncleGenerations")); + Assert.That(changedModules[0].HasConstantAdded("UncleGenerations"), Is.True); Assert.That(changedModules[1].ModuleName, Is.EqualTo("Balances")); - Assert.IsTrue(changedModules[1].HasConstantAdded("MaxLocks")); - Assert.IsTrue(changedModules[1].HasConstantAdded("MaxReserves")); + Assert.That(changedModules[1].HasConstantAdded("MaxLocks"), Is.True); + Assert.That(changedModules[1].HasConstantAdded("MaxReserves"), Is.True); Assert.That(changedModules[2].ModuleName, Is.EqualTo("Democracy")); Assert.That(changedModules[2].Constants.Count(), Is.EqualTo(2)); - Assert.IsTrue(changedModules[2].HasConstantAdded("InstantAllowed")); - Assert.IsTrue(changedModules[2].HasConstantAdded("MaxProposals")); + Assert.That(changedModules[2].HasConstantAdded("InstantAllowed"), Is.True); + Assert.That(changedModules[2].HasConstantAdded("MaxProposals"), Is.True); Assert.That(changedModules[2].Errors.Count(), Is.EqualTo(5)); - Assert.IsFalse(changedModules[2].HasErrorAdded("test")); - Assert.IsFalse(changedModules[2].HasErrorRemoved("test2")); + Assert.That(changedModules[2].HasErrorAdded("test"), Is.False); + Assert.That(changedModules[2].HasErrorRemoved("test2"), Is.False); } [Test] @@ -51,8 +51,8 @@ public void MetadataV13_V9080_And_V9090_PalletHasChanged_ShouldSucceed() var metadataSource = readMetadataFromFile("V13\\MetadataV13_9080"); var metadataDestination = readMetadataFromFile("V13\\MetadataV13_9090"); - Assert.IsTrue(_metadataService.HasPalletChangedVersionBetween("Balances", metadataSource, metadataDestination)); - Assert.IsFalse(_metadataService.HasPalletChangedVersionBetween("Babe", metadataSource, metadataDestination)); + Assert.That(_metadataService.HasPalletChangedVersionBetween("Balances", metadataSource, metadataDestination), Is.True); + Assert.That(_metadataService.HasPalletChangedVersionBetween("Babe", metadataSource, metadataDestination), Is.False); } } } diff --git a/Substrate.NET.Metadata.Tests/MetadataServiceV14Test.cs b/Substrate.NET.Metadata.Tests/MetadataServiceV14Test.cs index cc7c553..1c0a4ad 100644 --- a/Substrate.NET.Metadata.Tests/MetadataServiceV14Test.cs +++ b/Substrate.NET.Metadata.Tests/MetadataServiceV14Test.cs @@ -58,9 +58,9 @@ public void MetadataV14_SpecVersionCompare_V9370_And_V9420_ShouldSucceed() Assert.That(res, Is.Not.Null); - Assert.IsTrue(res.AddedModules.Any(x => x.ModuleName == "ConvictionVoting")); - Assert.IsTrue(res.AddedModules.Any(x => x.ModuleName == "Referenda")); - Assert.IsTrue(res.AddedModules.Any(x => x.ModuleName == "Whitelist")); + Assert.That(res.AddedModules.Any(x => x.ModuleName == "ConvictionVoting"), Is.True); + Assert.That(res.AddedModules.Any(x => x.ModuleName == "Referenda"), Is.True); + Assert.That(res.AddedModules.Any(x => x.ModuleName == "Whitelist"), Is.True); // Some basic other assertions on Balance pallet I checked with file compare var palletBalance = res.ChangedModules.FirstOrDefault(x => x.ModuleName == "Balances"); @@ -69,12 +69,12 @@ public void MetadataV14_SpecVersionCompare_V9370_And_V9420_ShouldSucceed() // Some calls has been added and one has been removed var callsMethodChanged = palletBalance.Calls.LookupDifferentialType.TypeVariant.Elems; Assert.That(callsMethodChanged.Count(), Is.GreaterThan(1)); - Assert.IsTrue(callsMethodChanged.Any(x => x.Item1 == CompareStatus.Added && x.Item2.Name.Value == "set_balance_deprecated")); - Assert.IsTrue(callsMethodChanged.Any(x => x.Item1 == CompareStatus.Removed && x.Item2.Name.Value == "set_balance")); + Assert.That(callsMethodChanged.Any(x => x.Item1 == CompareStatus.Added && x.Item2.Name.Value == "set_balance_deprecated"), Is.True); + Assert.That(callsMethodChanged.Any(x => x.Item1 == CompareStatus.Removed && x.Item2.Name.Value == "set_balance"), Is.True); - Assert.IsTrue(callsMethodChanged.Any(x => x.Item1 == CompareStatus.Added && x.Item2.Name.Value == "transfer_allow_death")); - Assert.IsTrue(callsMethodChanged.Any(x => x.Item1 == CompareStatus.Added && x.Item2.Name.Value == "set_balance_deprecated")); - Assert.IsTrue(callsMethodChanged.Any(x => x.Item1 == CompareStatus.Added && x.Item2.Name.Value == "force_set_balance")); + Assert.That(callsMethodChanged.Any(x => x.Item1 == CompareStatus.Added && x.Item2.Name.Value == "transfer_allow_death"), Is.True); + Assert.That(callsMethodChanged.Any(x => x.Item1 == CompareStatus.Added && x.Item2.Name.Value == "set_balance_deprecated"), Is.True); + Assert.That(callsMethodChanged.Any(x => x.Item1 == CompareStatus.Added && x.Item2.Name.Value == "force_set_balance"), Is.True); var upgradeAccounts = callsMethodChanged.FirstOrDefault(x => x.Item1 == CompareStatus.Added && x.Item2.Name.Value == "upgrade_accounts"); Assert.That(upgradeAccounts.Item2.VariantFields.Value.Count(), Is.EqualTo(1)); @@ -105,9 +105,9 @@ public void MetadataV14_V9270_And_V9280_PalletHasChanged_ShouldSucceed() var metadataSource = readMetadataFromFile("V14\\MetadataV14_9270"); var metadataDestination = readMetadataFromFile("V14\\MetadataV14_9280"); - Assert.IsTrue(_metadataService.HasPalletChangedVersionBetween("Auctions", metadataSource, metadataDestination)); + Assert.That(_metadataService.HasPalletChangedVersionBetween("Auctions", metadataSource, metadataDestination), Is.True); - Assert.IsFalse(_metadataService.HasPalletChangedVersionBetween("AuthorityDiscovery", metadataSource, metadataDestination)); + Assert.That(_metadataService.HasPalletChangedVersionBetween("AuthorityDiscovery", metadataSource, metadataDestination), Is.False); } } } diff --git a/Substrate.NET.Metadata.Tests/MetadataServiceV9Test.cs b/Substrate.NET.Metadata.Tests/MetadataServiceV9Test.cs index b8b42ba..c71181c 100644 --- a/Substrate.NET.Metadata.Tests/MetadataServiceV9Test.cs +++ b/Substrate.NET.Metadata.Tests/MetadataServiceV9Test.cs @@ -42,8 +42,8 @@ public void MetadataV9_V1020_And_V1022_PalletHasChanged_ShouldSucceed() var metadataSource = readMetadataFromFile("V9\\MetadataV9_Kusama_1020"); var metadataDestination = readMetadataFromFile("V9\\MetadataV9_Kusama_1022"); - Assert.IsTrue(_metadataService.HasPalletChangedVersionBetween("Democracy", metadataSource, metadataDestination)); - Assert.IsFalse(_metadataService.HasPalletChangedVersionBetween("Balances", metadataSource, metadataDestination)); + Assert.That(_metadataService.HasPalletChangedVersionBetween("Democracy", metadataSource, metadataDestination), Is.True); + Assert.That(_metadataService.HasPalletChangedVersionBetween("Balances", metadataSource, metadataDestination), Is.False); } } } diff --git a/Substrate.NET.Metadata.Tests/Substrate.NET.Metadata.Tests.csproj b/Substrate.NET.Metadata.Tests/Substrate.NET.Metadata.Tests.csproj index 5ddfb69..7fe15bd 100644 --- a/Substrate.NET.Metadata.Tests/Substrate.NET.Metadata.Tests.csproj +++ b/Substrate.NET.Metadata.Tests/Substrate.NET.Metadata.Tests.csproj @@ -9,12 +9,18 @@ - - - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/Substrate.NET.Metadata/Substrate.NET.Metadata.csproj b/Substrate.NET.Metadata/Substrate.NET.Metadata.csproj index 2f79d0d..a54eb37 100644 --- a/Substrate.NET.Metadata/Substrate.NET.Metadata.csproj +++ b/Substrate.NET.Metadata/Substrate.NET.Metadata.csproj @@ -17,8 +17,8 @@ - - + + From 83c3b1e3339690ae5bc63250a1b678a54448e433 Mon Sep 17 00:00:00 2001 From: Apolixit Date: Sat, 20 Apr 2024 15:52:55 +0200 Subject: [PATCH 2/2] Bump Java version to 17 for Sonar analysis --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e3ccbde..37d1cab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,10 +31,10 @@ jobs: - name: Restore dependencies run: dotnet restore - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: 'zulu' - uses: actions/checkout@v3 with: @@ -60,7 +60,7 @@ jobs: run: | New-Item -Path .\.sonar\scanner -ItemType Directory dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner - + - name: Install Dotnet coverage shell: powershell run: | @@ -76,7 +76,7 @@ jobs: dotnet build dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml" .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" - + - name: Build test project run: dotnet build .\Substrate.NET.Metadata.Tests