From 7e94f534b6af416696b25c6e834d4a630b025f91 Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Mon, 5 Sep 2022 14:08:43 +0200 Subject: [PATCH] e2e: update libs for Python 3.10 --- test/appium/requirements.txt | 13 ++++++------ test/appium/support/api/network_api.py | 29 +++++++++++++++++--------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/test/appium/requirements.txt b/test/appium/requirements.txt index 892816d416..826df2862d 100644 --- a/test/appium/requirements.txt +++ b/test/appium/requirements.txt @@ -1,15 +1,16 @@ -aiohttp==3.8.0 +aiohttp==3.8.1 allpairspy==2.5.0 apipkg==1.5 Appium-Python-Client==1.0.2 +PyGithub==1.55 async-timeout==4.0.1 certifi==2020.11.8 chardet==3.0.4 cycler==0.10.0 -cytoolz==0.11.0 +cytoolz==0.12.0 emoji==0.5.0 eth-hash==0.3.2 -eth-keys==0.3.3 +eth-keys eth-utils==1.10.0 ethereum==2.3.2 execnet==1.7.1 @@ -21,7 +22,7 @@ lxml==4.6.5 matplotlib==3.3.3 multidict==5.0.2 namedlist==1.8 -numpy==1.19.4 +numpy==1.23.0 pbkdf2==1.3 Pillow==8.1.0 py==1.10.0 @@ -30,7 +31,7 @@ pycryptodome==3.9.9 pyethash==0.1.27 pyparsing==2.4.7 pysha3==1.0.2 -pytest==6.2.0 +pytest==6.2.5 pytest-forked==1.3.0 pytest-xdist==2.5.0 python-dateutil==2.8.1 @@ -47,5 +48,5 @@ urllib3==1.26.3 yarl==1.6.3 docker==4.4.0 influxdb==5.3.1 -web3==5.25.0 +web3==5.30.0 imagehash \ No newline at end of file diff --git a/test/appium/support/api/network_api.py b/test/appium/support/api/network_api.py index 2fc5732652..3ec988c8cb 100644 --- a/test/appium/support/api/network_api.py +++ b/test/appium/support/api/network_api.py @@ -72,10 +72,25 @@ class NetworkApi(object): method = self.network_url + 'module=proxy&action=eth_blockNumber' return int(requests.request('GET', url=method).json()['result'], 0) - def find_transaction_by_hash(self,transaction_hash: str): - transaction = w3.transaction_status(transaction_hash) - if not transaction['blockHash']: - self.log("TX %s is still pending" %transaction_hash) + def find_transaction_by_hash(self, transaction_hash: str): + method = self.network_url + 'module=transaction&action=gettxreceiptstatus&txhash=%s&apikey=%s' % ( + transaction_hash, self.api_key) + try: + transactions_response = requests.request('GET', url=method, headers=self.headers).json() + if transactions_response: + result = True + if transactions_response['result']['status'] == '1': + self.log("TX %s is found and confirmed: " % transaction_hash) + elif transactions_response['result']['status'] == '0': + self.log("TX %s is found and failed: " % transaction_hash) + else: + result = False + self.log("TX %s is not found!" % transaction_hash) + return result + except TypeError as e: + self.log("Check response from etherscan API. Returned values do not match expected. %s" % str(e)) + except JSONDecodeError as e: + self.log("No valid JSON response from Etherscan: %s " % str(e)) def find_transaction_by_unique_amount(self, address, amount, token=False, decimals=18, wait_time=300): additional_info = 'token transactions' if token else 'ETH transactions' @@ -104,12 +119,6 @@ class NetworkApi(object): for transaction in transactions: if float(int(transaction['value']) / 10 ** decimals) == float(amount): self.log("Tx is found: %s (etherscan API)" % transaction['hash']) - try: - w3.transaction_status(transaction['hash']) - self.log("Tx is found (web3 API)") - except TransactionNotFound: - self.log("Tx is not found (web3 API)") - continue return transaction except TypeError as e: self.log("Failed iterate transactions(Etherscan unexpected error): " + str(e))