10
10
RetryAsyncSubstrate ,
11
11
)
12
12
from tests .conftest import start_docker_container
13
-
14
- LATENT_LITE_ENTRYPOINT = "wss://lite.sub.latent.to:443"
13
+ from tests .helpers .settings import ARCHIVE_ENTRYPOINT , LATENT_LITE_ENTRYPOINT
15
14
16
15
17
16
@pytest .fixture (scope = "function" )
18
17
def docker_containers ():
19
- processes = (start_docker_container (9944 , "9944" ), start_docker_container (9945 , "9945" ))
18
+ processes = (
19
+ start_docker_container (9944 , "9944" ),
20
+ start_docker_container (9945 , "9945" ),
21
+ )
20
22
try :
21
23
yield processes
22
24
@@ -50,22 +52,22 @@ def test_retry_sync_substrate(single_local_chain):
50
52
time .sleep (2 )
51
53
52
54
53
- # def test_retry_sync_substrate_max_retries(docker_containers):
54
- # time.sleep(10)
55
- # with RetrySyncSubstrate(
56
- # docker_containers[0].uri, fallback_chains=[docker_containers[1].uri]
57
- # ) as substrate:
58
- # for i in range(5):
59
- # assert substrate.get_chain_head().startswith("0x")
60
- # if i == 2:
61
- # subprocess.run(["docker", "pause", docker_containers[0].name])
62
- # if i == 3:
63
- # assert substrate.chain_endpoint == docker_containers[1].uri
64
- # if i == 4:
65
- # subprocess.run(["docker", "pause", docker_containers[1].name])
66
- # with pytest.raises(MaxRetriesExceeded):
67
- # substrate.get_chain_head().startswith("0x")
68
- # time.sleep(2)
55
+ def test_retry_sync_substrate_max_retries (docker_containers ):
56
+ time .sleep (10 )
57
+ with RetrySyncSubstrate (
58
+ docker_containers [0 ].uri , fallback_chains = [docker_containers [1 ].uri ]
59
+ ) as substrate :
60
+ for i in range (5 ):
61
+ assert substrate .get_chain_head ().startswith ("0x" )
62
+ if i == 2 :
63
+ subprocess .run (["docker" , "pause" , docker_containers [0 ].name ])
64
+ if i == 3 :
65
+ assert substrate .chain_endpoint == docker_containers [1 ].uri
66
+ if i == 4 :
67
+ subprocess .run (["docker" , "pause" , docker_containers [1 ].name ])
68
+ with pytest .raises (MaxRetriesExceeded ):
69
+ substrate .get_chain_head ().startswith ("0x" )
70
+ time .sleep (2 )
69
71
70
72
71
73
def test_retry_sync_substrate_offline ():
@@ -75,26 +77,26 @@ def test_retry_sync_substrate_offline():
75
77
)
76
78
77
79
78
- # @pytest.mark.asyncio
79
- # async def test_retry_async_subtensor_archive_node():
80
- # async with AsyncSubstrateInterface("wss://lite.sub.latent.to:443" ) as substrate:
81
- # current_block = await substrate.get_block_number()
82
- # old_block = current_block - 1000
83
- # with pytest.raises(StateDiscardedError):
84
- # await substrate.get_block(block_number=old_block)
85
- # async with RetryAsyncSubstrate(
86
- # "wss://lite.sub.latent.to:443" , archive_nodes=[LATENT_LITE_ENTRYPOINT ]
87
- # ) as substrate:
88
- # assert isinstance((await substrate.get_block(block_number=old_block)), dict)
89
- #
90
- #
91
- # def test_retry_sync_subtensor_archive_node():
92
- # with SubstrateInterface("wss://lite.sub.latent.to:443" ) as substrate:
93
- # current_block = substrate.get_block_number()
94
- # old_block = current_block - 1000
95
- # with pytest.raises(StateDiscardedError):
96
- # substrate.get_block(block_number=old_block)
97
- # with RetrySyncSubstrate(
98
- # "wss://lite.sub.latent.to:443" , archive_nodes=[LATENT_LITE_ENTRYPOINT ]
99
- # ) as substrate:
100
- # assert isinstance((substrate.get_block(block_number=old_block)), dict)
80
+ @pytest .mark .asyncio
81
+ async def test_retry_async_subtensor_archive_node ():
82
+ async with AsyncSubstrateInterface (LATENT_LITE_ENTRYPOINT ) as substrate :
83
+ current_block = await substrate .get_block_number ()
84
+ old_block = current_block - 1000
85
+ with pytest .raises (StateDiscardedError ):
86
+ await substrate .get_block (block_number = old_block )
87
+ async with RetryAsyncSubstrate (
88
+ LATENT_LITE_ENTRYPOINT , archive_nodes = [ARCHIVE_ENTRYPOINT ]
89
+ ) as substrate :
90
+ assert isinstance ((await substrate .get_block (block_number = old_block )), dict )
91
+
92
+
93
+ def test_retry_sync_subtensor_archive_node ():
94
+ with SubstrateInterface (LATENT_LITE_ENTRYPOINT ) as substrate :
95
+ current_block = substrate .get_block_number ()
96
+ old_block = current_block - 1000
97
+ with pytest .raises (StateDiscardedError ):
98
+ substrate .get_block (block_number = old_block )
99
+ with RetrySyncSubstrate (
100
+ LATENT_LITE_ENTRYPOINT , archive_nodes = [ARCHIVE_ENTRYPOINT ]
101
+ ) as substrate :
102
+ assert isinstance ((substrate .get_block (block_number = old_block )), dict )
0 commit comments