Skip to content
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
8 changes: 4 additions & 4 deletions async_substrate_interface/substrate_addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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 (
Expand Down
33 changes: 33 additions & 0 deletions tests/e2e_tests/test_substrate_addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading