Skip to content

Commit 83e6095

Browse files
shargonJim8y
andauthored
Update neo (#1285)
* Update neo * update neo * Revert some of them * Fix * Fix ut --------- Co-authored-by: Jimmy <[email protected]>
1 parent 465637f commit 83e6095

File tree

10 files changed

+49
-55
lines changed

10 files changed

+49
-55
lines changed

neo

Submodule neo updated 96 files

src/Neo.Compiler.CSharp/MethodConvert/System/SystemCall.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
using System.Reflection;
2222
using System.Runtime.InteropServices;
2323
using Array = System.Array;
24-
using Akka.Util.Internal;
2524

2625
namespace Neo.Compiler;
2726

2827
internal partial class MethodConvert
2928
{
3029
private delegate void SystemCallHandler(MethodConvert methodConvert, SemanticModel model, IMethodSymbol symbol, ExpressionSyntax? instanceExpression, IReadOnlyList<SyntaxNode>? arguments);
3130

32-
private static readonly Dictionary<string, SystemCallHandler> SystemCallHandlers = new();
31+
private static readonly Dictionary<string, SystemCallHandler> SystemCallHandlers = [];
3332

3433
static MethodConvert()
3534
{
@@ -44,13 +43,13 @@ private static void RegisterHandler<TResult>(Expression<Func<TResult>> expressio
4443

4544
private static void RegisterHandler<T, TResult>(Expression<Func<T, TResult>> expression, SystemCallHandler handler, string? key = null)
4645
{
47-
key = key ?? GetKeyFromExpression(expression, typeof(T));
46+
key ??= GetKeyFromExpression(expression, typeof(T));
4847
SystemCallHandlers[key] = handler;
4948
}
5049

5150
private static void RegisterHandler<T1, T2, TResult>(Expression<Func<T1, T2, TResult>> expression, SystemCallHandler handler, string? key = null)
5251
{
53-
key = key ?? GetKeyFromExpression(expression, typeof(T1), typeof(T2));
52+
key ??= GetKeyFromExpression(expression, typeof(T1), typeof(T2));
5453
SystemCallHandlers[key] = handler;
5554
}
5655

src/Neo.SmartContract.Testing/Neo.SmartContract.Testing.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<ItemGroup>
2020
<PackageReference Include="Moq" Version="4.20.72" />
21-
<PackageReference Include="MSTest.TestFramework" Version="3.7.1" />
21+
<PackageReference Include="MSTest.TestFramework" Version="3.7.2" />
2222
<PackageReference Include="ReportGenerator.Core" Version="5.4.3" />
2323
</ItemGroup>
2424

src/Neo.SmartContract.Testing/TestEngine.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,8 @@ public T Deploy<T>(NefFile nef, ContractManifest manifest, object? data = null,
414414
// Deploy
415415

416416
//UInt160 expectedHash = GetDeployHash(nef, manifest);
417-
var state = Native.ContractManagement.Deploy(nef.ToArray(), Encoding.UTF8.GetBytes(manifest.ToJson().ToString(false)), data);
418-
419-
if (state is null)
420-
{
421-
throw new Exception("Can't get the ContractState");
422-
}
417+
var state = Native.ContractManagement.Deploy(nef.ToArray(), Encoding.UTF8.GetBytes(manifest.ToJson().ToString(false)), data)
418+
?? throw new Exception("Can't get the ContractState");
423419

424420
// Mock contract
425421

tests/Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
12-
<PackageReference Include="MSTest.TestAdapter" Version="3.7.1" />
13-
<PackageReference Include="MSTest.TestFramework" Version="3.7.1" />
12+
<PackageReference Include="MSTest.TestAdapter" Version="3.7.2" />
13+
<PackageReference Include="MSTest.TestFramework" Version="3.7.2" />
1414
<PackageReference Include="coverlet.collector" Version="6.0.4">
1515
<PrivateAssets>all</PrivateAssets>
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

tests/Neo.Compiler.CSharp.TestContracts/Contract_Continue.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ public static void ContinueInTryCatch(bool exception)
6363
{
6464
j += 1;
6565
continue;
66+
#pragma warning disable CS0162 // Unreachable code detected
6667
j = 10;
68+
#pragma warning restore CS0162 // Unreachable code detected
6769
}
6870
ExecutionEngine.Assert(j == 3);
6971
try

tests/Neo.Compiler.CSharp.TestContracts/Contract_SecurityAnalyzer/Contract_CheckWitness.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,16 @@
1010
// modifications are permitted.
1111

1212
using Neo.SmartContract.Framework;
13-
using Neo.SmartContract.Framework.Attributes;
14-
using Neo.SmartContract.Framework.Native;
1513
using Neo.SmartContract.Framework.Services;
1614

1715
namespace Neo.Compiler.CSharp.TestContracts
1816
{
19-
#pragma warning disable CS8625
2017
public class Contract_CheckWitness : SmartContract.Framework.SmartContract
2118
{
2219
public static void Main(UInt160 u)
2320
{
2421
Runtime.CheckWitness(u);
2522
ExecutionEngine.Assert(Runtime.CheckWitness(u));
2623
}
27-
#pragma warning restore CS8625
2824
}
2925
}

tests/Neo.SmartContract.Framework.TestContracts/Neo.SmartContract.Framework.TestContracts.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
<ItemGroup>
1818
<ProjectReference Include="..\..\src\Neo.SmartContract.Framework\Neo.SmartContract.Framework.csproj" />
19-
<ProjectReference Include="..\..\src\Neo.SmartContract.Analyzer\Neo.SmartContract.Analyzer.csproj"
20-
OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
19+
<ProjectReference Include="..\..\src\Neo.SmartContract.Analyzer\Neo.SmartContract.Analyzer.csproj"
20+
OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
2121
</ItemGroup>
2222

2323
</Project>

tests/Neo.SmartContract.Framework.UnitTests/Services/CryptoTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void Test_VerifySignatureWithMessage()
6565

6666
// Check
6767

68-
Assert.IsFalse(Contract.Secp256r1VerifySignatureWithMessage(System.Array.Empty<byte>(), key.PublicKey, signature));
68+
Assert.IsFalse(Contract.Secp256r1VerifySignatureWithMessage([], key.PublicKey, signature));
6969
Assert.IsTrue(Contract.Secp256r1VerifySignatureWithMessage(data, key.PublicKey, signature));
7070

7171
// secp256r1 with Keccak hash
@@ -74,7 +74,7 @@ public void Test_VerifySignatureWithMessage()
7474

7575
// Check
7676

77-
Assert.IsFalse(Contract.Secp256r1VerifyKeccakSignatureWithMessage(System.Array.Empty<byte>(), key.PublicKey, signatureKeccak));
77+
Assert.IsFalse(Contract.Secp256r1VerifyKeccakSignatureWithMessage([], key.PublicKey, signatureKeccak));
7878
Assert.IsTrue(Contract.Secp256r1VerifyKeccakSignatureWithMessage(data, key.PublicKey, signatureKeccak));
7979

8080
// secp256k1 with SHA256 hash
@@ -85,16 +85,16 @@ public void Test_VerifySignatureWithMessage()
8585

8686
// Check
8787

88-
Assert.IsFalse(Contract.Secp256k1VerifySignatureWithMessage(System.Array.Empty<byte>(), pubkey, signature));
88+
Assert.IsFalse(Contract.Secp256k1VerifySignatureWithMessage([], pubkey, signature));
8989
Assert.IsTrue(Contract.Secp256k1VerifySignatureWithMessage(data, pubkey, signature));
9090

9191
// secp256k1 with Keccak hash
9292

93-
signature = Crypto.Sign(data, key.PrivateKey, ecCurve: Cryptography.ECC.ECCurve.Secp256k1, hasher: Hasher.Keccak256);
93+
signature = Crypto.Sign(data, key.PrivateKey, Cryptography.ECC.ECCurve.Secp256k1, Cryptography.HashAlgorithm.Keccak256);
9494

9595
// Check
9696

97-
Assert.IsFalse(Contract.Secp256k1VerifyKeccakSignatureWithMessage(System.Array.Empty<byte>(), pubkey, signature));
97+
Assert.IsFalse(Contract.Secp256k1VerifyKeccakSignatureWithMessage([], pubkey, signature));
9898
Assert.IsTrue(Contract.Secp256k1VerifyKeccakSignatureWithMessage(data, pubkey, signature));
9999
}
100100

tests/Neo.SmartContract.Testing.UnitTests/Coverage/CoverageDataTests.cs

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,36 @@ public void TestDump()
3232
Assert.AreEqual(100_000_000, engine.Native.NEO.TotalSupply);
3333

3434
Assert.AreEqual(WhiteSpaceRegex.Replace(@"
35-
NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [5.00 % - 100.00 %]
36-
┌-───────────────────────────────-┬-────────-┬-────────-┐
37-
│ Method │ Line │ Branch │
38-
├-───────────────────────────────-┼-────────-┼-────────-┤
39-
│ totalSupply() │ 100.00 % │ 100.00 % │
40-
│ balanceOf(account) │ 0.00 % │ 100.00 % │
41-
│ decimals() │ 0.00 % │ 100.00 % │
42-
│ getAccountState(account) │ 0.00 % │ 100.00 % │
43-
│ getAllCandidates() │ 0.00 % │ 100.00 % │
44-
│ getCandidates() │ 0.00 % │ 100.00 % │
45-
│ getCandidateVote(pubKey) │ 0.00 % │ 100.00 % │
46-
│ getCommittee() │ 0.00 % │ 100.00 % │
47-
│ getCommitteeAddress() │ 0.00 % │ 100.00 % │
48-
│ getGasPerBlock() │ 0.00 % │ 100.00 % │
49-
│ getNextBlockValidators() │ 0.00 % │ 100.00 % │
50-
│ getRegisterPrice() │ 0.00 % │ 100.00 % │
51-
│ registerCandidate(pubkey) │ 0.00 % │ 100.00 % │
52-
│ setGasPerBlock(gasPerBlock) │ 0.00 % │ 100.00 % │
53-
│ setRegisterPrice(registerPrice) │ 0.00 % │ 100.00 % │
54-
│ symbol() │ 0.00 % │ 100.00 % │
55-
│ transfer(from,to,amount,data) │ 0.00 % │ 100.00 % │
56-
│ unclaimedGas(account,end) │ 0.00 % │ 100.00 % │
57-
│ unregisterCandidate(pubkey) │ 0.00 % │ 100.00 % │
58-
│ vote(account,voteTo) │ 0.00 % │ 100.00 % │
59-
└-───────────────────────────────-┴-────────-┴-────────-┘
35+
NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [4.76 % - 100.00 %]
36+
┌-────────────────────────────────-┬-────────-┬-────────-┐
37+
│ Method │ Line │ Branch │
38+
├-────────────────────────────────-┼-────────-┼-────────-┤
39+
│ totalSupply() │ 100.00 % │ 100.00 % │
40+
│ balanceOf(account) │ 0.00 % │ 100.00 % │
41+
│ decimals() │ 0.00 % │ 100.00 % │
42+
│ getAccountState(account) │ 0.00 % │ 100.00 % │
43+
│ getAllCandidates() │ 0.00 % │ 100.00 % │
44+
│ getCandidates() │ 0.00 % │ 100.00 % │
45+
│ getCandidateVote(pubKey) │ 0.00 % │ 100.00 % │
46+
│ getCommittee() │ 0.00 % │ 100.00 % │
47+
│ getCommitteeAddress() │ 0.00 % │ 100.00 % │
48+
│ getGasPerBlock() │ 0.00 % │ 100.00 % │
49+
│ getNextBlockValidators() │ 0.00 % │ 100.00 % │
50+
│ getRegisterPrice() │ 0.00 % │ 100.00 % │
51+
│ onNEP17Payment(from,amount,data) │ 0.00 % │ 100.00 % │
52+
│ registerCandidate(pubkey) │ 0.00 % │ 100.00 % │
53+
│ setGasPerBlock(gasPerBlock) │ 0.00 % │ 100.00 % │
54+
│ setRegisterPrice(registerPrice) │ 0.00 % │ 100.00 % │
55+
│ symbol() │ 0.00 % │ 100.00 % │
56+
│ transfer(from,to,amount,data) │ 0.00 % │ 100.00 % │
57+
│ unclaimedGas(account,end) │ 0.00 % │ 100.00 % │
58+
│ unregisterCandidate(pubkey) │ 0.00 % │ 100.00 % │
59+
│ vote(account,voteTo) │ 0.00 % │ 100.00 % │
60+
└-────────────────────────────────-┴-────────-┴-────────-┘
6061
", ""), WhiteSpaceRegex.Replace(engine.GetCoverage(engine.Native.NEO)?.Dump()!, ""));
6162

6263
Assert.AreEqual(WhiteSpaceRegex.Replace(@"
63-
NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [5.00 % - 100.00 %]
64+
NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [4.76 % - 100.00 %]
6465
┌-─────────────-┬-────────-┬-────────-┐
6566
│ Method │ Line │ Branch │
6667
├-─────────────-┼-────────-┼-────────-┤
@@ -89,15 +90,15 @@ public void TestCoverageByEngine()
8990
Assert.AreEqual(100_000_000, engine.Native.NEO.TotalSupply);
9091

9192
Assert.AreEqual(engine.Native.NEO.Hash, engine.GetCoverage(engine.Native.NEO)?.Hash);
92-
Assert.AreEqual(60, engine.GetCoverage(engine.Native.NEO)?.TotalLines);
93+
Assert.AreEqual(63, engine.GetCoverage(engine.Native.NEO)?.TotalLines);
9394
Assert.AreEqual(3, engine.GetCoverage(engine.Native.NEO)?.CoveredLines);
9495
Assert.AreEqual(3, engine.GetCoverage(engine.Native.NEO)?.CoveredLinesAll);
9596

9697
// Check balanceOf
9798

9899
Assert.AreEqual(0, engine.Native.NEO.BalanceOf(engine.Native.NEO.Hash));
99100

100-
Assert.AreEqual(60, engine.GetCoverage(engine.Native.NEO)?.TotalLines);
101+
Assert.AreEqual(63, engine.GetCoverage(engine.Native.NEO)?.TotalLines);
101102
Assert.AreEqual(6, engine.GetCoverage(engine.Native.NEO)?.CoveredLines);
102103
Assert.AreEqual(6, engine.GetCoverage(engine.Native.NEO)?.CoveredLinesAll);
103104

@@ -160,15 +161,15 @@ public void TestCoverageByExtension()
160161
Assert.AreEqual(100_000_000, engine.Native.NEO.TotalSupply);
161162

162163
Assert.AreEqual(engine.Native.NEO.Hash, engine.Native.NEO.GetCoverage()?.Hash);
163-
Assert.AreEqual(60, engine.Native.NEO.GetCoverage()?.TotalLines);
164+
Assert.AreEqual(63, engine.Native.NEO.GetCoverage()?.TotalLines);
164165
Assert.AreEqual(3, engine.Native.NEO.GetCoverage()?.CoveredLines);
165166
Assert.AreEqual(3, engine.Native.NEO.GetCoverage()?.CoveredLinesAll);
166167

167168
// Check balanceOf
168169

169170
Assert.AreEqual(0, engine.Native.NEO.BalanceOf(engine.Native.NEO.Hash));
170171

171-
Assert.AreEqual(60, engine.Native.NEO.GetCoverage()?.TotalLines);
172+
Assert.AreEqual(63, engine.Native.NEO.GetCoverage()?.TotalLines);
172173
Assert.AreEqual(6, engine.Native.NEO.GetCoverage()?.CoveredLines);
173174
Assert.AreEqual(6, engine.Native.NEO.GetCoverage()?.CoveredLinesAll);
174175

0 commit comments

Comments
 (0)