Skip to content

Commit

Permalink
Change GetScriptContainer returns (#2312)
Browse files Browse the repository at this point in the history
* Add native contract: StdLib

* format

* Add CryptoLib

* Add SCriptContainer.GetHashData

* Return object instead of interop

* Fix UT

* Fix of fix

Co-authored-by: Erik Zhang <erik@neo.org>
Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com>
  • Loading branch information
3 people authored Feb 9, 2021
1 parent 9fe018c commit 6cb8cc9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/neo/SmartContract/ApplicationEngine.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Neo.IO;
using Neo.Network.P2P.Payloads;
using Neo.SmartContract.Native;
using Neo.VM.Types;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -39,9 +40,10 @@ protected internal ulong GetTime()
return PersistingBlock.Timestamp;
}

protected internal IInteroperable GetScriptContainer()
protected internal StackItem GetScriptContainer()
{
return ScriptContainer as IInteroperable;
if (ScriptContainer is not IInteroperable interop) throw new InvalidOperationException();
return interop.ToStackItem(ReferenceCounter);
}

protected internal bool CheckWitness(byte[] hashOrPubkey)
Expand Down
2 changes: 1 addition & 1 deletion tests/neo.UnitTests/SmartContract/UT_InteropService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private static void AssertNotification(StackItem stackItem, UInt160 scriptHash,
[TestMethod]
public void TestExecutionEngine_GetScriptContainer()
{
GetEngine(true).GetScriptContainer().Should().BeOfType<Transaction>();
GetEngine(true).GetScriptContainer().Should().BeOfType<VM.Types.Array>();
}

[TestMethod]
Expand Down
5 changes: 2 additions & 3 deletions tests/neo.UnitTests/SmartContract/UT_Syscalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ public void System_ExecutionEngine_GetScriptContainer()
var engine = ApplicationEngine.Create(TriggerType.Application, null, snapshot);
engine.LoadScript(script.ToArray());

Assert.AreEqual(engine.Execute(), VMState.HALT);
Assert.AreEqual(1, engine.ResultStack.Count);
Assert.IsTrue(engine.ResultStack.Peek().IsNull);
Assert.AreEqual(engine.Execute(), VMState.FAULT);
Assert.AreEqual(0, engine.ResultStack.Count);

// With tx

Expand Down

0 comments on commit 6cb8cc9

Please sign in to comment.