added ability to set default network
Signed-off-by: Anton Danchenko <ant.danchenko@gmail.com>
This commit is contained in:
parent
c216a378e4
commit
95a686e4c3
|
@ -7,24 +7,24 @@ from tests import info
|
||||||
class NetworkApi:
|
class NetworkApi:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.ropsten_url = 'http://api-ropsten.etherscan.io/api?'
|
self.network_url = 'http://api-%s.etherscan.io/api?' % pytest.config.getoption('network')
|
||||||
self.faucet_url = 'http://51.15.45.169:3001/donate'
|
self.faucet_url = 'http://51.15.45.169:3001/donate'
|
||||||
self.chat_bot_url = 'http://offsite.chat:8099'
|
self.chat_bot_url = 'http://offsite.chat:8099'
|
||||||
|
|
||||||
def get_transactions(self, address: str) -> dict:
|
def get_transactions(self, address: str) -> dict:
|
||||||
method = self.ropsten_url + 'module=account&action=txlist&address=0x%s&sort=desc' % address
|
method = self.network_url + 'module=account&action=txlist&address=0x%s&sort=desc' % address
|
||||||
return requests.request('GET', url=method).json()['result']
|
return requests.request('GET', url=method).json()['result']
|
||||||
|
|
||||||
def get_token_transaction(self, address: str) -> dict:
|
def get_token_transaction(self, address: str) -> dict:
|
||||||
method = self.ropsten_url + 'module=account&action=tokentx&address=0x%s&sort=desc' % address
|
method = self.network_url + 'module=account&action=tokentx&address=0x%s&sort=desc' % address
|
||||||
return requests.request('GET', url=method).json()['result']
|
return requests.request('GET', url=method).json()['result']
|
||||||
|
|
||||||
def is_transaction_successful(self, transaction_hash: str) -> int:
|
def is_transaction_successful(self, transaction_hash: str) -> int:
|
||||||
method = self.ropsten_url + 'module=transaction&action=getstatus&txhash=%s' % transaction_hash
|
method = self.network_url + 'module=transaction&action=getstatus&txhash=%s' % transaction_hash
|
||||||
return not int(requests.request('GET', url=method).json()['result']['isError'])
|
return not int(requests.request('GET', url=method).json()['result']['isError'])
|
||||||
|
|
||||||
def get_balance(self, address):
|
def get_balance(self, address):
|
||||||
method = self.ropsten_url + 'module=account&action=balance&address=0x%s&tag=latest' % address
|
method = self.network_url + 'module=account&action=balance&address=0x%s&tag=latest' % address
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
try:
|
try:
|
||||||
return int(requests.request('GET', method).json()["result"])
|
return int(requests.request('GET', method).json()["result"])
|
||||||
|
@ -32,7 +32,7 @@ class NetworkApi:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_latest_block_number(self) -> int:
|
def get_latest_block_number(self) -> int:
|
||||||
method = self.ropsten_url + 'module=proxy&action=eth_blockNumber'
|
method = self.network_url + 'module=proxy&action=eth_blockNumber'
|
||||||
return int(requests.request('GET', url=method).json()['result'], 0)
|
return int(requests.request('GET', url=method).json()['result'], 0)
|
||||||
|
|
||||||
def find_transaction_by_hash(self, address: str, transaction_hash: str):
|
def find_transaction_by_hash(self, address: str, transaction_hash: str):
|
||||||
|
|
|
@ -45,6 +45,12 @@ def pytest_addoption(parser):
|
||||||
action='store',
|
action='store',
|
||||||
default=False,
|
default=False,
|
||||||
help='boolean; For creating testrail report per run')
|
help='boolean; For creating testrail report per run')
|
||||||
|
parser.addoption('--network',
|
||||||
|
action='store',
|
||||||
|
default='ropsten',
|
||||||
|
help='string; ropsten or rinkeby')
|
||||||
|
|
||||||
|
# message reliability
|
||||||
parser.addoption('--rerun_count',
|
parser.addoption('--rerun_count',
|
||||||
action='store',
|
action='store',
|
||||||
default=0,
|
default=0,
|
||||||
|
|
Loading…
Reference in New Issue