Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommo-L committed Oct 29, 2020
1 parent 15792c2 commit 44bdd5c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/neo.UnitTests/SmartContract/Native/Tokens/UT_NeoToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 44bdd5c

Please sign in to comment.