txs history test added (testrail id 5314)

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
Oleksii Lymarenko 2018-10-11 23:28:52 +03:00 committed by yenda
parent bc688421ea
commit 3bda480fe6
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
5 changed files with 82 additions and 8 deletions

View File

@ -1,22 +1,24 @@
import logging
from typing import List
import pytest
import requests
import time
from json import JSONDecodeError
class NetworkApi:
class NetworkApi(object):
def __init__(self):
self.network_url = 'http://api-%s.etherscan.io/api?' % pytest.config.getoption('network')
self.faucet_url = 'http://51.15.45.169:3001/donate'
self.chat_bot_url = 'http://offsite.chat:8099'
def get_transactions(self, address: str) -> dict:
def get_transactions(self, address: str) -> List[dict]:
method = self.network_url + 'module=account&action=txlist&address=0x%s&sort=desc' % address
return requests.request('GET', url=method).json()['result']
def get_token_transactions(self, address: str) -> dict:
def get_token_transactions(self, address: str) -> List[dict]:
method = self.network_url + 'module=account&action=tokentx&address=0x%s&sort=desc' % address
return requests.request('GET', url=method).json()['result']

View File

@ -1,3 +1,7 @@
from operator import itemgetter
from typing import List
def fill_string_with_char(string: str, fillchar: str, amount: int, start: bool = False, end: bool = False) -> str:
"""
:param string: input string to be formatted
@ -23,3 +27,14 @@ def fill_string_with_char(string: str, fillchar: str, amount: int, start: bool =
if end:
string_revised = string_revised.ljust(len(string_revised)+len(fill_with), fillchar)
return string_revised
def get_merged_txs_list(normal_txs_list, token_events_list) -> List[dict]:
res = []
for i in normal_txs_list:
for j in token_events_list:
if i['hash'] == j['hash']:
normal_txs_list.remove(i)
res.extend(normal_txs_list)
res.extend(token_events_list)
return sorted(res, key=itemgetter('timeStamp'), reverse=True)

View File

@ -2,6 +2,7 @@ import random
import pytest
from support.utilities import get_merged_txs_list
from tests import marks, unique_password, common_password
from tests.base_test_case import SingleDeviceTestCase, MultipleDeviceTestCase
from tests.users import transaction_senders, basic_user, wallet_users, transaction_recipients
@ -363,6 +364,47 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
send_transaction.sign_transaction()
self.network_api.find_transaction_by_unique_amount(sender['address'], amount)
@marks.testrail_id(5314)
@marks.critical
def test_can_see_all_transactions_in_history(self):
address = transaction_senders['W']['address']
passphrase = transaction_senders['W']['passphrase']
ropsten_txs = self.network_api.get_transactions(address)
ropsten_tokens = self.network_api.get_token_transactions(address)
expected_txs_list = get_merged_txs_list(ropsten_txs, ropsten_tokens)
signin_view = SignInView(self.driver)
home_view = signin_view.recover_access(passphrase=passphrase)
wallet_view = home_view.wallet_button.click()
wallet_view.set_up_wallet()
transaction_view = wallet_view.transaction_history_button.click()
status_tx_number = transaction_view.transactions_table.get_transactions_number()
actual_txs_list = []
for n in range(status_tx_number):
transactions_details = transaction_view.transactions_table.transaction_by_index(n).click()
status_tx = {
'hash': transactions_details.get_transaction_hash(),
'from': transactions_details.get_sender_address(),
'to': transactions_details.get_recipient_address(),
}
actual_txs_list.append(status_tx)
transactions_details.back_button.click()
if [tx['hash'] for tx in actual_txs_list] != [tx['hash'] for tx in expected_txs_list]:
self.errors.append('Transactions hashes do not match!')
if [tx['from'] for tx in actual_txs_list] != [tx['from'] for tx in expected_txs_list]:
self.errors.append('Transactions senders do not match!')
if [tx['to'] for tx in actual_txs_list] != [tx['to'] for tx in expected_txs_list]:
self.errors.append('Transactions recipients do not match!')
self.verify_no_errors()
@marks.transaction
class TestTransactionWalletMultipleDevice(MultipleDeviceTestCase):

View File

@ -181,6 +181,12 @@ transaction_senders['V']['username'] = "Handsome Breakable Trout"
transaction_senders['V']['address'] = "785acde6058a670e674aa0f66ccbabe98bbce7b1"
transaction_senders['V']['public_key'] = "0x04617c8001fd201c80095eb55ed483c1d3c8abb1f273215a694b3606bbde53460ea1909b"\
"b2c58340afc8e55768fc1cb6a6a91592019bbdeefb75f5caab05c9ed11"
transaction_senders['W'] = dict()
transaction_senders['W']['passphrase'] = "setup portion luxury fatigue unhappy position pioneer sell angry trust hat magic"
transaction_senders['W']['username'] = "Adorable Linen Oriole"
transaction_senders['W']['address'] = "d5de9a58a3eab0643ecbd01729312215ef647a4d"
transaction_senders['W']['public_key'] = "0x04fe5b77e1f0aa15b36090db04d830cd080a716982503d6b962a6ba2ed8f42bdbcc66bba8" \
"9dba8c35620313c50f7ac625c9c75199d2164b07253143717f6ef0834"
transaction_recipients = dict()
@ -218,3 +224,9 @@ transaction_recipients['E']['username'] = "Likely Darkgreen Iridescentshark"
transaction_recipients['E']['address'] = "5c1d183ca67f651d864a2c88318c05dc0e32f188"
transaction_recipients['E']['public_key'] = "0x043dd70b791b95afabab57e9c68bf94e706927d0907e7cc59e60d3c93e7eb061210" \
"c3556b62bee28337db6636b99fbdfaf7cb3ea0ead63192deae6b4ba48ceeb39"
transaction_recipients['F'] = dict()
transaction_recipients['F']['passphrase'] = "gather please ritual cactus plunge cruel foil armor sock topic fence urge"
transaction_recipients['F']['username'] = "Exhausted Yellowgreen Polecat"
transaction_recipients['F']['address'] = "81e0b035fe73f4f1aefeb5c75537c7d9b423149f"
transaction_recipients['F']['public_key'] = "0x04bf7da995d4e35a9fec3eec00f1b628d8c47fe931014111236cae617bd1dbd4743a49" \
"684d083b4552d86a37380c8b0d49688e2026e2c801b4b503a9a8383c533d"

View File

@ -1,6 +1,4 @@
import time
import pytest
from selenium.common.exceptions import NoSuchElementException
from views.base_element import BaseElement, BaseButton, BaseText
from views.base_view import BaseView
@ -66,14 +64,19 @@ class TransactionTable(BaseElement):
self).__init__(driver)
self.locator = self.Locator.xpath_selector(locator)
def text(self):
text = self.find_element().text
self.driver.info('%s is %s' % (self.name, text))
return text
def get_transaction_hash(self) -> str:
return self.DetailsTextElement(driver=self.driver, locator=self.locators['transaction_hash']).text
return self.DetailsTextElement(driver=self.driver, locator=self.locators['transaction_hash']).text()
def get_sender_address(self) -> str:
return self.DetailsTextElement(driver=self.driver, locator=self.locators['sender_address']).text
return self.DetailsTextElement(driver=self.driver, locator=self.locators['sender_address']).text()
def get_recipient_address(self) -> str:
return self.DetailsTextElement(driver=self.driver, locator=self.locators['recipient_address']).text
return self.DetailsTextElement(driver=self.driver, locator=self.locators['recipient_address']).text()
def navigate(self):
return self.TransactionDetailsView(self.driver)