diff --git a/tests/neo.UnitTests/SmartContract/Native/Tokens/UT_NeoToken.cs b/tests/neo.UnitTests/SmartContract/Native/Tokens/UT_NeoToken.cs index 3822fe4260..d7e117b870 100644 --- a/tests/neo.UnitTests/SmartContract/Native/Tokens/UT_NeoToken.cs +++ b/tests/neo.UnitTests/SmartContract/Native/Tokens/UT_NeoToken.cs @@ -570,6 +570,33 @@ public void TestGetCandidates2() NativeContract.NEO.GetCandidates(snapshot).Length.Should().Be(1); } + [TestMethod] + public void TestCheckCandidate() + { + var snapshot = Blockchain.Singleton.GetSnapshot(); + var committee = NativeContract.NEO.GetCommittee(snapshot); + var point = committee[0].EncodePoint(true); + + // Prepare Prefix_VoterRewardPerCommittee + var storageKey = new KeyBuilder(-1, 23).Add(committee[0]).AddBigEndian(20); + snapshot.Storages.Add(storageKey, new StorageItem(new BigInteger(1000))); + + // Prepare Candidate + storageKey = new KeyBuilder(-1, 33).Add(committee[0]); + snapshot.Storages.Add(storageKey, new StorageItem(new CandidateState { Registered = true, Votes = BigInteger.One })); + + // Unregister candidate + var ret = Check_UnregisterCandidate(snapshot, point); + ret.State.Should().BeTrue(); + ret.Result.Should().BeTrue(); + + snapshot.PersistingBlock = new Block { Index = 21 }; + Check_PostPersist(snapshot).Should().BeTrue(); + + storageKey = new KeyBuilder(-1, 23).Add(committee[0]); + snapshot.Storages.Find(storageKey.ToArray()).ToArray().Length.Should().Be(1); + } + [TestMethod] public void TestGetCommittee() {