Skip to content

Commit

Permalink
Merge pull request #119 from skalenetwork/fix-node-data
Browse files Browse the repository at this point in the history
Update nodes_data get to current skale manager version
  • Loading branch information
badrogger authored Mar 5, 2020
2 parents 01b25d3 + d13d176 commit 93e2898
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion skale/contracts/data/nodes_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@

FIELDS = [
'name', 'ip', 'publicIP', 'port', 'publicKey', 'start_date',
'leaving_date', 'last_reward_date', 'second_address'
'last_reward_date', 'finish_time', 'status', 'validator_id'
]

COMPACT_FIELDS = ['schainIndex', 'nodeID', 'ip', 'basePort']
SCHAIN_CONFIG_FIELDS = [
'schainIndex', 'nodeID', 'nodeName', 'ip', 'basePort',
Expand Down
21 changes: 21 additions & 0 deletions tests/contracts/data/nodes_data_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
""" SKALE node data test """

import socket
from eth_keys import keys
from web3 import Web3

import skale.utils.helper as Helper
from skale.contracts.data.nodes_data import FIELDS
from tests.constants import DEFAULT_NODE_HASH, DEFAULT_NODE_NAME
Expand All @@ -11,12 +15,29 @@ def test_get_raw_not_exist(skale):
assert node_arr is None


def public_key_from_private(key):
pr_bytes = Web3.toBytes(hexstr=key)
return keys.PrivateKey(pr_bytes)


def test_get(skale):
node = skale.nodes_data.get_by_name(DEFAULT_NODE_NAME)
node_id = skale.nodes_data.node_name_to_index(DEFAULT_NODE_NAME)
node_by_id = skale.nodes_data.get(node_id)
assert list(node.keys()) == FIELDS
assert [k for k, v in node.items() if v is None] == []
assert node_by_id['name'] == DEFAULT_NODE_NAME
socket.inet_ntoa(node_by_id['ip'])
socket.inet_ntoa(node_by_id['publicIP'])

assert node_by_id['publicKey'].hex() == skale.wallet.public_key[2:]

assert node_by_id['publicKey'] != b''
assert node_by_id['start_date'] > 0
assert node_by_id['last_reward_date'] > 0
assert node_by_id['finish_time'] == 0
assert node_by_id['status'] == 0
assert node_by_id['validator_id'] == 1

assert list(node_by_id.keys()) == FIELDS
assert node == node_by_id
Expand Down

0 comments on commit 93e2898

Please sign in to comment.