Skip to content

Commit f2c5691

Browse files
committed
fix: resolve issue with conflicting retry param
1 parent d1a8f80 commit f2c5691

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

async_substrate_interface/substrate_addons.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ def __init__(
171171
for method in retry_methods:
172172
setattr(self, method, partial(self._retry, method))
173173

174-
def _retry(self, method, *args, **kwargs):
175-
method_ = self._original_methods[method]
174+
def _retry(self, method_name, *args, **kwargs):
175+
method_ = self._original_methods[method_name]
176176
try:
177177
return method_(*args, **kwargs)
178178
except (
@@ -341,8 +341,8 @@ async def _reinstantiate_substrate(
341341
self._initializing = False
342342
await self.initialize()
343343

344-
async def _retry(self, method, *args, **kwargs):
345-
method_ = self._original_methods[method]
344+
async def _retry(self, method_name, *args, **kwargs):
345+
method_ = self._original_methods[method_name]
346346
try:
347347
return await method_(*args, **kwargs)
348348
except (

tests/e2e_tests/test_substrate_addons.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,36 @@ def test_retry_sync_subtensor_archive_node():
105105
LATENT_LITE_ENTRYPOINT, archive_nodes=[ARCHIVE_ENTRYPOINT]
106106
) as substrate:
107107
assert isinstance((substrate.get_block(block_number=old_block)), dict)
108+
109+
110+
@pytest.mark.asyncio
111+
async def test_retry_async_substrate_runtime_call_with_keyword_args():
112+
"""Test that runtime_call works with keyword arguments (parameter name conflict fix)."""
113+
async with RetryAsyncSubstrate(
114+
LATENT_LITE_ENTRYPOINT, retry_forever=True
115+
) as substrate:
116+
# This should not raise TypeError due to parameter name conflict
117+
# The 'method' kwarg should not conflict with _retry's parameter
118+
result = await substrate.runtime_call(
119+
api="SwapRuntimeApi",
120+
method="current_alpha_price",
121+
params=[1],
122+
block_hash=None,
123+
)
124+
assert result is not None
125+
126+
127+
def test_retry_sync_substrate_runtime_call_with_keyword_args():
128+
"""Test that runtime_call works with keyword arguments (parameter name conflict fix)."""
129+
with RetrySyncSubstrate(
130+
LATENT_LITE_ENTRYPOINT, retry_forever=True
131+
) as substrate:
132+
# This should not raise TypeError due to parameter name conflict
133+
# The 'method' kwarg should not conflict with _retry's parameter
134+
result = substrate.runtime_call(
135+
api="SwapRuntimeApi",
136+
method="current_alpha_price",
137+
params=[1],
138+
block_hash=None,
139+
)
140+
assert result is not None

0 commit comments

Comments
 (0)