-
Notifications
You must be signed in to change notification settings - Fork 446
test: bring back old (sync subtensor) tests and fix them #2600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zyzniewski-reef
merged 19 commits into
async/thewhaleking/experimental-new-caller
from
test/async_unittests
Jan 24, 2025
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4fb0586
Revert "update `bittensor/core/extrinsics/serving.py` unit tests"
zyzniewski-reef dcc6e5b
Revert "update `bittensor/core/extrinsics/transfer.py` unit tests"
zyzniewski-reef e4cde0f
Revert "update `bittensor/core/extrinsics/set_weights.py` unit tests"
zyzniewski-reef d593bcf
Revert "update `bittensor/core/extrinsics/root.py` unit tests"
zyzniewski-reef 7f64dd1
Revert "typo"
zyzniewski-reef 57e92a7
Revert "ruff"
zyzniewski-reef 901ad69
Revert "update `commit_weights.py` unit test"
zyzniewski-reef f674a01
Revert "update `commit_reveal` unit test"
zyzniewski-reef ef50ff5
Revert "update `registration.py` unit test"
zyzniewski-reef b9e70f0
test: fix old (sync subtensor) unittests
zyzniewski-reef 2b747bc
fix `tests/integration_tests/test_metagraph_integration.py`
f546cd8
add `metagraph[chain_getBlockHash]` result
ababac2
fix `tests/integration_tests/test_subtensor_integration.py`
e841b41
improve helper to use with sync integration tests
b0eba57
test: fix extrinsics unittests
zyzniewski-reef ed9466e
Merge remote-tracking branch 'origin/test/async_unittests' into test/…
af26e98
ruff
28b3fdc
improve integration subtensor test
64065d2
remove comment
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| def mock_subtensor(mocker): | ||
| mock = mocker.MagicMock(spec=Subtensor) | ||
| mock.network = "magic_mock" | ||
| mock.substrate = mocker.Mock() | ||
| return mock | ||
|
|
||
|
|
||
|
|
@@ -30,17 +31,17 @@ def mock_wallet(mocker): | |
| ( | ||
| False, | ||
| True, | ||
| [False, True], | ||
| [False, 1], | ||
| True, | ||
| True, | ||
| ), # Registration succeeds with user confirmation | ||
| (False, True, [False, False], False, None), # Registration fails | ||
| (False, True, [False, None], False, False), # Registration fails | ||
| ( | ||
| False, | ||
| True, | ||
| [False, False], | ||
| [False, None], | ||
| True, | ||
| None, | ||
| False, | ||
| ), # Registration succeeds but neuron not found | ||
| ], | ||
| ids=[ | ||
|
|
@@ -61,13 +62,19 @@ def test_root_register_extrinsic( | |
| mocker, | ||
| ): | ||
| # Arrange | ||
| mock_subtensor.is_hotkey_registered.side_effect = hotkey_registered | ||
| mock_subtensor.is_hotkey_registered.return_value = hotkey_registered[0] | ||
|
|
||
| # Preps | ||
| mock_register = mocker.Mock( | ||
| mocked_sign_and_send_extrinsic = mocker.patch.object( | ||
| mock_subtensor, | ||
| "sign_and_send_extrinsic", | ||
| return_value=(registration_success, "Error registering") | ||
| ) | ||
| root._do_root_register = mock_register | ||
| mocker.patch.object( | ||
| mock_subtensor.substrate, | ||
| "query", | ||
| return_value=hotkey_registered[1], | ||
| ) | ||
|
|
||
| # Act | ||
| result = root.root_register_extrinsic( | ||
|
|
@@ -80,7 +87,17 @@ def test_root_register_extrinsic( | |
| assert result == expected_result | ||
|
|
||
| if not hotkey_registered[0]: | ||
| mock_register.assert_called_once() | ||
| mock_subtensor.substrate.compose_call.assert_called_once_with( | ||
| call_module="SubtensorModule", | ||
| call_function="root_register", | ||
| call_params={"hotkey": "fake_hotkey_address"}, | ||
| ) | ||
| mocked_sign_and_send_extrinsic.assert_called_once_with( | ||
| mock_subtensor.substrate.compose_call.return_value, | ||
| wallet=mock_wallet, | ||
| wait_for_inclusion=wait_for_inclusion, | ||
| wait_for_finalization=wait_for_finalization | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
|
|
@@ -115,21 +132,13 @@ def test_root_register_extrinsic( | |
| [0.5, 0.5], | ||
| False, | ||
| ), # Failure - setting weights failed | ||
| ( | ||
| True, | ||
| False, | ||
| [], | ||
| [], | ||
| False, | ||
| ), # Exception catched - ValueError 'min() arg is an empty sequence' | ||
| ], | ||
| ids=[ | ||
| "success-weights-set", | ||
| "success-not-wait", | ||
| "success-large-value", | ||
| "success-single-value", | ||
| "failure-setting-weights", | ||
| "failure-value-error-exception", | ||
|
||
| ], | ||
| ) | ||
| def test_set_root_weights_extrinsic( | ||
|
|
@@ -146,8 +155,9 @@ def test_set_root_weights_extrinsic( | |
| root._do_set_root_weights = mocker.Mock( | ||
| return_value=(expected_success, "Mock error") | ||
| ) | ||
| mock_subtensor.min_allowed_weights = mocker.Mock(return_value=0) | ||
| mock_subtensor.max_weight_limit = mocker.Mock(return_value=1) | ||
| root._get_limits = mocker.Mock( | ||
| return_value=(0, 1), | ||
| ) | ||
|
|
||
| # Call | ||
| result = root.set_root_weights_extrinsic( | ||
|
|
@@ -200,22 +210,13 @@ def test_set_root_weights_extrinsic( | |
| None, | ||
| False, | ||
| ), # Failure - setting weights failed | ||
| ( | ||
| True, | ||
| False, | ||
| [], | ||
| [], | ||
| False, | ||
| False, | ||
| ), # Exception catched - ValueError 'min() arg is an empty sequence' | ||
| ], | ||
| ids=[ | ||
| "success-weights-set", | ||
| "success-not-wait", | ||
| "success-large-value", | ||
| "success-single-value", | ||
| "failure-setting-weights", | ||
| "failure-value-error-exception", | ||
|
||
| ], | ||
| ) | ||
| def test_set_root_weights_extrinsic_torch( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root.root_register_extrinsic no longer returns no response (only True/False)