Skip to content

Conversation

@codomposer
Copy link
Contributor

Add Unit Tests for AsyncSubtensor Methods

Description

This PR adds 7 new unit tests for the AsyncSubtensor class to improve test coverage for critical blockchain interaction methods.

Changes

Added the following tests to tests/unit_tests/test_async_subtensor.py:

Test Description
test_get_stake_with_locked_amount Verifies correct locked vs unlocked stake amount handling and Balance unit per netuid
test_sim_swap_accuracy Tests swap fee calculations (tao_fee, alpha_fee) and unit symbol handling
test_get_subnet_hyperparameters_caching Validates reuse_block parameter behavior for block hash caching
test_compose_call_batch Tests batch call composition with multiple GenericCall objects
test_sign_and_send_extrinsic_retry_on_network_error Verifies error handling on SubstrateRequestException
test_get_delegates_lite_vs_full Tests data consistency between DelegateInfo and DelegateInfoLite
test_query_runtime_api_error_handling Validates ChainError propagation from runtime API

Testing

All tests pass:

source venv/bin/activate
python -m pytest tests/unit_tests/test_async_subtensor.py::test_get_stake_with_locked_amount \
    tests/unit_tests/test_async_subtensor.py::test_sim_swap_accuracy \
    tests/unit_tests/test_async_subtensor.py::test_get_subnet_hyperparameters_caching \
    tests/unit_tests/test_async_subtensor.py::test_compose_call_batch \
    tests/unit_tests/test_async_subtensor.py::test_sign_and_send_extrinsic_retry_on_network_error \
    tests/unit_tests/test_async_subtensor.py::test_get_delegates_lite_vs_full \
    tests/unit_tests/test_async_subtensor.py::test_query_runtime_api_error_handling -v

Contribution by Gittensor, learn more at https://gittensor.io/

- test_get_stake_with_locked_amount: Test locked vs unlocked stake amounts
- test_sim_swap_accuracy: Test swap fee calculations
- test_get_subnet_hyperparameters_caching: Test reuse_block parameter
- test_compose_call_batch: Test batch call composition
- test_sign_and_send_extrinsic_retry_on_network_error: Test network error handling
- test_get_delegates_lite_vs_full: Test DelegateInfo vs DelegateInfoLite
- test_query_runtime_api_error_handling: Test ChainError propagation
Copy link
Collaborator

@basfroman basfroman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before move forward, pls read all comments in this PR carefully.

@basfroman basfroman changed the base branch from SDKv10 to staging December 10, 2025 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants