-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change default public rpc node (tezos-reward-distributor-organization…
…#164) * Change default public rpc node * Fix unit tests
- Loading branch information
Showing
10 changed files
with
28 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,37 @@ | ||
from api.block_api import BlockApi | ||
from util.rpc_utils import parse_json_response | ||
import requests | ||
|
||
from api.block_api import BlockApi | ||
from log_config import main_logger | ||
|
||
logger = main_logger | ||
|
||
COMM_HEAD = " rpc get http://{}/chains/main/blocks/head" | ||
COMM_REVELATION = " rpc get http://{}/chains/main/blocks/head/context/contracts/{}/manager_key" | ||
COMM_HEAD = "http://{}/chains/main/blocks/head" | ||
COMM_REVELATION = "http://{}/chains/main/blocks/head/context/contracts/{}/manager_key" | ||
|
||
class RpcBlockApiImpl(BlockApi): | ||
|
||
def __init__(self, nw, wllt_clnt_mngr, node_url): | ||
def __init__(self, nw, node_url): | ||
super(RpcBlockApiImpl, self).__init__(nw) | ||
|
||
self.wllt_clnt_mngr = wllt_clnt_mngr | ||
self.node_url = node_url | ||
|
||
def get_current_level(self, verbose=False): | ||
_, response = self.wllt_clnt_mngr.send_request(COMM_HEAD.format(self.node_url)) | ||
head = parse_json_response(response) | ||
response = requests.get(COMM_HEAD.format(self.node_url), timeout=5) | ||
head = response.json() | ||
current_level = int(head["metadata"]["level"]["level"]) | ||
return current_level | ||
|
||
def get_revelation(self, pkh, verbose=False): | ||
_, response = self.wllt_clnt_mngr.send_request(COMM_REVELATION.format(self.node_url, pkh)) | ||
manager_key = parse_json_response(response, verbose=verbose) | ||
response = requests.get(COMM_REVELATION.format(self.node_url, pkh), timeout=5) | ||
manager_key = response.json() | ||
logger.debug("Manager key is '{}'".format(manager_key)) | ||
bool_revelation = manager_key and manager_key!='null' | ||
return bool_revelation | ||
|
||
|
||
|
||
from cli.wallet_client_manager import WalletClientManager | ||
|
||
def test_get_revelation(): | ||
|
||
wllt_clnt_mngr = WalletClientManager("~/tezos-alpha/tezos-client", "", "", "", True) | ||
|
||
address_api = RpcBlockApiImpl({"NAME":"ALPHANET"}, wllt_clnt_mngr, "127.0.0.1:8732") | ||
address_api = RpcBlockApiImpl({"NAME":"ALPHANET"}, "127.0.0.1:8732") | ||
print(address_api.get_revelation("tz1N5cvoGZFNYWBp2NbCWhaRXuLQf6e1gZrv")) | ||
print(address_api.get_revelation("KT1FXQjnbdqDdKNpjeM6o8PF1w8Rn2j8BmmG")) | ||
print(address_api.get_revelation("tz1YVxe7FFisREKXWNxdrrwqvw3o2jeXzaNb")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters