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

api: fix type error when contract state not found #303

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions neo3/api/noderpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,10 +930,11 @@ async def find_states(
response = await self._do_post(
"findstorage", [contract_hash, _prefix, start]
)
for pair in response["results"]:
key = base64.b64decode(pair["key"])
value = base64.b64decode(pair["value"])
yield key, value
if response["results"] is not None:
for pair in response["results"]:
key = base64.b64decode(pair["key"])
value = base64.b64decode(pair["value"])
yield key, value
if not response["truncated"]:
break
start = response["next"]
Expand Down
8 changes: 8 additions & 0 deletions tests/api/test_noderpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,14 @@ async def test_exception(self):
self.assertIn("bogus_message", str(context.exception))
self.assertIn("bogus_data", str(context.exception))

async def test_findstorage_issue_neogo(self):
# test workaround for https://github.com/nspcc-dev/neo-go/issues/3370
captured = {"results": None, "next": 0, "truncated": False}
self.mock_response(captured)

x = [(k, v) async for k, v in self.client.find_states(types.UInt160.zero())]
self.assertEqual(0, len(x))


class TestStackItem(unittest.TestCase):
@classmethod
Expand Down
Loading