Skip to content

Commit 43ee0da

Browse files
Merge branch 'master' into fix-build
2 parents e46f680 + e5cebae commit 43ee0da

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

src/Neo.CLI/Settings.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public class Settings
2222
public P2PSettings P2P { get; }
2323
public UnlockWalletSettings UnlockWallet { get; }
2424

25-
static Settings? _default;
25+
static Settings? s_default;
2626

2727
static bool UpdateDefault(IConfiguration configuration)
2828
{
2929
var settings = new Settings(configuration.GetSection("ApplicationConfiguration"));
30-
return null == Interlocked.CompareExchange(ref _default, settings, null);
30+
return null == Interlocked.CompareExchange(ref s_default, settings, null);
3131
}
3232

3333
public static bool Initialize(IConfiguration configuration)
@@ -39,22 +39,22 @@ public static Settings Default
3939
{
4040
get
4141
{
42-
if (_default == null)
42+
if (s_default == null)
4343
{
44-
IConfigurationRoot config = new ConfigurationBuilder().AddJsonFile("config.json", optional: true).Build();
44+
var config = new ConfigurationBuilder().AddJsonFile("config.json", optional: true).Build();
4545
Initialize(config);
4646
}
4747

48-
return _default!;
48+
return s_default!;
4949
}
5050
}
5151

5252
public Settings(IConfigurationSection section)
5353
{
54-
this.Logger = new LoggerSettings(section.GetSection("Logger"));
55-
this.Storage = new StorageSettings(section.GetSection("Storage"));
56-
this.P2P = new P2PSettings(section.GetSection("P2P"));
57-
this.UnlockWallet = new UnlockWalletSettings(section.GetSection("UnlockWallet"));
54+
this.Logger = new(section.GetSection("Logger"));
55+
this.Storage = new(section.GetSection("Storage"));
56+
this.P2P = new(section.GetSection("P2P"));
57+
this.UnlockWallet = new(section.GetSection("UnlockWallet"));
5858
}
5959
}
6060

@@ -93,7 +93,7 @@ public class P2PSettings
9393

9494
public P2PSettings(IConfigurationSection section)
9595
{
96-
this.Port = ushort.Parse(section.GetValue("Port", "10333"));
96+
this.Port = section.GetValue<ushort>("Port", 10333);
9797
this.MinDesiredConnections = section.GetValue("MinDesiredConnections", Peer.DefaultMinDesiredConnections);
9898
this.MaxConnections = section.GetValue("MaxConnections", Peer.DefaultMaxConnections);
9999
this.MaxConnectionsPerAddress = section.GetValue("MaxConnectionsPerAddress", 3);

tests/Neo.UnitTests/SmartContract/UT_InteropService.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void Runtime_GetNotifications_Test()
5656
scriptHash2 = script.ToArray().ToScriptHash();
5757

5858
snapshot.DeleteContract(scriptHash2);
59-
ContractState contract = TestUtils.GetContract(script.ToArray(), TestUtils.CreateManifest("test", ContractParameterType.Any, ContractParameterType.Integer, ContractParameterType.Integer));
59+
var contract = TestUtils.GetContract(script.ToArray(), TestUtils.CreateManifest("test", ContractParameterType.Any, ContractParameterType.Integer, ContractParameterType.Integer));
6060
contract.Manifest.Abi.Events = new[]
6161
{
6262
new ContractEventDescriptor
@@ -294,8 +294,8 @@ public void TestRuntime_CheckWitness()
294294
{
295295
byte[] privateKey = { 0x01,0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
296296
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
297-
KeyPair keyPair = new(privateKey);
298-
ECPoint pubkey = keyPair.PublicKey;
297+
var keyPair = new KeyPair(privateKey);
298+
var pubkey = keyPair.PublicKey;
299299

300300
var engine = GetEngine(true);
301301
((Transaction)engine.ScriptContainer).Signers[0].Account = Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash();
@@ -316,8 +316,8 @@ public void TestRuntime_CheckWitness_Null_ScriptContainer()
316316
{
317317
byte[] privateKey = { 0x01,0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
318318
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
319-
KeyPair keyPair = new(privateKey);
320-
ECPoint pubkey = keyPair.PublicKey;
319+
var keyPair = new KeyPair(privateKey);
320+
var pubkey = keyPair.PublicKey;
321321

322322
var engine = GetEngine();
323323

@@ -328,7 +328,7 @@ public void TestRuntime_CheckWitness_Null_ScriptContainer()
328328
public void TestRuntime_Log()
329329
{
330330
var engine = GetEngine(true);
331-
string message = "hello";
331+
var message = "hello";
332332
ApplicationEngine.Log += LogEvent;
333333
engine.RuntimeLog(Encoding.UTF8.GetBytes(message));
334334
((Transaction)engine.ScriptContainer).Script.Span.ToHexString().Should().Be(new byte[] { 0x01, 0x02, 0x03 }.ToHexString());
@@ -396,16 +396,16 @@ public void TestRuntime_GetCurrentSigners_SysCall()
396396
public void TestCrypto_Verify()
397397
{
398398
var engine = GetEngine(true);
399-
IVerifiable iv = engine.ScriptContainer;
400-
byte[] message = iv.GetSignData(TestProtocolSettings.Default.Network);
399+
var iv = engine.ScriptContainer;
400+
var message = iv.GetSignData(TestProtocolSettings.Default.Network);
401401
byte[] privateKey = { 0x01,0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
402402
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
403403
KeyPair keyPair = new(privateKey);
404-
ECPoint pubkey = keyPair.PublicKey;
405-
byte[] signature = Crypto.Sign(message, privateKey, pubkey.EncodePoint(false).Skip(1).ToArray());
404+
var pubkey = keyPair.PublicKey;
405+
var signature = Crypto.Sign(message, privateKey, pubkey.EncodePoint(false).Skip(1).ToArray());
406406
engine.CheckSig(pubkey.EncodePoint(false), signature).Should().BeTrue();
407407

408-
byte[] wrongkey = pubkey.EncodePoint(false);
408+
var wrongkey = pubkey.EncodePoint(false);
409409
wrongkey[0] = 5;
410410
Assert.ThrowsException<FormatException>(() => engine.CheckSig(wrongkey, signature));
411411
}
@@ -424,7 +424,7 @@ public void TestBlockchain_GetBlock()
424424

425425
NativeContract.Ledger.GetBlock(engine.Snapshot, UInt256.Zero).Should().BeNull();
426426

427-
byte[] data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01,
427+
var data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01,
428428
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
429429
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
430430
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
@@ -436,7 +436,7 @@ public void TestBlockchain_GetBlock()
436436
public void TestBlockchain_GetTransaction()
437437
{
438438
var engine = GetEngine(true, true);
439-
byte[] data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01,
439+
var data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01,
440440
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
441441
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
442442
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
@@ -469,7 +469,7 @@ public void TestBlockchain_GetTransactionHeight()
469469
public void TestBlockchain_GetContract()
470470
{
471471
var engine = GetEngine(true, true);
472-
byte[] data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01,
472+
var data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01,
473473
0x01, 0x01, 0x01, 0x01, 0x01,
474474
0x01, 0x01, 0x01, 0x01, 0x01,
475475
0x01, 0x01, 0x01, 0x01, 0x01 };
@@ -638,7 +638,7 @@ public void TestStorageContext_AsReadOnly()
638638
public void TestContract_Call()
639639
{
640640
var snapshot = TestBlockchain.GetTestSnapshot();
641-
string method = "method";
641+
var method = "method";
642642
var args = new VM.Types.Array { 0, 1 };
643643
var state = TestUtils.GetContract(method, args.Count);
644644

@@ -696,13 +696,13 @@ public void TestContract_Destroy()
696696
[TestMethod]
697697
public void TestContract_CreateStandardAccount()
698698
{
699-
ECPoint pubkey = ECPoint.Parse("024b817ef37f2fc3d4a33fe36687e592d9f30fe24b3e28187dc8f12b3b3b2b839e", ECCurve.Secp256r1);
699+
var pubkey = ECPoint.Parse("024b817ef37f2fc3d4a33fe36687e592d9f30fe24b3e28187dc8f12b3b3b2b839e", ECCurve.Secp256r1);
700700
GetEngine().CreateStandardAccount(pubkey).ToArray().ToHexString().Should().Be("c44ea575c5f79638f0e73f39d7bd4b3337c81691");
701701
}
702702

703703
public static void LogEvent(object sender, LogEventArgs args)
704704
{
705-
Transaction tx = (Transaction)args.ScriptContainer;
705+
var tx = (Transaction)args.ScriptContainer;
706706
tx.Script = new byte[] { 0x01, 0x02, 0x03 };
707707
}
708708

@@ -711,7 +711,7 @@ private static ApplicationEngine GetEngine(bool hasContainer = false, bool hasSn
711711
var tx = hasContainer ? TestUtils.GetTransaction(UInt160.Zero) : null;
712712
var snapshot = hasSnapshot ? TestBlockchain.GetTestSnapshot() : null;
713713
var block = hasBlock ? new Block { Header = new Header() } : null;
714-
ApplicationEngine engine = ApplicationEngine.Create(TriggerType.Application, tx, snapshot, block, TestBlockchain.TheNeoSystem.Settings, gas: gas);
714+
var engine = ApplicationEngine.Create(TriggerType.Application, tx, snapshot, block, TestBlockchain.TheNeoSystem.Settings, gas: gas);
715715
if (addScript) engine.LoadScript(new byte[] { 0x01 });
716716
return engine;
717717
}

0 commit comments

Comments
 (0)