Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change GetScriptContainer returns #2312

Merged
merged 14 commits into from
Feb 9, 2021
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