From f2c5691d7c1779ac0ba105a8d77fd13870cf74ff Mon Sep 17 00:00:00 2001 From: Arthurdw Date: Tue, 21 Oct 2025 16:23:55 +0200 Subject: [PATCH] fix: resolve issue with conflicting retry param --- async_substrate_interface/substrate_addons.py | 8 ++--- tests/e2e_tests/test_substrate_addons.py | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/async_substrate_interface/substrate_addons.py b/async_substrate_interface/substrate_addons.py index 3b0f0ba..5c548ce 100644 --- a/async_substrate_interface/substrate_addons.py +++ b/async_substrate_interface/substrate_addons.py @@ -171,8 +171,8 @@ def __init__( for method in retry_methods: setattr(self, method, partial(self._retry, method)) - def _retry(self, method, *args, **kwargs): - method_ = self._original_methods[method] + def _retry(self, method_name, *args, **kwargs): + method_ = self._original_methods[method_name] try: return method_(*args, **kwargs) except ( @@ -341,8 +341,8 @@ async def _reinstantiate_substrate( self._initializing = False await self.initialize() - async def _retry(self, method, *args, **kwargs): - method_ = self._original_methods[method] + async def _retry(self, method_name, *args, **kwargs): + method_ = self._original_methods[method_name] try: return await method_(*args, **kwargs) except ( diff --git a/tests/e2e_tests/test_substrate_addons.py b/tests/e2e_tests/test_substrate_addons.py index c776506..bcf8750 100644 --- a/tests/e2e_tests/test_substrate_addons.py +++ b/tests/e2e_tests/test_substrate_addons.py @@ -105,3 +105,36 @@ def test_retry_sync_subtensor_archive_node(): LATENT_LITE_ENTRYPOINT, archive_nodes=[ARCHIVE_ENTRYPOINT] ) as substrate: assert isinstance((substrate.get_block(block_number=old_block)), dict) + + +@pytest.mark.asyncio +async def test_retry_async_substrate_runtime_call_with_keyword_args(): + """Test that runtime_call works with keyword arguments (parameter name conflict fix).""" + async with RetryAsyncSubstrate( + LATENT_LITE_ENTRYPOINT, retry_forever=True + ) as substrate: + # This should not raise TypeError due to parameter name conflict + # The 'method' kwarg should not conflict with _retry's parameter + result = await substrate.runtime_call( + api="SwapRuntimeApi", + method="current_alpha_price", + params=[1], + block_hash=None, + ) + assert result is not None + + +def test_retry_sync_substrate_runtime_call_with_keyword_args(): + """Test that runtime_call works with keyword arguments (parameter name conflict fix).""" + with RetrySyncSubstrate( + LATENT_LITE_ENTRYPOINT, retry_forever=True + ) as substrate: + # This should not raise TypeError due to parameter name conflict + # The 'method' kwarg should not conflict with _retry's parameter + result = substrate.runtime_call( + api="SwapRuntimeApi", + method="current_alpha_price", + params=[1], + block_hash=None, + ) + assert result is not None