diff --git a/src/neo/IO/Json/JArray.cs b/src/neo/IO/Json/JArray.cs index 8b7dab524d..9519c98b3e 100644 --- a/src/neo/IO/Json/JArray.cs +++ b/src/neo/IO/Json/JArray.cs @@ -114,6 +114,18 @@ internal override void Write(Utf8JsonWriter writer) writer.WriteEndArray(); } + public override JObject Clone() + { + var cloned = new JArray(); + + foreach (JObject item in items) + { + cloned.Add(item.Clone()); + } + + return cloned; + } + public static implicit operator JArray(JObject[] value) { return new JArray(value); diff --git a/src/neo/IO/Json/JBoolean.cs b/src/neo/IO/Json/JBoolean.cs index fa1554ab56..7cfd7ee025 100644 --- a/src/neo/IO/Json/JBoolean.cs +++ b/src/neo/IO/Json/JBoolean.cs @@ -36,6 +36,11 @@ internal override void Write(Utf8JsonWriter writer) writer.WriteBooleanValue(Value); } + public override JObject Clone() + { + return this; + } + public static implicit operator JBoolean(bool value) { return new JBoolean(value); diff --git a/src/neo/IO/Json/JNumber.cs b/src/neo/IO/Json/JNumber.cs index 4f933aa3ad..165d8138ec 100644 --- a/src/neo/IO/Json/JNumber.cs +++ b/src/neo/IO/Json/JNumber.cs @@ -58,6 +58,11 @@ internal override void Write(Utf8JsonWriter writer) writer.WriteNumberValue(Value); } + public override JObject Clone() + { + return this; + } + public static implicit operator JNumber(double value) { return new JNumber(value); diff --git a/src/neo/IO/Json/JObject.cs b/src/neo/IO/Json/JObject.cs index 9e1f1d62e0..ef681d5410 100644 --- a/src/neo/IO/Json/JObject.cs +++ b/src/neo/IO/Json/JObject.cs @@ -204,5 +204,17 @@ public static implicit operator JObject(string value) { return (JString)value; } + + public virtual JObject Clone() + { + var cloned = new JObject(); + + foreach (KeyValuePair pair in Properties) + { + cloned[pair.Key] = pair.Value != null ? pair.Value.Clone() : Null; + } + + return cloned; + } } } diff --git a/src/neo/IO/Json/JString.cs b/src/neo/IO/Json/JString.cs index a54284c3f0..7c625875b3 100644 --- a/src/neo/IO/Json/JString.cs +++ b/src/neo/IO/Json/JString.cs @@ -46,6 +46,11 @@ internal override void Write(Utf8JsonWriter writer) writer.WriteStringValue(Value); } + public override JObject Clone() + { + return this; + } + public static implicit operator JString(Enum value) { return new JString(value.ToString()); diff --git a/src/neo/SmartContract/Manifest/ContractManifest.cs b/src/neo/SmartContract/Manifest/ContractManifest.cs index c376af7d00..112a608030 100644 --- a/src/neo/SmartContract/Manifest/ContractManifest.cs +++ b/src/neo/SmartContract/Manifest/ContractManifest.cs @@ -1,5 +1,6 @@ using Neo.IO; using Neo.IO.Json; +using System.Collections.Generic; using System.IO; using System.Linq; @@ -50,13 +51,18 @@ public class ContractManifest : ISerializable /// The trusts field is an array containing a set of contract hashes or group public keys. It can also be assigned with a wildcard *. If it is a wildcard *, then it means that it trusts any contract. /// If a contract is trusted, the user interface will not give any warnings when called by the contract. /// - public WildCardContainer Trusts { get; set; } + public WildcardContainer Trusts { get; set; } /// /// The safemethods field is an array containing a set of method names. It can also be assigned with a wildcard *. If it is a wildcard *, then it means that all methods of the contract are safe. /// If a method is marked as safe, the user interface will not give any warnings when it is called by any other contract. /// - public WildCardContainer SafeMethods { get; set; } + public WildcardContainer SafeMethods { get; set; } + + /// + /// Custom user data + /// + public JObject Extra { get; set; } /// /// Create Default Contract manifest @@ -77,8 +83,9 @@ public static ContractManifest CreateDefault(UInt160 hash) }, Features = ContractFeatures.NoProperty, Groups = new ContractGroup[0], - SafeMethods = WildCardContainer.Create(), - Trusts = WildCardContainer.Create() + SafeMethods = WildcardContainer.Create(), + Trusts = WildcardContainer.Create(), + Extra = null, }; } @@ -128,6 +135,7 @@ public JObject ToJson() json["permissions"] = Permissions.Select(p => p.ToJson()).ToArray(); json["trusts"] = Trusts.ToJson(); json["safeMethods"] = SafeMethods.ToJson(); + json["extra"] = Extra; return json; } @@ -145,7 +153,8 @@ public ContractManifest Clone() Abi = Abi.Clone(), Permissions = Permissions.Select(p => p.Clone()).ToArray(), Trusts = Trusts, - SafeMethods = SafeMethods + SafeMethods = SafeMethods, + Extra = Extra?.Clone() }; } @@ -171,9 +180,9 @@ private void DeserializeFromJson(JObject json) Groups = ((JArray)json["groups"]).Select(u => ContractGroup.FromJson(u)).ToArray(); Features = ContractFeatures.NoProperty; Permissions = ((JArray)json["permissions"]).Select(u => ContractPermission.FromJson(u)).ToArray(); - Trusts = WildCardContainer.FromJson(json["trusts"], u => UInt160.Parse(u.AsString())); - SafeMethods = WildCardContainer.FromJson(json["safeMethods"], u => u.AsString()); - + Trusts = WildcardContainer.FromJson(json["trusts"], u => UInt160.Parse(u.AsString())); + SafeMethods = WildcardContainer.FromJson(json["safeMethods"], u => u.AsString()); + Extra = json["extra"]; if (json["features"]["storage"].AsBoolean()) Features |= ContractFeatures.HasStorage; if (json["features"]["payable"].AsBoolean()) Features |= ContractFeatures.Payable; } diff --git a/src/neo/SmartContract/Manifest/ContractPermission.cs b/src/neo/SmartContract/Manifest/ContractPermission.cs index ab86157786..f4084eaf0f 100644 --- a/src/neo/SmartContract/Manifest/ContractPermission.cs +++ b/src/neo/SmartContract/Manifest/ContractPermission.cs @@ -19,12 +19,12 @@ public class ContractPermission /// The methods field is an array containing a set of methods to be called. It can also be assigned with a wildcard *. If it is a wildcard *, then it means that any method can be called. /// If a contract invokes a contract or method that is not declared in the manifest at runtime, the invocation will fail. /// - public WildCardContainer Methods { get; set; } + public WildcardContainer Methods { get; set; } public static readonly ContractPermission DefaultPermission = new ContractPermission { Contract = ContractPermissionDescriptor.CreateWildcard(), - Methods = WildCardContainer.CreateWildcard() + Methods = WildcardContainer.CreateWildcard() }; public ContractPermission Clone() @@ -46,7 +46,7 @@ public static ContractPermission FromJson(JObject json) return new ContractPermission { Contract = ContractPermissionDescriptor.FromJson(json["contract"]), - Methods = WildCardContainer.FromJson(json["methods"], u => u.AsString()), + Methods = WildcardContainer.FromJson(json["methods"], u => u.AsString()), }; } diff --git a/src/neo/SmartContract/Manifest/WildCardContainer.cs b/src/neo/SmartContract/Manifest/WildCardContainer.cs index 12dbac60fe..d85f23fbd8 100644 --- a/src/neo/SmartContract/Manifest/WildCardContainer.cs +++ b/src/neo/SmartContract/Manifest/WildCardContainer.cs @@ -6,7 +6,7 @@ namespace Neo.SmartContract.Manifest { - public class WildCardContainer : IReadOnlyList + public class WildcardContainer : IReadOnlyList { private readonly T[] _data; @@ -26,7 +26,7 @@ public class WildCardContainer : IReadOnlyList /// Constructor /// /// Data - private WildCardContainer(T[] data) + private WildcardContainer(T[] data) { _data = data; } @@ -36,15 +36,15 @@ private WildCardContainer(T[] data) /// /// Data /// WildCardContainer - public static WildCardContainer Create(params T[] data) => new WildCardContainer(data); + public static WildcardContainer Create(params T[] data) => new WildcardContainer(data); /// /// Create a wildcard /// /// WildCardContainer - public static WildCardContainer CreateWildcard() => new WildCardContainer(null); + public static WildcardContainer CreateWildcard() => new WildcardContainer(null); - public static WildCardContainer FromJson(JObject json, Func elementSelector) + public static WildcardContainer FromJson(JObject json, Func elementSelector) { switch (json) { diff --git a/src/neo/SmartContract/Native/NativeContract.cs b/src/neo/SmartContract/Native/NativeContract.cs index 80edebd11b..cb2863fda2 100644 --- a/src/neo/SmartContract/Native/NativeContract.cs +++ b/src/neo/SmartContract/Native/NativeContract.cs @@ -62,7 +62,7 @@ protected NativeContract() }); } this.Manifest.Abi.Methods = descriptors.ToArray(); - this.Manifest.SafeMethods = WildCardContainer.Create(safeMethods.ToArray()); + this.Manifest.SafeMethods = WildcardContainer.Create(safeMethods.ToArray()); contracts.Add(this); } diff --git a/tests/neo.UnitTests/IO/Json/UT_JObject.cs b/tests/neo.UnitTests/IO/Json/UT_JObject.cs index fe835016f0..f32bf968dc 100644 --- a/tests/neo.UnitTests/IO/Json/UT_JObject.cs +++ b/tests/neo.UnitTests/IO/Json/UT_JObject.cs @@ -1,6 +1,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; using Neo.IO.Json; +using Neo.SmartContract.Manifest; using System; namespace Neo.UnitTests.IO.Json @@ -106,5 +107,16 @@ public void TestGetNull() { JObject.Null.Should().BeNull(); } + + [TestMethod] + public void TestClone() + { + var bobClone = bob.Clone(); + bobClone.Should().NotBeSameAs(bob); + foreach (var key in bobClone.Properties.Keys) + { + bobClone[key].Should().BeEquivalentTo(bob[key]); + } + } } } diff --git a/tests/neo.UnitTests/Ledger/UT_ContractState.cs b/tests/neo.UnitTests/Ledger/UT_ContractState.cs index 097e9c3e04..670f31d757 100644 --- a/tests/neo.UnitTests/Ledger/UT_ContractState.cs +++ b/tests/neo.UnitTests/Ledger/UT_ContractState.cs @@ -84,7 +84,7 @@ public void TestDeserialize() public void TestGetSize() { ISerializable newContract = contract; - newContract.Size.Should().Be(355); + newContract.Size.Should().Be(368); } [TestMethod] diff --git a/tests/neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs b/tests/neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs index 2416c60bd5..6bab91a808 100644 --- a/tests/neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs +++ b/tests/neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs @@ -1,5 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Neo.Cryptography.ECC; +using Neo.IO.Json; using Neo.SmartContract.Manifest; using System.IO; @@ -11,7 +12,7 @@ public class UT_ContractManifest [TestMethod] public void ParseFromJson_Default() { - var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[]}"; + var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToString(), json); @@ -22,7 +23,7 @@ public void ParseFromJson_Default() [TestMethod] public void ParseFromJson_Features() { - var json = @"{""groups"":[],""features"":{""storage"":true,""payable"":true},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[]}"; + var json = @"{""groups"":[],""features"":{""storage"":true,""payable"":true},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToJson().ToString(), json); @@ -34,7 +35,7 @@ public void ParseFromJson_Features() [TestMethod] public void ParseFromJson_Permissions() { - var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""0x0000000000000000000000000000000000000000"",""methods"":[""method1"",""method2""]}],""trusts"":[],""safeMethods"":[]}"; + var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""0x0000000000000000000000000000000000000000"",""methods"":[""method1"",""method2""]}],""trusts"":[],""safeMethods"":[],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToString(), json); @@ -44,7 +45,7 @@ public void ParseFromJson_Permissions() new ContractPermission() { Contract = ContractPermissionDescriptor.Create(UInt160.Zero), - Methods = WildCardContainer.Create("method1", "method2") + Methods = WildcardContainer.Create("method1", "method2") } }; Assert.AreEqual(manifest.ToString(), check.ToString()); @@ -53,31 +54,31 @@ public void ParseFromJson_Permissions() [TestMethod] public void ParseFromJson_SafeMethods() { - var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[""balanceOf""]}"; + var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[""balanceOf""],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToString(), json); var check = ContractManifest.CreateDefault(UInt160.Zero); - check.SafeMethods = WildCardContainer.Create("balanceOf"); + check.SafeMethods = WildcardContainer.Create("balanceOf"); Assert.AreEqual(manifest.ToString(), check.ToString()); } [TestMethod] public void ParseFromJson_Trust() { - var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[""0x0000000000000000000000000000000000000001""],""safeMethods"":[]}"; + var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[""0x0000000000000000000000000000000000000001""],""safeMethods"":[],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToString(), json); var check = ContractManifest.CreateDefault(UInt160.Zero); - check.Trusts = WildCardContainer.Create(UInt160.Parse("0x0000000000000000000000000000000000000001")); + check.Trusts = WildcardContainer.Create(UInt160.Parse("0x0000000000000000000000000000000000000001")); Assert.AreEqual(manifest.ToString(), check.ToString()); } [TestMethod] public void ParseFromJson_Groups() { - var json = @"{""groups"":[{""pubKey"":""03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c"",""signature"":""QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQQ==""}],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[]}"; + var json = @"{""groups"":[{""pubKey"":""03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c"",""signature"":""QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQQ==""}],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToString(), json); @@ -86,6 +87,15 @@ public void ParseFromJson_Groups() Assert.AreEqual(manifest.ToString(), check.ToString()); } + [TestMethod] + public void ParseFromJson_Extra() + { + var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[],""extra"":{""key"":""value""}}"; + var manifest = ContractManifest.Parse(json); + Assert.AreEqual(json, json); + Assert.AreEqual("value", manifest.Extra["key"].AsString(), false); + } + [TestMethod] public void TestDeserializeAndSerialize() { @@ -93,7 +103,7 @@ public void TestDeserializeAndSerialize() BinaryWriter writer = new BinaryWriter(stream); BinaryReader reader = new BinaryReader(stream); var expected = ContractManifest.CreateDefault(UInt160.Zero); - expected.SafeMethods = WildCardContainer.Create(new string[] { "AAA" }); + expected.SafeMethods = WildcardContainer.Create(new string[] { "AAA" }); expected.Serialize(writer); stream.Seek(0, SeekOrigin.Begin); var actual = ContractManifest.CreateDefault(UInt160.Zero); @@ -113,7 +123,7 @@ public void TestGetHash() public void TestGetSize() { var temp = ContractManifest.CreateDefault(UInt160.Zero); - Assert.AreEqual(353, temp.Size); + Assert.AreEqual(366, temp.Size); } [TestMethod] @@ -127,7 +137,7 @@ public void TestGenerator() public void TestCanCall() { var temp = ContractManifest.CreateDefault(UInt160.Zero); - temp.SafeMethods = WildCardContainer.Create(new string[] { "AAA" }); + temp.SafeMethods = WildcardContainer.Create(new string[] { "AAA" }); Assert.AreEqual(true, temp.CanCall(ContractManifest.CreateDefault(UInt160.Zero), "AAA")); } @@ -135,7 +145,7 @@ public void TestCanCall() public void TestClone() { var expected = ContractManifest.CreateDefault(UInt160.Zero); - expected.SafeMethods = WildCardContainer.Create(new string[] { "AAA" }); + expected.SafeMethods = WildcardContainer.Create(new string[] { "AAA" }); var actual = expected.Clone(); Assert.AreEqual(actual.ToString(), expected.ToString()); } diff --git a/tests/neo.UnitTests/SmartContract/Manifest/UT_WildCardContainer.cs b/tests/neo.UnitTests/SmartContract/Manifest/UT_WildCardContainer.cs index 96bec21d2d..9a6743e4a5 100644 --- a/tests/neo.UnitTests/SmartContract/Manifest/UT_WildCardContainer.cs +++ b/tests/neo.UnitTests/SmartContract/Manifest/UT_WildCardContainer.cs @@ -15,22 +15,22 @@ public class UT_WildCardContainer public void TestFromJson() { JString jstring = new JString("*"); - WildCardContainer s = WildCardContainer.FromJson(jstring, u => u.AsString()); + WildcardContainer s = WildcardContainer.FromJson(jstring, u => u.AsString()); s.Should().BeEmpty(); jstring = new JString("hello world"); - Action action = () => WildCardContainer.FromJson(jstring, u => u.AsString()); + Action action = () => WildcardContainer.FromJson(jstring, u => u.AsString()); action.Should().Throw(); JObject alice = new JObject(); alice["name"] = "alice"; alice["age"] = 30; JArray jarray = new JArray { alice }; - WildCardContainer r = WildCardContainer.FromJson(jarray, u => u.AsString()); + WildcardContainer r = WildcardContainer.FromJson(jarray, u => u.AsString()); r[0].Should().Be("{\"name\":\"alice\",\"age\":30}"); JBoolean jbool = new JBoolean(); - action = () => WildCardContainer.FromJson(jbool, u => u.AsString()); + action = () => WildcardContainer.FromJson(jbool, u => u.AsString()); action.Should().Throw(); } @@ -38,11 +38,11 @@ public void TestFromJson() public void TestGetCount() { string[] s = new string[] { "hello", "world" }; - WildCardContainer container = WildCardContainer.Create(s); + WildcardContainer container = WildcardContainer.Create(s); container.Count.Should().Be(2); s = null; - container = WildCardContainer.Create(s); + container = WildcardContainer.Create(s); container.Count.Should().Be(0); } @@ -50,7 +50,7 @@ public void TestGetCount() public void TestGetItem() { string[] s = new string[] { "hello", "world" }; - WildCardContainer container = WildCardContainer.Create(s); + WildcardContainer container = WildcardContainer.Create(s); container[0].Should().Be("hello"); container[1].Should().Be("world"); } @@ -60,12 +60,12 @@ public void TestGetEnumerator() { string[] s = null; IReadOnlyList rs = (IReadOnlyList)new string[0]; - WildCardContainer container = WildCardContainer.Create(s); + WildcardContainer container = WildcardContainer.Create(s); IEnumerator enumerator = container.GetEnumerator(); enumerator.Should().Be(rs.GetEnumerator()); s = new string[] { "hello", "world" }; - container = WildCardContainer.Create(s); + container = WildcardContainer.Create(s); enumerator = container.GetEnumerator(); foreach (string _ in s) { @@ -78,7 +78,7 @@ public void TestGetEnumerator() public void TestIEnumerableGetEnumerator() { string[] s = new string[] { "hello", "world" }; - WildCardContainer container = WildCardContainer.Create(s); + WildcardContainer container = WildcardContainer.Create(s); IEnumerable enumerable = container; var enumerator = enumerable.GetEnumerator(); foreach (string _ in s) diff --git a/tests/neo.UnitTests/SmartContract/UT_InteropService.cs b/tests/neo.UnitTests/SmartContract/UT_InteropService.cs index e1f29ad4ad..d7e376def3 100644 --- a/tests/neo.UnitTests/SmartContract/UT_InteropService.cs +++ b/tests/neo.UnitTests/SmartContract/UT_InteropService.cs @@ -748,12 +748,12 @@ public void TestContract_Call() engine.CurrentContext.EvaluationStack.Pop().GetSpan().ToHexString().Should().Be(method.ToHexString()); engine.CurrentContext.EvaluationStack.Pop().GetSpan().ToHexString().Should().Be(args.ToHexString()); - state.Manifest.Permissions[0].Methods = WildCardContainer.Create("a"); + state.Manifest.Permissions[0].Methods = WildcardContainer.Create("a"); engine.CurrentContext.EvaluationStack.Push(args); engine.CurrentContext.EvaluationStack.Push(method); engine.CurrentContext.EvaluationStack.Push(state.ScriptHash.ToArray()); InteropService.Invoke(engine, InteropService.System_Contract_Call).Should().BeFalse(); - state.Manifest.Permissions[0].Methods = WildCardContainer.CreateWildcard(); + state.Manifest.Permissions[0].Methods = WildcardContainer.CreateWildcard(); engine.CurrentContext.EvaluationStack.Push(args); engine.CurrentContext.EvaluationStack.Push(method);