From 7a71114816a8295e06cc6b070e1ac5c0ef097a9d Mon Sep 17 00:00:00 2001 From: ixje Date: Mon, 16 Sep 2024 11:50:09 +0200 Subject: [PATCH] api: extend `get_version` RPC call with extra fields (#311) --- neo3/api/noderpc.py | 11 +++++++++++ tests/api/test_noderpc.py | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/neo3/api/noderpc.py b/neo3/api/noderpc.py index 8b85bcf..a8e363d 100644 --- a/neo3/api/noderpc.py +++ b/neo3/api/noderpc.py @@ -91,6 +91,7 @@ class VersionProtocol: max_valid_until_block_increment: int memorypool_max_transactions: int initial_gas_distribution: int + hardforks: dict[str, int] @dataclass @@ -104,10 +105,17 @@ class GetVersionResponse: nonce: int user_agent: str protocol: VersionProtocol + rpc_session_enabled: bool + rpc_max_iterator_results: int @classmethod def from_json(cls, json: dict): p = json["protocol"] + + hf = {} + for pair in p["hardforks"]: + hf.update({pair["name"]: pair["blockheight"]}) + vp = VersionProtocol( p["addressversion"], p["network"], @@ -118,6 +126,7 @@ def from_json(cls, json: dict): p["maxvaliduntilblockincrement"], p["memorypoolmaxtransactions"], p["initialgasdistribution"], + hf, ) wsport = json.get("wsport", None) return cls( @@ -126,6 +135,8 @@ def from_json(cls, json: dict): json["nonce"], json["useragent"], vp, + json["rpc"]["sessionenabled"], + json["rpc"]["maxiteratorresultitems"], ) diff --git a/tests/api/test_noderpc.py b/tests/api/test_noderpc.py index ec5ec99..53a58c9 100644 --- a/tests/api/test_noderpc.py +++ b/tests/api/test_noderpc.py @@ -558,6 +558,7 @@ async def test_get_version(self): "wsport": 10334, "nonce": 1930156121, "useragent": user_agent, + "rpc": {"maxiteratorresultitems": 100, "sessionenabled": True}, "protocol": { "addressversion": 53, "network": 860833102, @@ -568,6 +569,12 @@ async def test_get_version(self): "maxtransactionsperblock": 512, "memorypoolmaxtransactions": 50000, "initialgasdistribution": 5200000000000000, + "hardforks": [ + {"name": "Aspidochelone", "blockheight": 1730000}, + {"name": "Basilisk", "blockheight": 4120000}, + {"name": "Cockatrice", "blockheight": 5450000}, + {"name": "Domovoi", "blockheight": 5570000}, + ], }, } self.mock_response(captured)