Skip to content

Commit d64b2cd

Browse files
committed
Moved integration tests out of unit tests.
1 parent 50e70b2 commit d64b2cd

File tree

4 files changed

+61
-56
lines changed

4 files changed

+61
-56
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import pytest
2+
3+
from async_substrate_interface.async_substrate import AsyncSubstrateInterface
4+
from async_substrate_interface.types import ScaleObj
5+
from tests.helpers.settings import ARCHIVE_ENTRYPOINT
6+
7+
8+
@pytest.mark.asyncio
9+
async def test_legacy_decoding():
10+
# roughly 4000 blocks before metadata v15 was added
11+
pre_metadata_v15_block = 3_010_611
12+
13+
async with AsyncSubstrateInterface(ARCHIVE_ENTRYPOINT) as substrate:
14+
block_hash = await substrate.get_block_hash(pre_metadata_v15_block)
15+
events = await substrate.get_events(block_hash)
16+
assert isinstance(events, list)
17+
18+
query_map_result = await substrate.query_map(
19+
module="SubtensorModule",
20+
storage_function="NetworksAdded",
21+
block_hash=block_hash,
22+
)
23+
async for key, value in query_map_result:
24+
assert isinstance(key, int)
25+
assert isinstance(value, ScaleObj)
26+
27+
timestamp = await substrate.query(
28+
"Timestamp",
29+
"Now",
30+
block_hash=block_hash,
31+
)
32+
assert timestamp.value == 1716358476004
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from async_substrate_interface.sync_substrate import SubstrateInterface
2+
from async_substrate_interface.types import ScaleObj
3+
from tests.helpers.settings import ARCHIVE_ENTRYPOINT
4+
5+
6+
def test_legacy_decoding():
7+
# roughly 4000 blocks before metadata v15 was added
8+
pre_metadata_v15_block = 3_010_611
9+
10+
with SubstrateInterface(ARCHIVE_ENTRYPOINT) as substrate:
11+
block_hash = substrate.get_block_hash(pre_metadata_v15_block)
12+
events = substrate.get_events(block_hash)
13+
assert isinstance(events, list)
14+
15+
query_map_result = substrate.query_map(
16+
module="SubtensorModule",
17+
storage_function="NetworksAdded",
18+
block_hash=block_hash,
19+
)
20+
for key, value in query_map_result:
21+
assert isinstance(key, int)
22+
assert isinstance(value, ScaleObj)
23+
24+
timestamp = substrate.query(
25+
"Timestamp",
26+
"Now",
27+
block_hash=block_hash,
28+
)
29+
assert timestamp.value == 1716358476004

tests/unit_tests/asyncio_/test_substrate_interface.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from async_substrate_interface.async_substrate import AsyncSubstrateInterface
88
from async_substrate_interface.types import ScaleObj
9-
from tests.helpers.settings import ARCHIVE_ENTRYPOINT
109

1110

1211
@pytest.mark.asyncio
@@ -114,30 +113,3 @@ async def test_websocket_shutdown_timer():
114113
await substrate.get_chain_head()
115114
await asyncio.sleep(6) # same sleep time as before
116115
assert substrate.ws._initialized is True # connection should still be open
117-
118-
119-
@pytest.mark.asyncio
120-
async def test_legacy_decoding():
121-
# roughly 4000 blocks before metadata v15 was added
122-
pre_metadata_v15_block = 3_010_611
123-
124-
async with AsyncSubstrateInterface(ARCHIVE_ENTRYPOINT) as substrate:
125-
block_hash = await substrate.get_block_hash(pre_metadata_v15_block)
126-
events = await substrate.get_events(block_hash)
127-
assert isinstance(events, list)
128-
129-
query_map_result = await substrate.query_map(
130-
module="SubtensorModule",
131-
storage_function="NetworksAdded",
132-
block_hash=block_hash,
133-
)
134-
async for key, value in query_map_result:
135-
assert isinstance(key, int)
136-
assert isinstance(value, ScaleObj)
137-
138-
timestamp = await substrate.query(
139-
"Timestamp",
140-
"Now",
141-
block_hash=block_hash,
142-
)
143-
assert timestamp.value == 1716358476004

tests/unit_tests/sync/test_substrate_interface.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from async_substrate_interface.sync_substrate import SubstrateInterface
44
from async_substrate_interface.types import ScaleObj
55

6-
from tests.helpers.settings import ARCHIVE_ENTRYPOINT
7-
86

97
def test_runtime_call(monkeypatch):
108
substrate = SubstrateInterface("ws://localhost", _mock=True)
@@ -75,29 +73,3 @@ def test_runtime_call(monkeypatch):
7573
"state_call", ["SubstrateApi_SubstrateMethod", "", None]
7674
)
7775
substrate.close()
78-
79-
80-
def test_legacy_decoding():
81-
# roughly 4000 blocks before metadata v15 was added
82-
pre_metadata_v15_block = 3_010_611
83-
84-
with SubstrateInterface(ARCHIVE_ENTRYPOINT) as substrate:
85-
block_hash = substrate.get_block_hash(pre_metadata_v15_block)
86-
events = substrate.get_events(block_hash)
87-
assert isinstance(events, list)
88-
89-
query_map_result = substrate.query_map(
90-
module="SubtensorModule",
91-
storage_function="NetworksAdded",
92-
block_hash=block_hash,
93-
)
94-
for key, value in query_map_result:
95-
assert isinstance(key, int)
96-
assert isinstance(value, ScaleObj)
97-
98-
timestamp = substrate.query(
99-
"Timestamp",
100-
"Now",
101-
block_hash=block_hash,
102-
)
103-
assert timestamp.value == 1716358476004

0 commit comments

Comments
 (0)