Skip to content

Commit

Permalink
Merge pull request #33 from NebraLtd/posterzh/get-firmware-version
Browse files Browse the repository at this point in the history
feat: add getting firmware version method
  • Loading branch information
shawaj authored Oct 24, 2021
2 parents 4f37655 + a6fd97d commit c86bfd8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions hm_pyhelper/miner_json_rpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ def get_peer_addr(self):

def get_peer_book(self):
return self.__fetch_data('peer_book', addr='self')

def get_firmware_version(self):
summary = self.get_summary()
return summary.get('firmware_version')
34 changes: 34 additions & 0 deletions hm_pyhelper/tests/test_miner_json_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,37 @@ def test_get_peer_book(self, mock_json_rpc_client):
addr='self'
)
self.assertEqual(result, [])

@mock.patch('hm_pyhelper.miner_json_rpc.client.request')
def test_get_firmware_version(self, mock_json_rpc_client):
firmware_version = '2021.10.18.0'
summary = {
'block_age': 1136610,
'epoch': 25612,
'firmware_version': firmware_version,
'gateway_details': 'undefined',
'height': 993640,
'mac_addresses': [
{'eth0': '0242AC110002'},
{'ip6tnl0': '00000000000000000000000000000000'},
{'tunl0': '00000000'},
{'lo': '000000000000'}
],
'name': 'scruffy-chocolate-shell',
'peer_book_entry_count': 3,
'sync_height': 993640,
'uptime': 144,
'version': 10010005
}
mock_json_rpc_client.return_value = Response(
data=Result(
result=summary
)
)
client = MinerClient()
result = client.get_firmware_version()
mock_json_rpc_client.assert_called_with(
BASE_URL,
'info_summary'
)
self.assertEqual(result, firmware_version)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='hm_pyhelper',
version='0.8.10',
version='0.8.11',
author="Nebra Ltd",
author_email="[email protected]",
description="Helium Python Helper",
Expand Down

0 comments on commit c86bfd8

Please sign in to comment.