Skip to content

Commit

Permalink
show all type and value of stack item
Browse files Browse the repository at this point in the history
  • Loading branch information
superboyiii committed Dec 1, 2023
1 parent e7e3e8f commit 2ced172
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
33 changes: 21 additions & 12 deletions src/ApplicationLogs/LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,19 @@ public static JObject TxLogToJson(Blockchain.ApplicationExecuted appExec)
trigger["vmstate"] = appExec.VMState;
trigger["exception"] = GetExceptionMessage(appExec.Exception);
trigger["gasconsumed"] = appExec.GasConsumed.ToString();
try
var stack = new JArray();
foreach (var item in appExec.Stack)
{
trigger["stack"] = appExec.Stack.Select(q => q.ToJson(Settings.Default.MaxStackSize)).ToArray();
}
catch (InvalidOperationException)
{
trigger["stack"] = "error: invalid operation";
try
{
stack.Add(item.ToJson());
}
catch (InvalidOperationException)
{
stack.Add("error: invalid operation");
}
}
trigger["stack"] = stack;
trigger["notifications"] = appExec.Notifications.Select(q =>
{
JObject notification = new JObject();
Expand Down Expand Up @@ -133,13 +138,17 @@ public static JObject BlockLogToJson(Block block, IReadOnlyList<Blockchain.Appli
trigger["trigger"] = appExec.Trigger;
trigger["vmstate"] = appExec.VMState;
trigger["gasconsumed"] = appExec.GasConsumed.ToString();
try
var stack = new JArray();
foreach (var item in appExec.Stack)
{
trigger["stack"] = appExec.Stack.Select(q => q.ToJson(Settings.Default.MaxStackSize)).ToArray();
}
catch (InvalidOperationException)
{
trigger["stack"] = "error: invalid operation";
try
{
stack.Add(item.ToJson());
}
catch (InvalidOperationException)
{
stack.Add("error: invalid operation");
}
}
trigger["notifications"] = appExec.Notifications.Select(q =>
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Update="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Update="MSTest.TestFramework" Version="3.1.1" />
</ItemGroup>
Expand Down

0 comments on commit 2ced172

Please sign in to comment.