|
2 | 2 | import json
|
3 | 3 | import time
|
4 | 4 | from collections import deque
|
5 |
| -from typing import Union |
| 5 | +from typing import Optional, Union |
6 | 6 |
|
7 | 7 | from bittensor_wallet.mock.wallet_mock import MockWallet as _MockWallet
|
8 | 8 | from bittensor_wallet.mock.wallet_mock import get_mock_coldkey
|
@@ -44,6 +44,45 @@ def __eq__(self, __o: Union[float, int, Balance]) -> bool:
|
44 | 44 | ) or ((__o - self.tolerance) <= self.value <= (__o + self.tolerance))
|
45 | 45 |
|
46 | 46 |
|
| 47 | +def assert_submit_signed_extrinsic( |
| 48 | + substrate, |
| 49 | + keypair, |
| 50 | + call_module, |
| 51 | + call_function, |
| 52 | + call_params: Optional[dict] = None, |
| 53 | + era: Optional[dict] = None, |
| 54 | + nonce: Optional[int] = None, |
| 55 | + wait_for_inclusion: bool = False, |
| 56 | + wait_for_finalization: bool = True, |
| 57 | +): |
| 58 | + substrate.compose_call.assert_called_with( |
| 59 | + call_module, |
| 60 | + call_function, |
| 61 | + call_params, |
| 62 | + ) |
| 63 | + |
| 64 | + extrinsic = { |
| 65 | + "call": substrate.compose_call.return_value, |
| 66 | + "keypair": keypair, |
| 67 | + } |
| 68 | + |
| 69 | + if era: |
| 70 | + extrinsic["era"] = era |
| 71 | + |
| 72 | + if nonce: |
| 73 | + extrinsic["nonce"] = nonce |
| 74 | + |
| 75 | + substrate.create_signed_extrinsic.assert_called_with( |
| 76 | + **extrinsic, |
| 77 | + ) |
| 78 | + |
| 79 | + substrate.submit_extrinsic.assert_called_with( |
| 80 | + substrate.create_signed_extrinsic.return_value, |
| 81 | + wait_for_inclusion=wait_for_inclusion, |
| 82 | + wait_for_finalization=wait_for_finalization, |
| 83 | + ) |
| 84 | + |
| 85 | + |
47 | 86 | def get_mock_neuron(**kwargs) -> NeuronInfo:
|
48 | 87 | """
|
49 | 88 | Returns a mock neuron with the given kwargs overriding the default values.
|
|
0 commit comments