Skip to content

Commit

Permalink
Fix some tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
TeknoPT committed Sep 22, 2023
1 parent 52e89b8 commit f958b09
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Library/tests/Contracts/SwitchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public check(x:decimal<2>): decimal<2> {
default: _value = 5.00m; break;
}

vm.Stack.Push(VMObject.FromObject(_value));
vm.Stack.Push(VMObject.FromObject(UnitConversion.ToBigInteger(_value, 2)));
var state = vm.Execute();
Assert.IsTrue(state == ExecutionState.Halt);
var obj = vm.Stack.Pop();
Expand Down
16 changes: 16 additions & 0 deletions Library/tests/TestVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Phantasma.Core.Numerics;
using Phantasma.Tomb.CodeGen;
using System.Numerics;
using Phantasma.Core.Domain.Events.Structs;
using ExecutionContext = Phantasma.Core.Domain.Execution.ExecutionContext;

namespace TOMBLib.Tests;
Expand Down Expand Up @@ -48,6 +49,7 @@ public TestVM(Module module, Dictionary<byte[], byte[]> storage, ContractMethod
RegisterMethod("Runtime.Context", Runtime_Context);
RegisterMethod("Runtime.ReadInfusions", Runtime_ReadInfusions);
RegisterMethod("Runtime.GetOwnerships", Runtime_GetOwnerships);
RegisterMethod("Runtime.Notify", Runtime_Notify);

RegisterMethod("Runtime.GetAvailableTokenSymbols", Runtime_GetAvailableTokenSymbols);

Expand Down Expand Up @@ -207,6 +209,20 @@ private ExecutionState Runtime_GetOwnerships(VirtualMachine vm)

return ExecutionState.Running;
}

private ExecutionState Runtime_Notify(VirtualMachine vm)
{
var kind = vm.Stack.Pop().AsEnum<EventKind>();
var address = vm.Stack.Pop().AsAddress();
var obj = vm.Stack.Pop();

var array = new BigInteger[] { 123, 456, 789 };

var val = VMObject.FromArray(array);
this.Stack.Push(val);

return ExecutionState.Running;
}

private ExecutionState Runtime_ReadInfusions(VirtualMachine vm)
{
Expand Down

0 comments on commit f958b09

Please sign in to comment.