def test_getNodeInfo(self): with set_qrl_dir("wallet_ver1"): walletd = WalletD() service = WalletAPIService(walletd) block_last_hash_str = 'c23f47a10a8c53cc5ded096369255a32c4a218682a961d0ee7db22c500000000' version = "1.0.0" num_connections = 10 num_known_peers = 200 uptime = 10000 block_height = 102345 block_last_hash = bytes(hstr2bin(block_last_hash_str)) network_id = "network id" node_info = qrl_pb2.NodeInfo(version=version, num_connections=num_connections, num_known_peers=num_known_peers, uptime=uptime, block_height=block_height, block_last_hash=block_last_hash, network_id=network_id) walletd._public_stub.GetNodeState = Mock( return_value=qrl_pb2.GetNodeStateResp(info=node_info)) resp = service.GetNodeInfo(qrlwallet_pb2.NodeInfoReq(), context=None) self.assertEqual(resp.version, version) self.assertEqual(resp.num_connections, str(num_connections)) self.assertEqual(resp.num_known_peers, str(num_known_peers)) self.assertEqual(resp.uptime, uptime) self.assertEqual(resp.block_height, block_height) self.assertEqual(resp.block_last_hash, block_last_hash_str) self.assertEqual(resp.network_id, network_id)
def getNodeInfo(self) -> qrl_pb2.NodeInfo: info = qrl_pb2.NodeInfo() info.version = self.version info.state = self.state info.num_connections = self.num_connections info.num_known_peers = self.num_known_peers info.uptime = self.uptime info.block_height = self.block_height info.block_last_hash = b'' # FIXME info.network_id = config.dev.genesis_prev_headerhash # FIXME return info
def get_node_info(self) -> qrl_pb2.NodeInfo: info = qrl_pb2.NodeInfo() info.version = self.version info.state = self.state info.num_connections = self.num_connections info.num_known_peers = self.num_known_peers info.uptime = self.uptime info.block_height = self.block_height info.block_last_hash = self._chain_manager.last_block.headerhash info.network_id = config.user.genesis_prev_headerhash return info