From 62a3ca2eb2dc7b248be1b83ac055bd46eba690d3 Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Thu, 12 Nov 2020 22:45:40 +0800 Subject: [PATCH] Remove ContractFeatures (#2060) --- src/neo/Ledger/ContractState.cs | 5 +--- .../ApplicationEngine.Contract.cs | 7 ++--- .../ApplicationEngine.Storage.cs | 2 -- .../Manifest/ContractFeatures.cs | 13 ---------- .../Manifest/ContractManifest.cs | 14 ---------- .../Native/Designate/DesignateContract.cs | 2 -- .../SmartContract/Native/NativeContract.cs | 1 - .../Native/Oracle/OracleContract.cs | 2 -- .../SmartContract/Native/PolicyContract.cs | 4 +-- .../SmartContract/Native/Tokens/Nep5Token.cs | 3 --- .../neo.UnitTests/Ledger/UT_ContractState.cs | 14 +--------- .../Manifest/UT_ContractManifest.cs | 26 +++++-------------- .../SmartContract/UT_InteropPrices.cs | 5 ---- .../SmartContract/UT_InteropService.NEO.cs | 3 --- .../SmartContract/UT_InteropService.cs | 13 +--------- tests/neo.UnitTests/TestUtils.cs | 1 - 16 files changed, 13 insertions(+), 102 deletions(-) delete mode 100644 src/neo/SmartContract/Manifest/ContractFeatures.cs diff --git a/src/neo/Ledger/ContractState.cs b/src/neo/Ledger/ContractState.cs index 882abb4e2e..4017eb28ac 100644 --- a/src/neo/Ledger/ContractState.cs +++ b/src/neo/Ledger/ContractState.cs @@ -16,9 +16,6 @@ public class ContractState : ICloneable, ISerializable, IInterope public byte[] Script; public ContractManifest Manifest; - public bool HasStorage => Manifest.Features.HasFlag(ContractFeatures.HasStorage); - public bool Payable => Manifest.Features.HasFlag(ContractFeatures.Payable); - private UInt160 _scriptHash; public UInt160 ScriptHash { @@ -82,7 +79,7 @@ public JObject ToJson() public StackItem ToStackItem(ReferenceCounter referenceCounter) { - return new Array(referenceCounter, new StackItem[] { Script, Manifest.ToString(), HasStorage, Payable }); + return new Array(referenceCounter, new StackItem[] { Script, Manifest.ToString() }); } } } diff --git a/src/neo/SmartContract/ApplicationEngine.Contract.cs b/src/neo/SmartContract/ApplicationEngine.Contract.cs index 3501293f92..8fe9e779a2 100644 --- a/src/neo/SmartContract/ApplicationEngine.Contract.cs +++ b/src/neo/SmartContract/ApplicationEngine.Contract.cs @@ -96,8 +96,6 @@ protected internal void UpdateContract(byte[] script, byte[] manifest) contract.Manifest = ContractManifest.Parse(manifest); if (!contract.Manifest.IsValid(contract.ScriptHash)) throw new InvalidOperationException($"Invalid Manifest Hash: {contract.ScriptHash}"); - if (!contract.HasStorage && Snapshot.Storages.Find(BitConverter.GetBytes(contract.Id)).Any()) - throw new InvalidOperationException($"Contract Does Not Support Storage But Uses Storage"); } if (script != null) { @@ -113,9 +111,8 @@ protected internal void DestroyContract() ContractState contract = Snapshot.Contracts.TryGet(hash); if (contract == null) return; Snapshot.Contracts.Delete(hash); - if (contract.HasStorage) - foreach (var (key, _) in Snapshot.Storages.Find(BitConverter.GetBytes(contract.Id))) - Snapshot.Storages.Delete(key); + foreach (var (key, _) in Snapshot.Storages.Find(BitConverter.GetBytes(contract.Id))) + Snapshot.Storages.Delete(key); } protected internal void CallContract(UInt160 contractHash, string method, Array args) diff --git a/src/neo/SmartContract/ApplicationEngine.Storage.cs b/src/neo/SmartContract/ApplicationEngine.Storage.cs index ce87bc6211..92c9d9df74 100644 --- a/src/neo/SmartContract/ApplicationEngine.Storage.cs +++ b/src/neo/SmartContract/ApplicationEngine.Storage.cs @@ -23,7 +23,6 @@ partial class ApplicationEngine protected internal StorageContext GetStorageContext() { ContractState contract = Snapshot.Contracts.TryGet(CurrentScriptHash); - if (!contract.HasStorage) throw new InvalidOperationException(); return new StorageContext { Id = contract.Id, @@ -34,7 +33,6 @@ protected internal StorageContext GetStorageContext() protected internal StorageContext GetReadOnlyContext() { ContractState contract = Snapshot.Contracts.TryGet(CurrentScriptHash); - if (!contract.HasStorage) throw new InvalidOperationException(); return new StorageContext { Id = contract.Id, diff --git a/src/neo/SmartContract/Manifest/ContractFeatures.cs b/src/neo/SmartContract/Manifest/ContractFeatures.cs deleted file mode 100644 index 9f94a9d3f1..0000000000 --- a/src/neo/SmartContract/Manifest/ContractFeatures.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace Neo.SmartContract.Manifest -{ - [Flags] - public enum ContractFeatures : byte - { - NoProperty = 0, - - HasStorage = 1 << 0, - Payable = 1 << 2 - } -} diff --git a/src/neo/SmartContract/Manifest/ContractManifest.cs b/src/neo/SmartContract/Manifest/ContractManifest.cs index 990a400929..ff57c1e3c4 100644 --- a/src/neo/SmartContract/Manifest/ContractManifest.cs +++ b/src/neo/SmartContract/Manifest/ContractManifest.cs @@ -39,11 +39,6 @@ public int Size /// public ContractGroup[] Groups { get; set; } - /// - /// The features field describes what features are available for the contract. - /// - public ContractFeatures Features { get; set; } - /// /// NEP10 - SupportedStandards /// @@ -116,11 +111,6 @@ public JObject ToJson() return new JObject { ["groups"] = Groups.Select(u => u.ToJson()).ToArray(), - ["features"] = new JObject - { - ["storage"] = Features.HasFlag(ContractFeatures.HasStorage), - ["payable"] = Features.HasFlag(ContractFeatures.Payable) - }, ["supportedstandards"] = SupportedStandards.Select(u => new JString(u)).ToArray(), ["abi"] = Abi.ToJson(), ["permissions"] = Permissions.Select(p => p.ToJson()).ToArray(), @@ -139,7 +129,6 @@ public ContractManifest Clone() return new ContractManifest { Groups = Groups.Select(p => p.Clone()).ToArray(), - Features = Features, SupportedStandards = SupportedStandards[..], Abi = Abi.Clone(), Permissions = Permissions.Select(p => p.Clone()).ToArray(), @@ -168,9 +157,6 @@ public void Deserialize(BinaryReader reader) private void DeserializeFromJson(JObject json) { Groups = ((JArray)json["groups"]).Select(u => ContractGroup.FromJson(u)).ToArray(); - Features = ContractFeatures.NoProperty; - if (json["features"]["storage"].AsBoolean()) Features |= ContractFeatures.HasStorage; - if (json["features"]["payable"].AsBoolean()) Features |= ContractFeatures.Payable; SupportedStandards = ((JArray)json["supportedstandards"]).Select(u => u.AsString()).ToArray(); Abi = ContractAbi.FromJson(json["abi"]); Permissions = ((JArray)json["permissions"]).Select(u => ContractPermission.FromJson(u)).ToArray(); diff --git a/src/neo/SmartContract/Native/Designate/DesignateContract.cs b/src/neo/SmartContract/Native/Designate/DesignateContract.cs index b6e0fbe248..a8180bbea0 100644 --- a/src/neo/SmartContract/Native/Designate/DesignateContract.cs +++ b/src/neo/SmartContract/Native/Designate/DesignateContract.cs @@ -6,7 +6,6 @@ using Neo.IO.Caching; using Neo.Ledger; using Neo.Persistence; -using Neo.SmartContract.Manifest; using Neo.VM; using Neo.VM.Types; using System; @@ -22,7 +21,6 @@ public sealed class DesignateContract : NativeContract internal DesignateContract() { - Manifest.Features = ContractFeatures.HasStorage; } [ContractMethod(0_01000000, CallFlags.AllowStates)] diff --git a/src/neo/SmartContract/Native/NativeContract.cs b/src/neo/SmartContract/Native/NativeContract.cs index 81f944647c..ae670d74a2 100644 --- a/src/neo/SmartContract/Native/NativeContract.cs +++ b/src/neo/SmartContract/Native/NativeContract.cs @@ -63,7 +63,6 @@ protected NativeContract() this.Manifest = new ContractManifest { Groups = System.Array.Empty(), - Features = ContractFeatures.NoProperty, SupportedStandards = new string[0], Abi = new ContractAbi() { diff --git a/src/neo/SmartContract/Native/Oracle/OracleContract.cs b/src/neo/SmartContract/Native/Oracle/OracleContract.cs index 96b5aa7bba..18d8ad20a9 100644 --- a/src/neo/SmartContract/Native/Oracle/OracleContract.cs +++ b/src/neo/SmartContract/Native/Oracle/OracleContract.cs @@ -34,8 +34,6 @@ public sealed class OracleContract : NativeContract internal OracleContract() { - Manifest.Features = ContractFeatures.HasStorage; - var events = new List(Manifest.Abi.Events) { new ContractEventDescriptor diff --git a/src/neo/SmartContract/Native/PolicyContract.cs b/src/neo/SmartContract/Native/PolicyContract.cs index 1002debb7c..e828bbc94c 100644 --- a/src/neo/SmartContract/Native/PolicyContract.cs +++ b/src/neo/SmartContract/Native/PolicyContract.cs @@ -4,7 +4,6 @@ using Neo.Network.P2P; using Neo.Network.P2P.Payloads; using Neo.Persistence; -using Neo.SmartContract.Manifest; using System; using System.Numerics; @@ -21,9 +20,8 @@ public sealed class PolicyContract : NativeContract private const byte Prefix_MaxBlockSize = 12; private const byte Prefix_MaxBlockSystemFee = 17; - public PolicyContract() + internal PolicyContract() { - Manifest.Features = ContractFeatures.HasStorage; } [ContractMethod(0_01000000, CallFlags.AllowStates)] diff --git a/src/neo/SmartContract/Native/Tokens/Nep5Token.cs b/src/neo/SmartContract/Native/Tokens/Nep5Token.cs index ed4308b73c..a2337b1c25 100644 --- a/src/neo/SmartContract/Native/Tokens/Nep5Token.cs +++ b/src/neo/SmartContract/Native/Tokens/Nep5Token.cs @@ -26,7 +26,6 @@ protected Nep5Token() { this.Factor = BigInteger.Pow(10, Decimals); - Manifest.Features = ContractFeatures.HasStorage; Manifest.SupportedStandards = new[] { "NEP-5" }; var events = new List(Manifest.Abi.Events) @@ -111,8 +110,6 @@ protected virtual bool Transfer(ApplicationEngine engine, UInt160 from, UInt160 if (amount.Sign < 0) throw new ArgumentOutOfRangeException(nameof(amount)); if (!from.Equals(engine.CallingScriptHash) && !engine.CheckWitnessInternal(from)) return false; - ContractState contract_to = engine.Snapshot.Contracts.TryGet(to); - if (contract_to?.Payable == false) return false; StorageKey key_from = CreateStorageKey(Prefix_Account).Add(from); StorageItem storage_from = engine.Snapshot.Storages.GetAndChange(key_from); if (amount.IsZero) diff --git a/tests/neo.UnitTests/Ledger/UT_ContractState.cs b/tests/neo.UnitTests/Ledger/UT_ContractState.cs index 76c48c4c3e..8fe1930adf 100644 --- a/tests/neo.UnitTests/Ledger/UT_ContractState.cs +++ b/tests/neo.UnitTests/Ledger/UT_ContractState.cs @@ -27,18 +27,6 @@ public void TestSetup() }; } - [TestMethod] - public void TestGetHasStorage() - { - contract.HasStorage.Should().BeFalse(); - } - - [TestMethod] - public void TestGetPayable() - { - contract.Payable.Should().BeFalse(); - } - [TestMethod] public void TestGetScriptHash() { @@ -84,7 +72,7 @@ public void TestDeserialize() public void TestGetSize() { ISerializable newContract = contract; - newContract.Size.Should().Be(265); + newContract.Size.Should().Be(218); } [TestMethod] diff --git a/tests/neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs b/tests/neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs index fbd8e10f4e..44c621870f 100644 --- a/tests/neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs +++ b/tests/neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs @@ -11,7 +11,7 @@ public class UT_ContractManifest [TestMethod] public void ParseFromJson_Default() { - var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safemethods"":[],""extra"":null}"; + var json = @"{""groups"":[],""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safemethods"":[],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToString(), json); @@ -19,22 +19,10 @@ public void ParseFromJson_Default() Assert.IsTrue(manifest.IsValid(UInt160.Zero)); } - [TestMethod] - public void ParseFromJson_Features() - { - var json = @"{""groups"":[],""features"":{""storage"":true,""payable"":true},""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safemethods"":[],""extra"":null}"; - var manifest = ContractManifest.Parse(json); - Assert.AreEqual(manifest.ToJson().ToString(), json); - - var check = TestUtils.CreateDefaultManifest(UInt160.Zero); - check.Features = ContractFeatures.HasStorage | ContractFeatures.Payable; - Assert.AreEqual(manifest.ToString(), check.ToString()); - } - [TestMethod] public void ParseFromJson_Permissions() { - var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""0x0000000000000000000000000000000000000000"",""methods"":[""method1"",""method2""]}],""trusts"":[],""safemethods"":[],""extra"":null}"; + var json = @"{""groups"":[],""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""0x0000000000000000000000000000000000000000"",""methods"":[""method1"",""method2""]}],""trusts"":[],""safemethods"":[],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToString(), json); @@ -53,7 +41,7 @@ public void ParseFromJson_Permissions() [TestMethod] public void ParseFromJson_SafeMethods() { - var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safemethods"":[""balanceOf""],""extra"":null}"; + var json = @"{""groups"":[],""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safemethods"":[""balanceOf""],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToString(), json); @@ -65,7 +53,7 @@ public void ParseFromJson_SafeMethods() [TestMethod] public void ParseFromJson_Trust() { - var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[""0x0000000000000000000000000000000000000001""],""safemethods"":[],""extra"":null}"; + var json = @"{""groups"":[],""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[""0x0000000000000000000000000000000000000001""],""safemethods"":[],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToString(), json); @@ -77,7 +65,7 @@ public void ParseFromJson_Trust() [TestMethod] public void ParseFromJson_Groups() { - var json = @"{""groups"":[{""pubkey"":""03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c"",""signature"":""QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQQ==""}],""features"":{""storage"":false,""payable"":false},""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safemethods"":[],""extra"":null}"; + var json = @"{""groups"":[{""pubkey"":""03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c"",""signature"":""QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQQ==""}],""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safemethods"":[],""extra"":null}"; var manifest = ContractManifest.Parse(json); Assert.AreEqual(manifest.ToString(), json); @@ -89,7 +77,7 @@ public void ParseFromJson_Groups() [TestMethod] public void ParseFromJson_Extra() { - var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safemethods"":[],""extra"":{""key"":""value""}}"; + var json = @"{""groups"":[],""supportedstandards"":[],""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""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); @@ -122,7 +110,7 @@ public void TestGetHash() public void TestGetSize() { var temp = TestUtils.CreateDefaultManifest(UInt160.Zero); - Assert.AreEqual(259, temp.Size); + Assert.AreEqual(212, temp.Size); } [TestMethod] diff --git a/tests/neo.UnitTests/SmartContract/UT_InteropPrices.cs b/tests/neo.UnitTests/SmartContract/UT_InteropPrices.cs index 00e3d09444..fbea2b839d 100644 --- a/tests/neo.UnitTests/SmartContract/UT_InteropPrices.cs +++ b/tests/neo.UnitTests/SmartContract/UT_InteropPrices.cs @@ -2,7 +2,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Neo.Ledger; using Neo.SmartContract; -using Neo.SmartContract.Manifest; using Neo.VM; namespace Neo.UnitTests.SmartContract @@ -56,7 +55,6 @@ public void ApplicationEngineRegularPut() byte[] script = CreatePutScript(key, value); ContractState contractState = TestUtils.GetContract(script); - contractState.Manifest.Features = ContractFeatures.HasStorage; StorageKey skey = TestUtils.GetStorageKey(contractState.Id, key); StorageItem sItem = TestUtils.GetStorageItem(new byte[0] { }); @@ -90,7 +88,6 @@ public void ApplicationEngineReusedStorage_FullReuse() byte[] script = CreatePutScript(key, value); ContractState contractState = TestUtils.GetContract(script); - contractState.Manifest.Features = ContractFeatures.HasStorage; StorageKey skey = TestUtils.GetStorageKey(contractState.Id, key); StorageItem sItem = TestUtils.GetStorageItem(value); @@ -126,7 +123,6 @@ public void ApplicationEngineReusedStorage_PartialReuse() byte[] script = CreatePutScript(key, value); ContractState contractState = TestUtils.GetContract(script); - contractState.Manifest.Features = ContractFeatures.HasStorage; StorageKey skey = TestUtils.GetStorageKey(contractState.Id, key); StorageItem sItem = TestUtils.GetStorageItem(oldValue); @@ -163,7 +159,6 @@ public void ApplicationEngineReusedStorage_PartialReuseTwice() byte[] script = CreateMultiplePutScript(key, value); ContractState contractState = TestUtils.GetContract(script); - contractState.Manifest.Features = ContractFeatures.HasStorage; StorageKey skey = TestUtils.GetStorageKey(contractState.Id, key); StorageItem sItem = TestUtils.GetStorageItem(oldValue); diff --git a/tests/neo.UnitTests/SmartContract/UT_InteropService.NEO.cs b/tests/neo.UnitTests/SmartContract/UT_InteropService.NEO.cs index b86276501f..72a682df98 100644 --- a/tests/neo.UnitTests/SmartContract/UT_InteropService.NEO.cs +++ b/tests/neo.UnitTests/SmartContract/UT_InteropService.NEO.cs @@ -176,10 +176,8 @@ public void TestContract_Update() Signature = signature } }; - manifest.Features = ContractFeatures.HasStorage; var snapshot = Blockchain.Singleton.GetSnapshot(); var state = TestUtils.GetContract(); - state.Manifest.Features = ContractFeatures.HasStorage; var storageItem = new StorageItem { Value = new byte[] { 0x01 }, @@ -215,7 +213,6 @@ public void TestStorage_Find() { var snapshot = Blockchain.Singleton.GetSnapshot(); var state = TestUtils.GetContract(); - state.Manifest.Features = ContractFeatures.HasStorage; var storageItem = new StorageItem { diff --git a/tests/neo.UnitTests/SmartContract/UT_InteropService.cs b/tests/neo.UnitTests/SmartContract/UT_InteropService.cs index 85e74ef265..21e405f90d 100644 --- a/tests/neo.UnitTests/SmartContract/UT_InteropService.cs +++ b/tests/neo.UnitTests/SmartContract/UT_InteropService.cs @@ -400,7 +400,6 @@ public void TestStorage_GetContext() { var engine = GetEngine(false, true); var state = TestUtils.GetContract(); - state.Manifest.Features = ContractFeatures.HasStorage; engine.Snapshot.Contracts.Add(state.ScriptHash, state); engine.LoadScript(state.Script); engine.GetStorageContext().IsReadOnly.Should().BeFalse(); @@ -411,7 +410,6 @@ public void TestStorage_GetReadOnlyContext() { var engine = GetEngine(false, true); var state = TestUtils.GetContract(); - state.Manifest.Features = ContractFeatures.HasStorage; engine.Snapshot.Contracts.Add(state.ScriptHash, state); engine.LoadScript(state.Script); engine.GetReadOnlyContext().IsReadOnly.Should().BeTrue(); @@ -422,7 +420,6 @@ public void TestStorage_Get() { var snapshot = Blockchain.Singleton.GetSnapshot(); var state = TestUtils.GetContract(); - state.Manifest.Features = ContractFeatures.HasStorage; var storageKey = new StorageKey { @@ -481,7 +478,6 @@ public void TestStorage_Put() //storage value is constant var snapshot = Blockchain.Singleton.GetSnapshot(); - state.Manifest.Features = ContractFeatures.HasStorage; var storageKey = new StorageKey { @@ -515,10 +511,8 @@ public void TestStorage_Put() [TestMethod] public void TestStorage_PutEx() { - var engine = GetEngine(false, true); var snapshot = Blockchain.Singleton.GetSnapshot(); var state = TestUtils.GetContract(); - state.Manifest.Features = ContractFeatures.HasStorage; var storageKey = new StorageKey { Id = 0x42000000, @@ -531,7 +525,7 @@ public void TestStorage_PutEx() }; snapshot.Contracts.Add(state.ScriptHash, state); snapshot.Storages.Add(storageKey, storageItem); - engine = ApplicationEngine.Create(TriggerType.Application, null, snapshot); + var engine = ApplicationEngine.Create(TriggerType.Application, null, snapshot); engine.LoadScript(new byte[] { 0x01 }); var key = new byte[] { 0x01 }; var value = new byte[] { 0x02 }; @@ -549,7 +543,6 @@ public void TestStorage_Delete() var engine = GetEngine(false, true); var snapshot = Blockchain.Singleton.GetSnapshot(); var state = TestUtils.GetContract(); - state.Manifest.Features = ContractFeatures.HasStorage; var storageKey = new StorageKey { Id = 0x42000000, @@ -564,7 +557,6 @@ public void TestStorage_Delete() snapshot.Storages.Add(storageKey, storageItem); engine = ApplicationEngine.Create(TriggerType.Application, null, snapshot); engine.LoadScript(new byte[] { 0x01 }); - state.Manifest.Features = ContractFeatures.HasStorage; var key = new byte[] { 0x01 }; var storageContext = new StorageContext { @@ -598,7 +590,6 @@ public void TestContract_Call() string method = "method"; var args = new VM.Types.Array { 0, 1 }; var state = TestUtils.GetContract(method, args.Count); - state.Manifest.Features = ContractFeatures.HasStorage; snapshot.Contracts.Add(state.ScriptHash, state); var engine = ApplicationEngine.Create(TriggerType.Application, null, snapshot); @@ -625,7 +616,6 @@ public void TestContract_CallEx() string method = "method"; var args = new VM.Types.Array { 0, 1 }; var state = TestUtils.GetContract(method, args.Count); - state.Manifest.Features = ContractFeatures.HasStorage; snapshot.Contracts.Add(state.ScriptHash, state); @@ -656,7 +646,6 @@ public void TestContract_Destroy() var snapshot = Blockchain.Singleton.GetSnapshot(); var state = TestUtils.GetContract(); - state.Manifest.Features = ContractFeatures.HasStorage; var scriptHash = UInt160.Parse("0xcb9f3b7c6fb1cf2c13a40637c189bdd066a272b4"); var storageItem = new StorageItem { diff --git a/tests/neo.UnitTests/TestUtils.cs b/tests/neo.UnitTests/TestUtils.cs index 9e12f702ae..2a4cb10cc3 100644 --- a/tests/neo.UnitTests/TestUtils.cs +++ b/tests/neo.UnitTests/TestUtils.cs @@ -23,7 +23,6 @@ public static ContractManifest CreateDefaultManifest(UInt160 hash) return new ContractManifest() { Groups = new ContractGroup[0], - Features = ContractFeatures.NoProperty, SupportedStandards = Array.Empty(), Abi = new ContractAbi() {