|
1 |
| -from unittest.mock import MagicMock |
2 |
| - |
3 |
| -import pytest |
4 |
| -from scalecodec.types import GenericExtrinsic |
5 |
| - |
| 1 | +from bittensor.core.chain_data import StakeInfo |
6 | 2 | from bittensor.core.extrinsics import utils
|
7 |
| -from bittensor.core.subtensor import Subtensor |
8 |
| - |
9 |
| - |
10 |
| -@pytest.fixture |
11 |
| -def mock_subtensor(mock_substrate): |
12 |
| - mock_subtensor = MagicMock(autospec=Subtensor) |
13 |
| - mock_subtensor.substrate = mock_substrate |
14 |
| - yield mock_subtensor |
15 |
| - |
16 |
| - |
17 |
| -@pytest.fixture |
18 |
| -def starting_block(): |
19 |
| - yield {"header": {"number": 1, "hash": "0x0100"}} |
20 |
| - |
21 |
| - |
22 |
| -def test_submit_extrinsic_success(mock_subtensor): |
23 |
| - mock_subtensor.substrate.submit_extrinsic.return_value = True |
24 |
| - mock_extrinsic = MagicMock(autospec=GenericExtrinsic) |
25 |
| - result = utils.submit_extrinsic(mock_subtensor, mock_extrinsic, True, True) |
26 |
| - assert result is True |
| 3 | +from bittensor.utils.balance import Balance |
| 4 | + |
| 5 | + |
| 6 | +def test_old_stake(subtensor, mocker): |
| 7 | + wallet = mocker.Mock( |
| 8 | + hotkey=mocker.Mock(ss58_address="HK1"), |
| 9 | + coldkeypub=mocker.Mock(ss58_address="CK1"), |
| 10 | + ) |
| 11 | + |
| 12 | + expected_stake = Balance.from_tao(100) |
| 13 | + |
| 14 | + hotkey_ss58s = ["HK1", "HK2"] |
| 15 | + netuids = [3, 4] |
| 16 | + all_stakes = [ |
| 17 | + StakeInfo( |
| 18 | + hotkey_ss58="HK1", |
| 19 | + coldkey_ss58="CK1", |
| 20 | + netuid=3, |
| 21 | + stake=expected_stake, |
| 22 | + locked=Balance.from_tao(10), |
| 23 | + emission=Balance.from_tao(1), |
| 24 | + drain=0, |
| 25 | + is_registered=True, |
| 26 | + ), |
| 27 | + ] |
| 28 | + |
| 29 | + result = utils.get_old_stakes(wallet, hotkey_ss58s, netuids, all_stakes) |
| 30 | + |
| 31 | + assert result == [expected_stake, Balance.from_tao(0)] |
0 commit comments