-
Notifications
You must be signed in to change notification settings - Fork 444
Expand file tree
/
Copy pathtest_subtensor.py
More file actions
45 lines (37 loc) · 1.43 KB
/
test_subtensor.py
File metadata and controls
45 lines (37 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from bittensor.core.subtensor import Subtensor
# TODO: It's probably worth adding a test for each corresponding method to check the correctness of the call with arguments
def test_methods_comparable(mocker):
"""Verifies that methods in sync and async Subtensors are comparable."""
# Preps
mocker.patch(
"async_substrate_interface.substrate_interface.AsyncSubstrateInterface"
)
subtensor = Subtensor()
# methods which lives in sync subtensor only
excluded_subtensor_methods = ["async_subtensor", "event_loop", "execute_coroutine"]
# methods which lives in async subtensor only
excluded_async_subtensor_methods = [
"determine_block_hash",
"encode_params",
"get_hyperparameter",
"sign_and_send_extrinsic",
]
subtensor_methods = [
m
for m in dir(subtensor)
if not m.startswith("_") and m not in excluded_subtensor_methods
]
async_subtensor_methods = [
m
for m in dir(subtensor.async_subtensor)
if not m.startswith("_") and m not in excluded_async_subtensor_methods
]
# Assertions
for method in subtensor_methods:
assert (
method in async_subtensor_methods
), f"`Subtensor.{method}` not in `AsyncSubtensor` class."
for method in async_subtensor_methods:
assert (
method in subtensor_methods
), f"`AsyncSubtensor.{method}` not in `Subtensor` class."