N3developertoolkit / neo-test

Neo N3 smart contract unit test framework
MIT License
6 stars 2 forks source link

Test Runner generating invalid result json when there's iterators in the result stack #46

Open meevee98 opened 1 year ago

meevee98 commented 1 year ago

I'm using Neo Test Runner to run some tests and found out that it generates a invalid json when the invocation has interators in its results image

I am testing a simple smart contract written in Python:

from typing import Union, Any

from boa3.builtin.compile_time import NeoMetadata, public
from boa3.builtin.interop import storage
from boa3.builtin.interop.iterator import Iterator
from boa3.builtin.type import ByteString

@metadata
def manifest_metadata() -> NeoMetadata:
    meta = NeoMetadata()
    meta.name = 'Example'
    return meta

@public
def find_by_prefix(prefix: bytes) -> Iterator:
    return storage.find(prefix)

@public
def put_on_storage(key: ByteString, value: Union[int, ByteString]):
    storage.put(key, value)

@public
def _deploy(data: Any, update: bool):
    # test data to test in unit tests
    storage.put('example_0', '0')
    storage.put('example_1', '1')
    storage.put('example_2', '2')

with this invoke file:

[{"contract":"Example","operation":"find_by_prefix","args":["0x74657374"]},{"contract":"Example","operation":"find_by_prefix","args":["0x6578616d706c65"]}]