diff --git a/neo b/neo index 045d96a9e..befe7f64d 160000 --- a/neo +++ b/neo @@ -1 +1 @@ -Subproject commit 045d96a9e21497dd3b206c218848d184e10dce01 +Subproject commit befe7f64d2ef7fa8abfb02864f63bc0bcac07875 diff --git a/src/Neo.Compiler.CSharp/MethodConvert/System/SystemCall.cs b/src/Neo.Compiler.CSharp/MethodConvert/System/SystemCall.cs index 03760a9b1..e36b3c5aa 100644 --- a/src/Neo.Compiler.CSharp/MethodConvert/System/SystemCall.cs +++ b/src/Neo.Compiler.CSharp/MethodConvert/System/SystemCall.cs @@ -21,7 +21,6 @@ using System.Reflection; using System.Runtime.InteropServices; using Array = System.Array; -using Akka.Util.Internal; namespace Neo.Compiler; @@ -29,7 +28,7 @@ internal partial class MethodConvert { private delegate void SystemCallHandler(MethodConvert methodConvert, SemanticModel model, IMethodSymbol symbol, ExpressionSyntax? instanceExpression, IReadOnlyList? arguments); - private static readonly Dictionary SystemCallHandlers = new(); + private static readonly Dictionary SystemCallHandlers = []; static MethodConvert() { @@ -44,13 +43,13 @@ private static void RegisterHandler(Expression> expressio private static void RegisterHandler(Expression> expression, SystemCallHandler handler, string? key = null) { - key = key ?? GetKeyFromExpression(expression, typeof(T)); + key ??= GetKeyFromExpression(expression, typeof(T)); SystemCallHandlers[key] = handler; } private static void RegisterHandler(Expression> expression, SystemCallHandler handler, string? key = null) { - key = key ?? GetKeyFromExpression(expression, typeof(T1), typeof(T2)); + key ??= GetKeyFromExpression(expression, typeof(T1), typeof(T2)); SystemCallHandlers[key] = handler; } diff --git a/src/Neo.SmartContract.Testing/Neo.SmartContract.Testing.csproj b/src/Neo.SmartContract.Testing/Neo.SmartContract.Testing.csproj index 9f9324cf6..b34b7b0c3 100644 --- a/src/Neo.SmartContract.Testing/Neo.SmartContract.Testing.csproj +++ b/src/Neo.SmartContract.Testing/Neo.SmartContract.Testing.csproj @@ -18,7 +18,7 @@ - + diff --git a/src/Neo.SmartContract.Testing/TestEngine.cs b/src/Neo.SmartContract.Testing/TestEngine.cs index 3b82e3ab3..bcf77a330 100644 --- a/src/Neo.SmartContract.Testing/TestEngine.cs +++ b/src/Neo.SmartContract.Testing/TestEngine.cs @@ -414,12 +414,8 @@ public T Deploy(NefFile nef, ContractManifest manifest, object? data = null, // Deploy //UInt160 expectedHash = GetDeployHash(nef, manifest); - var state = Native.ContractManagement.Deploy(nef.ToArray(), Encoding.UTF8.GetBytes(manifest.ToJson().ToString(false)), data); - - if (state is null) - { - throw new Exception("Can't get the ContractState"); - } + var state = Native.ContractManagement.Deploy(nef.ToArray(), Encoding.UTF8.GetBytes(manifest.ToJson().ToString(false)), data) + ?? throw new Exception("Can't get the ContractState"); // Mock contract diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index e339ad65c..8a80b3a2e 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -9,8 +9,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Continue.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Continue.cs index bfe72e2ab..55771048c 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Continue.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Continue.cs @@ -63,7 +63,9 @@ public static void ContinueInTryCatch(bool exception) { j += 1; continue; +#pragma warning disable CS0162 // Unreachable code detected j = 10; +#pragma warning restore CS0162 // Unreachable code detected } ExecutionEngine.Assert(j == 3); try diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_SecurityAnalyzer/Contract_CheckWitness.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_SecurityAnalyzer/Contract_CheckWitness.cs index b2f7cc65f..4da8c9e25 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_SecurityAnalyzer/Contract_CheckWitness.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_SecurityAnalyzer/Contract_CheckWitness.cs @@ -10,13 +10,10 @@ // modifications are permitted. using Neo.SmartContract.Framework; -using Neo.SmartContract.Framework.Attributes; -using Neo.SmartContract.Framework.Native; using Neo.SmartContract.Framework.Services; namespace Neo.Compiler.CSharp.TestContracts { -#pragma warning disable CS8625 public class Contract_CheckWitness : SmartContract.Framework.SmartContract { public static void Main(UInt160 u) @@ -24,6 +21,5 @@ public static void Main(UInt160 u) Runtime.CheckWitness(u); ExecutionEngine.Assert(Runtime.CheckWitness(u)); } -#pragma warning restore CS8625 } } diff --git a/tests/Neo.SmartContract.Framework.TestContracts/Neo.SmartContract.Framework.TestContracts.csproj b/tests/Neo.SmartContract.Framework.TestContracts/Neo.SmartContract.Framework.TestContracts.csproj index 328127e92..97dc9a565 100644 --- a/tests/Neo.SmartContract.Framework.TestContracts/Neo.SmartContract.Framework.TestContracts.csproj +++ b/tests/Neo.SmartContract.Framework.TestContracts/Neo.SmartContract.Framework.TestContracts.csproj @@ -16,8 +16,8 @@ - + diff --git a/tests/Neo.SmartContract.Framework.UnitTests/Services/CryptoTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/Services/CryptoTest.cs index 5a63ea2b6..39d6ee33b 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/Services/CryptoTest.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/Services/CryptoTest.cs @@ -65,7 +65,7 @@ public void Test_VerifySignatureWithMessage() // Check - Assert.IsFalse(Contract.Secp256r1VerifySignatureWithMessage(System.Array.Empty(), key.PublicKey, signature)); + Assert.IsFalse(Contract.Secp256r1VerifySignatureWithMessage([], key.PublicKey, signature)); Assert.IsTrue(Contract.Secp256r1VerifySignatureWithMessage(data, key.PublicKey, signature)); // secp256r1 with Keccak hash @@ -74,7 +74,7 @@ public void Test_VerifySignatureWithMessage() // Check - Assert.IsFalse(Contract.Secp256r1VerifyKeccakSignatureWithMessage(System.Array.Empty(), key.PublicKey, signatureKeccak)); + Assert.IsFalse(Contract.Secp256r1VerifyKeccakSignatureWithMessage([], key.PublicKey, signatureKeccak)); Assert.IsTrue(Contract.Secp256r1VerifyKeccakSignatureWithMessage(data, key.PublicKey, signatureKeccak)); // secp256k1 with SHA256 hash @@ -85,16 +85,16 @@ public void Test_VerifySignatureWithMessage() // Check - Assert.IsFalse(Contract.Secp256k1VerifySignatureWithMessage(System.Array.Empty(), pubkey, signature)); + Assert.IsFalse(Contract.Secp256k1VerifySignatureWithMessage([], pubkey, signature)); Assert.IsTrue(Contract.Secp256k1VerifySignatureWithMessage(data, pubkey, signature)); // secp256k1 with Keccak hash - signature = Crypto.Sign(data, key.PrivateKey, ecCurve: Cryptography.ECC.ECCurve.Secp256k1, hasher: Hasher.Keccak256); + signature = Crypto.Sign(data, key.PrivateKey, Cryptography.ECC.ECCurve.Secp256k1, Cryptography.HashAlgorithm.Keccak256); // Check - Assert.IsFalse(Contract.Secp256k1VerifyKeccakSignatureWithMessage(System.Array.Empty(), pubkey, signature)); + Assert.IsFalse(Contract.Secp256k1VerifyKeccakSignatureWithMessage([], pubkey, signature)); Assert.IsTrue(Contract.Secp256k1VerifyKeccakSignatureWithMessage(data, pubkey, signature)); } diff --git a/tests/Neo.SmartContract.Testing.UnitTests/Coverage/CoverageDataTests.cs b/tests/Neo.SmartContract.Testing.UnitTests/Coverage/CoverageDataTests.cs index 205e32cb1..81513370d 100644 --- a/tests/Neo.SmartContract.Testing.UnitTests/Coverage/CoverageDataTests.cs +++ b/tests/Neo.SmartContract.Testing.UnitTests/Coverage/CoverageDataTests.cs @@ -32,35 +32,36 @@ public void TestDump() Assert.AreEqual(100_000_000, engine.Native.NEO.TotalSupply); Assert.AreEqual(WhiteSpaceRegex.Replace(@" -NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [5.00 % - 100.00 %] -┌-───────────────────────────────-┬-────────-┬-────────-┐ -│ Method │ Line │ Branch │ -├-───────────────────────────────-┼-────────-┼-────────-┤ -│ totalSupply() │ 100.00 % │ 100.00 % │ -│ balanceOf(account) │ 0.00 % │ 100.00 % │ -│ decimals() │ 0.00 % │ 100.00 % │ -│ getAccountState(account) │ 0.00 % │ 100.00 % │ -│ getAllCandidates() │ 0.00 % │ 100.00 % │ -│ getCandidates() │ 0.00 % │ 100.00 % │ -│ getCandidateVote(pubKey) │ 0.00 % │ 100.00 % │ -│ getCommittee() │ 0.00 % │ 100.00 % │ -│ getCommitteeAddress() │ 0.00 % │ 100.00 % │ -│ getGasPerBlock() │ 0.00 % │ 100.00 % │ -│ getNextBlockValidators() │ 0.00 % │ 100.00 % │ -│ getRegisterPrice() │ 0.00 % │ 100.00 % │ -│ registerCandidate(pubkey) │ 0.00 % │ 100.00 % │ -│ setGasPerBlock(gasPerBlock) │ 0.00 % │ 100.00 % │ -│ setRegisterPrice(registerPrice) │ 0.00 % │ 100.00 % │ -│ symbol() │ 0.00 % │ 100.00 % │ -│ transfer(from,to,amount,data) │ 0.00 % │ 100.00 % │ -│ unclaimedGas(account,end) │ 0.00 % │ 100.00 % │ -│ unregisterCandidate(pubkey) │ 0.00 % │ 100.00 % │ -│ vote(account,voteTo) │ 0.00 % │ 100.00 % │ -└-───────────────────────────────-┴-────────-┴-────────-┘ +NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [4.76 % - 100.00 %] +┌-────────────────────────────────-┬-────────-┬-────────-┐ +│ Method │ Line │ Branch │ +├-────────────────────────────────-┼-────────-┼-────────-┤ +│ totalSupply() │ 100.00 % │ 100.00 % │ +│ balanceOf(account) │ 0.00 % │ 100.00 % │ +│ decimals() │ 0.00 % │ 100.00 % │ +│ getAccountState(account) │ 0.00 % │ 100.00 % │ +│ getAllCandidates() │ 0.00 % │ 100.00 % │ +│ getCandidates() │ 0.00 % │ 100.00 % │ +│ getCandidateVote(pubKey) │ 0.00 % │ 100.00 % │ +│ getCommittee() │ 0.00 % │ 100.00 % │ +│ getCommitteeAddress() │ 0.00 % │ 100.00 % │ +│ getGasPerBlock() │ 0.00 % │ 100.00 % │ +│ getNextBlockValidators() │ 0.00 % │ 100.00 % │ +│ getRegisterPrice() │ 0.00 % │ 100.00 % │ +│ onNEP17Payment(from,amount,data) │ 0.00 % │ 100.00 % │ +│ registerCandidate(pubkey) │ 0.00 % │ 100.00 % │ +│ setGasPerBlock(gasPerBlock) │ 0.00 % │ 100.00 % │ +│ setRegisterPrice(registerPrice) │ 0.00 % │ 100.00 % │ +│ symbol() │ 0.00 % │ 100.00 % │ +│ transfer(from,to,amount,data) │ 0.00 % │ 100.00 % │ +│ unclaimedGas(account,end) │ 0.00 % │ 100.00 % │ +│ unregisterCandidate(pubkey) │ 0.00 % │ 100.00 % │ +│ vote(account,voteTo) │ 0.00 % │ 100.00 % │ +└-────────────────────────────────-┴-────────-┴-────────-┘ ", ""), WhiteSpaceRegex.Replace(engine.GetCoverage(engine.Native.NEO)?.Dump()!, "")); Assert.AreEqual(WhiteSpaceRegex.Replace(@" -NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [5.00 % - 100.00 %] +NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [4.76 % - 100.00 %] ┌-─────────────-┬-────────-┬-────────-┐ │ Method │ Line │ Branch │ ├-─────────────-┼-────────-┼-────────-┤ @@ -89,7 +90,7 @@ public void TestCoverageByEngine() Assert.AreEqual(100_000_000, engine.Native.NEO.TotalSupply); Assert.AreEqual(engine.Native.NEO.Hash, engine.GetCoverage(engine.Native.NEO)?.Hash); - Assert.AreEqual(60, engine.GetCoverage(engine.Native.NEO)?.TotalLines); + Assert.AreEqual(63, engine.GetCoverage(engine.Native.NEO)?.TotalLines); Assert.AreEqual(3, engine.GetCoverage(engine.Native.NEO)?.CoveredLines); Assert.AreEqual(3, engine.GetCoverage(engine.Native.NEO)?.CoveredLinesAll); @@ -97,7 +98,7 @@ public void TestCoverageByEngine() Assert.AreEqual(0, engine.Native.NEO.BalanceOf(engine.Native.NEO.Hash)); - Assert.AreEqual(60, engine.GetCoverage(engine.Native.NEO)?.TotalLines); + Assert.AreEqual(63, engine.GetCoverage(engine.Native.NEO)?.TotalLines); Assert.AreEqual(6, engine.GetCoverage(engine.Native.NEO)?.CoveredLines); Assert.AreEqual(6, engine.GetCoverage(engine.Native.NEO)?.CoveredLinesAll); @@ -160,7 +161,7 @@ public void TestCoverageByExtension() Assert.AreEqual(100_000_000, engine.Native.NEO.TotalSupply); Assert.AreEqual(engine.Native.NEO.Hash, engine.Native.NEO.GetCoverage()?.Hash); - Assert.AreEqual(60, engine.Native.NEO.GetCoverage()?.TotalLines); + Assert.AreEqual(63, engine.Native.NEO.GetCoverage()?.TotalLines); Assert.AreEqual(3, engine.Native.NEO.GetCoverage()?.CoveredLines); Assert.AreEqual(3, engine.Native.NEO.GetCoverage()?.CoveredLinesAll); @@ -168,7 +169,7 @@ public void TestCoverageByExtension() Assert.AreEqual(0, engine.Native.NEO.BalanceOf(engine.Native.NEO.Hash)); - Assert.AreEqual(60, engine.Native.NEO.GetCoverage()?.TotalLines); + Assert.AreEqual(63, engine.Native.NEO.GetCoverage()?.TotalLines); Assert.AreEqual(6, engine.Native.NEO.GetCoverage()?.CoveredLines); Assert.AreEqual(6, engine.Native.NEO.GetCoverage()?.CoveredLinesAll);