feat: add comprehensive unit tests for bittensor.core.timelock module for SDKv10 #3195
+503
−0
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.
Pull Request: Add Comprehensive Unit Tests for Timelock Module
Bug
Missing unit test coverage for
bittensor/core/timelock.py. While integration tests exist intests/integration_tests/test_timelock.py, there are no unit tests that can run without network access to Drand. This leaves the module's logic untested in isolation and makes CI slower due to network-dependent tests.Description of the Change
This PR adds a comprehensive unit test suite (
tests/unit_tests/test_timelock.py) with 47 unit tests covering all aspects of the timelock module using mocked dependencies for fast, isolated testing.Test Coverage Added:
TLE Constants (3 tests)
TLE_ENCRYPTED_DATA_SUFFIXtype and value validation__all__exports verificationencrypt() Function (12 tests)
block_timehandlingblock_time=0.25)block_timesupportn_blocksvaluesdecrypt() Function (8 tests)
Nonereturn before reveal roundno_errorsflag handlingreturn_strflag handlingwait_reveal_and_decrypt() Function (9 tests)
reveal_roundparameterreturn_strandno_errorsparameter passingRound Parsing (4 tests)
Edge Cases (7 tests)
n_blocksblock_timeModule Imports (5 tests)
Alternate Designs
Alternative approaches considered:
The chosen approach provides thorough unit-level testing while maintaining test independence and fast execution.
Possible Drawbacks
Verification Process
Result: 47 passed in 0.06s
Result: All checks passed!
Result: 1 file already formatted
Release Notes
N/A - This change adds test coverage only and does not affect user-facing functionality.
Branch Acknowledgement
[x] I am acknowledging that I am opening this branch against
staging