Skip to content

Commit

Permalink
Fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
cschuchardt88 committed Dec 3, 2024
1 parent a1177d7 commit 9056189
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/Neo/Extensions/VM/StackItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@

using Neo.Json;
using Neo.SmartContract;

#if !NET5_0_OR_GREATER
using Neo.VM;
#endif

using Neo.VM.Types;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -52,12 +48,13 @@ public static JObject ToJson(this StackItem item, HashSet<StackItem> context, re
case Array array:
{
context ??= new(ReferenceEqualityComparer.Instance);
if (!context.Add(array)) throw new InvalidOperationException();
if (!context.Add(array)) throw new InvalidOperationException("Circular reference.");
maxSize -= 2/*[]*/+ Math.Max(0, (array.Count - 1))/*,*/;
JArray a = [];
foreach (var stackItem in array)
a.Add(ToJson(stackItem, context, ref maxSize));
value = a;
if (!context.Remove(array)) throw new InvalidOperationException("Circular reference.");
break;
}
case Boolean boolean:
Expand Down Expand Up @@ -85,9 +82,9 @@ public static JObject ToJson(this StackItem item, HashSet<StackItem> context, re
case Map map:
{
context ??= new(ReferenceEqualityComparer.Instance);
if (!context.Add(map)) throw new InvalidOperationException();
if (!context.Add(map)) throw new InvalidOperationException("Circular reference.");
maxSize -= 2/*[]*/+ Math.Max(0, (map.Count - 1))/*,*/;
JArray a = [];
JArray a = new();
foreach (var (k, v) in map)
{
maxSize -= 17/*{"key":,"value":}*/;
Expand All @@ -99,6 +96,7 @@ public static JObject ToJson(this StackItem item, HashSet<StackItem> context, re
a.Add(i);
}
value = a;
if (!context.Remove(map)) throw new InvalidOperationException("Circular reference.");
break;
}
case Pointer pointer:
Expand Down

0 comments on commit 9056189

Please sign in to comment.