Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions proxy/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def call(self, *args):
logger.debug("Calling: " + " ".join(cmd))
return subprocess.check_output(cmd, universal_newlines=True)
except subprocess.CalledProcessError as err:
import sys
logger.debug("ERR: solana error {}".format(err))
raise

Expand All @@ -35,7 +34,16 @@ def call(self, *args):
logger.debug("Calling: " + " ".join(cmd))
return subprocess.check_output(cmd, timeout=neon_cli_timeout, universal_newlines=True)
except subprocess.CalledProcessError as err:
import sys
logger.debug("ERR: neon-cli error {}".format(err))
raise

def version(self):
try:
cmd = ["neon-cli",
"--version"]
logger.debug("Calling: " + " ".join(cmd))
return subprocess.check_output(cmd, timeout=neon_cli_timeout, universal_newlines=True).split()[1]
except subprocess.CalledProcessError as err:
logger.debug("ERR: neon-cli error {}".format(err))
raise

Expand Down
3 changes: 3 additions & 0 deletions proxy/plugin/solana_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def eth_chainId(self):
# NEON_CHAIN_ID is a string in decimal form
return hex(int(self.neon_config_dict['NEON_CHAIN_ID']))

def neon_cli_version(self):
return neon_cli().version()

def net_version(self):
neon_config_load(self)
# NEON_CHAIN_ID is a string in decimal form
Expand Down
39 changes: 39 additions & 0 deletions proxy/testing/test_neon_cli_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import unittest
import os
import requests
import json
import inspect

from proxy.environment import neon_cli

proxy_url = os.environ.get('PROXY_URL', 'http://localhost:9090/solana')
headers = {'Content-type': 'application/json'}


def get_line_number():
cf = inspect.currentframe()
return cf.f_back.f_lineno


class TestNeonProxyVersion(unittest.TestCase):
@classmethod
def setUpClass(cls):
pass

def test_01_neon_cli_version(self):
print("https://github.com/neonlabsorg/proxy-model.py/issues/319")
response = json.loads(requests.post(
proxy_url, headers=headers,
data=json.dumps({"jsonrpc": "2.0",
"id": get_line_number(),
"method": "neon_cli_version",
"params": []
})).text)
print('response:', response)
neon_cli_version = response['result']
print('neon_cli_version:', neon_cli_version)
self.assertEqual(neon_cli_version, neon_cli().version())


if __name__ == '__main__':
unittest.main()