Skip to content

Commit

Permalink
Testing: Skip ut (#1269)
Browse files Browse the repository at this point in the history
* Skip ut

* Persist

* Next block
  • Loading branch information
shargon authored Dec 22, 2024
1 parent 81a0753 commit 6ddf726
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Neo.SmartContract.Testing/PersistingBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ public void Skip(uint count, TimeSpan elapsed)
UnderlyingBlock.Header.Timestamp += (ulong)elapsed.TotalMilliseconds;
}

/// <summary>
/// Persist block
/// </summary>
/// <returns>Persisted block</returns>
public Block Persist()
{
return Persist([], []);
}

/// <summary>
/// Persist block
/// </summary>
Expand Down
22 changes: 22 additions & 0 deletions tests/Neo.SmartContract.Testing.UnitTests/TestEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Neo.SmartContract.Testing.Native;
using Neo.VM;
using Neo.VM.Types;
using System;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
Expand Down Expand Up @@ -32,6 +33,27 @@ public void GenerateNativeArtifacts()
}
}

[TestMethod]
public void TestSkip()
{
TestEngine engine = new(true);

Assert.AreEqual(0L, engine.Native.Ledger.CurrentIndex);
engine.PersistingBlock.Skip(10, TimeSpan.Zero);
engine.PersistingBlock.Persist();
Assert.AreEqual(11L, engine.Native.Ledger.CurrentIndex);
}

[TestMethod]
public void TestNextBlock()
{
TestEngine engine = new(true);

Assert.AreEqual(0L, engine.Native.Ledger.CurrentIndex);
engine.PersistingBlock.Persist();
Assert.AreEqual(1L, engine.Native.Ledger.CurrentIndex);
}

[TestMethod]
public void TestOnGetEntryScriptHash()
{
Expand Down

0 comments on commit 6ddf726

Please sign in to comment.