Interact with ropsten web3 to send assets

Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
Serhy 2020-12-04 19:27:21 +02:00 committed by Churikova Tetiana
parent 8a97331779
commit a70b07e83d
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
9 changed files with 143 additions and 15 deletions

View File

@ -44,6 +44,10 @@ pipeline {
credentialsId: 'etherscan-api-key',
variable: 'ETHERSCAN_API_KEY'
),
string(
credentialsId: 'infura-e2e-token',
variable: 'WEB3_INFURA_PROJECT_ID'
),
]) {
dir('test/appium/tests') {
sh """

View File

@ -80,6 +80,10 @@ pipeline {
credentialsId: 'etherscan-api-key',
variable: 'ETHERSCAN_API_KEY'
),
string(
credentialsId: 'infura-e2e-token',
variable: 'WEB3_INFURA_PROJECT_ID'
),
]) {
dir('test/appium/tests') {
sh """

View File

@ -48,6 +48,10 @@ pipeline {
credentialsId: 'etherscan-api-key',
variable: 'ETHERSCAN_API_KEY'
),
string(
credentialsId: 'infura-e2e-token',
variable: 'WEB3_INFURA_PROJECT_ID'
),
]) {
dir('test/appium/tests') {
sh """

View File

@ -10,7 +10,7 @@ cytoolz==0.11.0
emoji==0.5.0
eth-hash==0.2.0
eth-keys==0.3.3
eth-utils==2.0.0a0
eth-utils==1.9.5
ethereum==2.3.2
execnet==1.7.1
future==0.18.2
@ -48,3 +48,4 @@ yarl==1.6.3
zbarlight==3.0
docker==4.4.0
influxdb==5.3.1
web3

View File

@ -8,14 +8,14 @@ from json import JSONDecodeError
from decimal import Decimal
from os import environ
import tests
import support.api.web3_api as w3
class NetworkApi(object):
def __init__(self):
self.network_url = 'http://api-%s.etherscan.io/api?' % tests.pytest_config_global['network']
self.faucet_url = 'https://faucet-ropsten.status.im/donate'
self.faucet_backup_url = 'https://faucet.ropsten.be/donate'
self.faucet_backup_address = w3.account_address
self.headers = {
'User-Agent':"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit\
/537.36 (KHTML, like Gecko) Chrome\/77.0.3865.90 Safari\/537.36", }
@ -155,20 +155,17 @@ class NetworkApi(object):
pass
def faucet_backup(self, address):
try:
self.log("Trying to get funds from %s" % self.faucet_backup_url)
return requests.request('GET', '%s/0x%s' % (self.faucet_backup_url, address)).json()
except JSONDecodeError as e:
self.log(str(e))
pass
self.log("Trying to get funds from %s" % self.faucet_backup_address)
address = "0x" + address
w3.donate_testnet_eth(address=address, amount=0.005, inscrease_default_gas_price=10)
def get_donate(self, address, external_faucet=True, wait_time=300):
def get_donate(self, address, external_faucet=False, wait_time=300):
initial_balance = self.get_balance(address)
counter = 0
if initial_balance < 1000000000000000000:
if external_faucet:
self.faucet_backup(address)
response = self.faucet(address)
self.faucet(address)
while True:
if counter >= wait_time:
pytest.fail("Donation was not received during %s seconds!" % wait_time)
@ -177,7 +174,7 @@ class NetworkApi(object):
time.sleep(10)
self.log('Waiting %s seconds for donation' % counter)
else:
self.log('Got %s for %s' % (response["amount_eth"], address))
self.log('Got %s Gwei for %s' % (self.get_balance(address), address))
return
def start_chat_bot(self, chat_name: str, messages_number: int, interval: int = 1) -> list:

File diff suppressed because one or more lines are too long

View File

@ -118,7 +118,7 @@ class TestWalletManagement(SingleDeviceTestCase):
if wallet.backup_recovery_phrase_warning_text.is_element_present():
self.driver.fail("'Back up your seed phrase' warning is shown on Wallet while no funds are present")
address = wallet.get_wallet_address()
self.network_api.get_donate(address[2:], external_faucet=False)
self.network_api.get_donate(address[2:], external_faucet=True, wait_time=60)
wallet.back_button.click()
wallet.wait_balance_is_changed()
if not wallet.backup_recovery_phrase_warning_text.is_element_present(30):

View File

@ -113,7 +113,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.set_up_wallet()
status_account_address = wallet_view.get_wallet_address()[2:]
wallet_view.back_button.click()
self.network_api.get_donate(status_account_address, external_faucet=False)
self.network_api.get_donate(status_account_address, external_faucet=True)
wallet_view.wait_balance_is_changed()
account_name = 'subaccount'
wallet_view.add_account(account_name, keycard=True)

View File

@ -247,7 +247,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.set_up_wallet()
status_account_address = wallet_view.get_wallet_address()[2:]
wallet_view.back_button.click()
self.network_api.get_donate(status_account_address, external_faucet=False)
self.network_api.get_donate(status_account_address, external_faucet=True)
wallet_view.wait_balance_is_changed()
account_name = 'subaccount'
wallet_view.add_account(account_name)