Skip to content

Commit 6a33c47

Browse files
authored
e2e: balance test (#21440)
1 parent 6a26eba commit 6a33c47

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

test/appium/tests/critical/test_wallet.py

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import pytest
55
from _pytest.outcomes import Failed
66
from selenium.common import TimeoutException, NoSuchElementException
7-
87
from base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
98
from support.api.network_api import NetworkApi
109
from tests import marks, run_in_parallel
@@ -192,17 +191,65 @@ def test_wallet_send_asset_from_drawer(self):
192191

193192
@pytest.mark.xdist_group(name="new_one_2")
194193
@marks.nightly
194+
@marks.secured
195195
@marks.smoke
196196
class TestWalletOneDevice(MultipleSharedDeviceTestCase):
197197

198198
def prepare_devices(self):
199199
self.network_api = NetworkApi()
200200
self.drivers, self.loop = create_shared_drivers(1)
201201
self.sign_in_view = SignInView(self.drivers[0])
202-
self.sign_in_view.create_user()
202+
self.sender, self.receiver = transaction_senders['ETH_1'], transaction_senders['ETH_2']
203+
self.total_balance = {'Ether': 0.0052, 'USDCoin': 5.0, 'Status': 10.0, 'Uniswap': 0.627, 'Dai Stablecoin': 0.0}
204+
self.mainnet_balance = {'Ether': 0.005, 'USDCoin': 0.0, 'Status': 10.0, 'Uniswap': 0.127, 'Dai Stablecoin': 0.0}
205+
self.optimizm_balance = {'Ether': 0.0001, 'USDCoin': 5.0, 'Status': 0, 'Uniswap': 0, 'Dai Stablecoin': 0.0}
206+
self.arb_balance = {'Ether': 0.0001, 'USDCoin': 0.0, 'Status': 0.0, 'Uniswap': 0.5, 'Dai Stablecoin': 0.0}
207+
self.sender['wallet_address'] = '0x' + self.sender['address']
208+
self.receiver['wallet_address'] = '0x' + self.receiver['address']
209+
self.sender_username, self.receiver_username = 'sender', 'receiver'
210+
self.sign_in_view.recover_access(passphrase=self.sender['passphrase'], username=self.sender_username)
211+
203212
self.home_view = self.sign_in_view.get_home_view()
204213
self.wallet_view = self.home_view.wallet_tab.click()
205214

215+
@marks.testrail_id(740490)
216+
def test_wallet_balance_mainnet(self):
217+
self.profile_view = self.home_view.profile_button.click()
218+
self.profile_view.switch_network()
219+
self.sign_in_view.sign_in()
220+
self.sign_in_view.wallet_tab.click()
221+
222+
self.wallet_view.just_fyi("Checking total balance")
223+
real_balance = {}
224+
for asset in self.total_balance:
225+
real_balance[asset] = self.wallet_view.get_asset(asset).get_amount()
226+
227+
for asset in self.total_balance:
228+
if real_balance[asset] != self.total_balance[asset]:
229+
self.errors.append("For the %s the wrong value %s is shown, expected %s in total" %
230+
(asset, real_balance[asset], self.total_balance[asset]))
231+
expected_balances = {
232+
'Mainnet': self.mainnet_balance,
233+
'Arbitrum': self.arb_balance,
234+
'Optimism': self.optimizm_balance
235+
}
236+
237+
for network in expected_balances:
238+
self.wallet_view.just_fyi("Checking total balance on %s network" % network)
239+
self.wallet_view.select_network(network)
240+
real_balance = {}
241+
for asset in expected_balances[network]:
242+
real_balance[asset] = self.wallet_view.get_asset(asset).get_amount()
243+
self.wallet_view.just_fyi("real on %s %s" % (network, str(real_balance)))
244+
self.wallet_view.just_fyi("real on %s %s" % (network, str(expected_balances[network])))
245+
for asset in expected_balances[network]:
246+
if real_balance[asset] != expected_balances[network][asset]:
247+
self.errors.append("For the %s the wrong value %s is shown, expected %s on %s" %
248+
(asset, real_balance[asset], self.total_balance[asset], network))
249+
self.wallet_view.select_network(network)
250+
251+
self.errors.verify_no_errors()
252+
206253
@marks.testrail_id(727231)
207254
def test_wallet_add_remove_regular_account(self):
208255
self.wallet_view.just_fyi("Adding new regular account")

test/appium/views/profile_view.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ def __init__(self, driver):
305305
suffix="/following-sibling::*[1]/android.widget.EditText")
306306
self.specify_network_id_input = EditBox(self.driver, translation_id="specify-network-id")
307307
self.connect_button = Button(self.driver, accessibility_id="network-connect-button")
308+
308309
## Toggles
309310
self.transaction_management_enabled_toggle = Button(self.driver,
310311
accessibility_id="transactions-management-enabled")
@@ -360,6 +361,7 @@ def __init__(self, driver):
360361
self.confirm_testnet_mode_change_button = Button(self.driver, accessibility_id="confirm-testnet-mode-change")
361362

362363
def switch_network(self):
364+
self.driver.info("Toggling test mode")
363365
self.profile_wallet_button.click()
364366
self.network_settings_button.click()
365367
self.testnet_mode_toggle.click()

test/appium/views/wallet_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, driver, asset_name):
1919

2020
def get_amount(self):
2121
element = Text(self.driver, xpath=self.locator + "/../android.widget.TextView[3]")
22-
element.scroll_to_element(down_start_y=0.89, down_end_y=0.8)
22+
element.scroll_to_element()
2323
try:
2424
amount = element.text.split()[0]
2525
if '<' in amount:

0 commit comments

Comments
 (0)