From 81b6ed231570f1f0cb90077b33b2726b34ec7367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Thu, 4 Jul 2024 15:04:39 +0800 Subject: [PATCH 1/2] Update ContractPermissionDescriptor.cs --- src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs b/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs index f1f22d99d8..d950d25c62 100644 --- a/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs +++ b/src/Neo/SmartContract/Manifest/ContractPermissionDescriptor.cs @@ -114,7 +114,8 @@ public bool Equals(ContractPermissionDescriptor other) if (this == other) return true; if (IsWildcard == other.IsWildcard) return true; if (IsHash) return Hash.Equals(other.Hash); - else return Group.Equals(other.Group); + if (IsGroup) return Group.Equals(other.Group); + return false; } public override int GetHashCode() From 3979d542cbe15a799e6fad6d2eee6df20b88c86b Mon Sep 17 00:00:00 2001 From: Fernando Diaz Toledano Date: Thu, 4 Jul 2024 09:44:35 +0200 Subject: [PATCH 2/2] Add UT --- .../Manifest/UT_ContractPermissionDescriptor.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/Neo.UnitTests/SmartContract/Manifest/UT_ContractPermissionDescriptor.cs b/tests/Neo.UnitTests/SmartContract/Manifest/UT_ContractPermissionDescriptor.cs index 0dee8b0f67..1ef2397d69 100644 --- a/tests/Neo.UnitTests/SmartContract/Manifest/UT_ContractPermissionDescriptor.cs +++ b/tests/Neo.UnitTests/SmartContract/Manifest/UT_ContractPermissionDescriptor.cs @@ -11,6 +11,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Neo.SmartContract.Manifest; +using Neo.SmartContract.Native; using Neo.Wallets; using System.Security.Cryptography; @@ -44,5 +45,18 @@ public void TestFromAndToJson() Assert.AreEqual(null, result.Hash); Assert.AreEqual(result.Group, result.Group); } + + [TestMethod] + public void TestEquals() + { + var descriptor1 = ContractPermissionDescriptor.CreateWildcard(); + var descriptor2 = ContractPermissionDescriptor.Create(LedgerContract.NEO.Hash); + + Assert.AreNotEqual(descriptor1, descriptor2); + + var descriptor3 = ContractPermissionDescriptor.Create(LedgerContract.NEO.Hash); + + Assert.AreEqual(descriptor2, descriptor3); + } } }