Skip to content

Commit f1d5de3

Browse files
committed
Added tests
1 parent 6ef9efd commit f1d5de3

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

tests/test_substrate_addons.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
import pytest
55
import time
66

7-
from async_substrate_interface.substrate_addons import RetrySyncSubstrate
8-
from async_substrate_interface.errors import MaxRetriesExceeded
7+
from async_substrate_interface import AsyncSubstrateInterface, SubstrateInterface
8+
from async_substrate_interface.substrate_addons import (
9+
RetrySyncSubstrate,
10+
RetryAsyncSubstrate,
11+
)
12+
from async_substrate_interface.errors import MaxRetriesExceeded, StateDiscardedError
913
from tests.conftest import start_docker_container
1014

1115
LATENT_LITE_ENTRYPOINT = "wss://lite.sub.latent.to:443"
@@ -70,3 +74,28 @@ def test_retry_sync_substrate_offline():
7074
RetrySyncSubstrate(
7175
"ws://127.0.0.1:9945", fallback_chains=["ws://127.0.0.1:9946"]
7276
)
77+
78+
79+
@pytest.mark.asyncio
80+
async def test_retry_async_subtensor_archive_node():
81+
async with AsyncSubstrateInterface("wss://lite.sub.latent.to:443") as substrate:
82+
current_block = await substrate.get_block_number()
83+
old_block = current_block - 1000
84+
with pytest.raises(StateDiscardedError):
85+
await substrate.get_block(block_number=old_block)
86+
async with RetryAsyncSubstrate(
87+
"wss://lite.sub.latent.to:443", archive_nodes=["ws://178.156.172.75:9944"]
88+
) as substrate:
89+
assert isinstance((await substrate.get_block(block_number=old_block)), dict)
90+
91+
92+
def test_retry_sync_subtensor_archive_node():
93+
with SubstrateInterface("wss://lite.sub.latent.to:443") as substrate:
94+
current_block = substrate.get_block_number()
95+
old_block = current_block - 1000
96+
with pytest.raises(StateDiscardedError):
97+
substrate.get_block(block_number=old_block)
98+
with RetrySyncSubstrate(
99+
"wss://lite.sub.latent.to:443", archive_nodes=["ws://178.156.172.75:9944"]
100+
) as substrate:
101+
assert isinstance((substrate.get_block(block_number=old_block)), dict)

0 commit comments

Comments
 (0)