Skip to content

Commit

Permalink
Merge branch 'master' into fix-build
Browse files Browse the repository at this point in the history
  • Loading branch information
cschuchardt88 authored Jan 5, 2024
2 parents e46f680 + e5cebae commit 43ee0da
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
20 changes: 10 additions & 10 deletions src/Neo.CLI/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public class Settings
public P2PSettings P2P { get; }
public UnlockWalletSettings UnlockWallet { get; }

static Settings? _default;
static Settings? s_default;

static bool UpdateDefault(IConfiguration configuration)
{
var settings = new Settings(configuration.GetSection("ApplicationConfiguration"));
return null == Interlocked.CompareExchange(ref _default, settings, null);
return null == Interlocked.CompareExchange(ref s_default, settings, null);
}

public static bool Initialize(IConfiguration configuration)
Expand All @@ -39,22 +39,22 @@ public static Settings Default
{
get
{
if (_default == null)
if (s_default == null)
{
IConfigurationRoot config = new ConfigurationBuilder().AddJsonFile("config.json", optional: true).Build();
var config = new ConfigurationBuilder().AddJsonFile("config.json", optional: true).Build();
Initialize(config);
}

return _default!;
return s_default!;
}
}

public Settings(IConfigurationSection section)
{
this.Logger = new LoggerSettings(section.GetSection("Logger"));
this.Storage = new StorageSettings(section.GetSection("Storage"));
this.P2P = new P2PSettings(section.GetSection("P2P"));
this.UnlockWallet = new UnlockWalletSettings(section.GetSection("UnlockWallet"));
this.Logger = new(section.GetSection("Logger"));
this.Storage = new(section.GetSection("Storage"));
this.P2P = new(section.GetSection("P2P"));
this.UnlockWallet = new(section.GetSection("UnlockWallet"));
}
}

Expand Down Expand Up @@ -93,7 +93,7 @@ public class P2PSettings

public P2PSettings(IConfigurationSection section)
{
this.Port = ushort.Parse(section.GetValue("Port", "10333"));
this.Port = section.GetValue<ushort>("Port", 10333);
this.MinDesiredConnections = section.GetValue("MinDesiredConnections", Peer.DefaultMinDesiredConnections);
this.MaxConnections = section.GetValue("MaxConnections", Peer.DefaultMaxConnections);
this.MaxConnectionsPerAddress = section.GetValue("MaxConnectionsPerAddress", 3);
Expand Down
36 changes: 18 additions & 18 deletions tests/Neo.UnitTests/SmartContract/UT_InteropService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void Runtime_GetNotifications_Test()
scriptHash2 = script.ToArray().ToScriptHash();

snapshot.DeleteContract(scriptHash2);
ContractState contract = TestUtils.GetContract(script.ToArray(), TestUtils.CreateManifest("test", ContractParameterType.Any, ContractParameterType.Integer, ContractParameterType.Integer));
var contract = TestUtils.GetContract(script.ToArray(), TestUtils.CreateManifest("test", ContractParameterType.Any, ContractParameterType.Integer, ContractParameterType.Integer));
contract.Manifest.Abi.Events = new[]
{
new ContractEventDescriptor
Expand Down Expand Up @@ -294,8 +294,8 @@ public void TestRuntime_CheckWitness()
{
byte[] privateKey = { 0x01,0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
KeyPair keyPair = new(privateKey);
ECPoint pubkey = keyPair.PublicKey;
var keyPair = new KeyPair(privateKey);
var pubkey = keyPair.PublicKey;

var engine = GetEngine(true);
((Transaction)engine.ScriptContainer).Signers[0].Account = Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash();
Expand All @@ -316,8 +316,8 @@ public void TestRuntime_CheckWitness_Null_ScriptContainer()
{
byte[] privateKey = { 0x01,0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
KeyPair keyPair = new(privateKey);
ECPoint pubkey = keyPair.PublicKey;
var keyPair = new KeyPair(privateKey);
var pubkey = keyPair.PublicKey;

var engine = GetEngine();

Expand All @@ -328,7 +328,7 @@ public void TestRuntime_CheckWitness_Null_ScriptContainer()
public void TestRuntime_Log()
{
var engine = GetEngine(true);
string message = "hello";
var message = "hello";
ApplicationEngine.Log += LogEvent;
engine.RuntimeLog(Encoding.UTF8.GetBytes(message));
((Transaction)engine.ScriptContainer).Script.Span.ToHexString().Should().Be(new byte[] { 0x01, 0x02, 0x03 }.ToHexString());
Expand Down Expand Up @@ -396,16 +396,16 @@ public void TestRuntime_GetCurrentSigners_SysCall()
public void TestCrypto_Verify()
{
var engine = GetEngine(true);
IVerifiable iv = engine.ScriptContainer;
byte[] message = iv.GetSignData(TestProtocolSettings.Default.Network);
var iv = engine.ScriptContainer;
var message = iv.GetSignData(TestProtocolSettings.Default.Network);
byte[] privateKey = { 0x01,0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
KeyPair keyPair = new(privateKey);
ECPoint pubkey = keyPair.PublicKey;
byte[] signature = Crypto.Sign(message, privateKey, pubkey.EncodePoint(false).Skip(1).ToArray());
var pubkey = keyPair.PublicKey;
var signature = Crypto.Sign(message, privateKey, pubkey.EncodePoint(false).Skip(1).ToArray());
engine.CheckSig(pubkey.EncodePoint(false), signature).Should().BeTrue();

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

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

byte[] data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01,
var data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
Expand All @@ -436,7 +436,7 @@ public void TestBlockchain_GetBlock()
public void TestBlockchain_GetTransaction()
{
var engine = GetEngine(true, true);
byte[] data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01,
var data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
Expand Down Expand Up @@ -469,7 +469,7 @@ public void TestBlockchain_GetTransactionHeight()
public void TestBlockchain_GetContract()
{
var engine = GetEngine(true, true);
byte[] data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01,
var data1 = new byte[] { 0x01, 0x01, 0x01 ,0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01 };
Expand Down Expand Up @@ -638,7 +638,7 @@ public void TestStorageContext_AsReadOnly()
public void TestContract_Call()
{
var snapshot = TestBlockchain.GetTestSnapshot();
string method = "method";
var method = "method";
var args = new VM.Types.Array { 0, 1 };
var state = TestUtils.GetContract(method, args.Count);

Expand Down Expand Up @@ -696,13 +696,13 @@ public void TestContract_Destroy()
[TestMethod]
public void TestContract_CreateStandardAccount()
{
ECPoint pubkey = ECPoint.Parse("024b817ef37f2fc3d4a33fe36687e592d9f30fe24b3e28187dc8f12b3b3b2b839e", ECCurve.Secp256r1);
var pubkey = ECPoint.Parse("024b817ef37f2fc3d4a33fe36687e592d9f30fe24b3e28187dc8f12b3b3b2b839e", ECCurve.Secp256r1);
GetEngine().CreateStandardAccount(pubkey).ToArray().ToHexString().Should().Be("c44ea575c5f79638f0e73f39d7bd4b3337c81691");
}

public static void LogEvent(object sender, LogEventArgs args)
{
Transaction tx = (Transaction)args.ScriptContainer;
var tx = (Transaction)args.ScriptContainer;
tx.Script = new byte[] { 0x01, 0x02, 0x03 };
}

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

0 comments on commit 43ee0da

Please sign in to comment.