yenda b13864d052
[refactor] move utils.ethereum to ethereum
move utils.ethereum.tokens to ethereum.tokens
move utils.ethereum.abi-spec to ethereum.abi-spec
move utils.ethereum.core to ethereum.core
move utils.ethereum.eip165 to ethereum.eip165
move utils.ethereum.eip55 to ethereum.eip55
move utils.ethereum.eip681 to ethereum.eip681
move utils.ethereum.ens to ethereum.ens
move utils.ethereum.erc721 to ethereum.erc721
move utils.ethereum.mnemonics to ethereum.mnemonics
move utils.ethereum.resolver to ethereum.resolver
move utils.ethereum.macros to ethereum.macros

Signed-off-by: yenda <eric@status.im>
2019-05-23 15:11:48 +02:00

39 lines
1.3 KiB
Python

import os
import pytest
import re
import time
from os import path
from support.api.third_parties_api import get_token_info
from tests import marks
def get_parameters():
directory = os.sep.join(__file__.split(os.sep)[:-4])
file_path = path.join(directory, 'src/status_im/ethereum/tokens.cljs')
with open(file_path, 'r') as f:
data = f.read()
return re.findall('{:symbol\s*:(.*)\n\s*:name\s*"(.*)"\n\s*:address\s*"(.*)"\n\s*:decimals\s*(.*)}', data)
class TestAPi(object):
@marks.api
@pytest.mark.parametrize('symbol,name,address,decimals', get_parameters())
def test_tokens_verification(self, symbol, name, address, decimals):
res = get_token_info(address)
errors = list()
if str(res['decimals']) != decimals:
errors.append("decimals value %s doesn't match expected %s" % (decimals, res['decimals']))
if res['symbol'] != symbol:
errors.append("symbol '%s' doesn't match expected '%s'" % (symbol, res['symbol']))
if res['name'] != name:
errors.append("token name '%s' doesn't match expected '%s'" % (name, res['name']))
if errors:
pytest.fail('For address %s %s' % (address, ', '.join(errors)))
@staticmethod
def teardown():
time.sleep(3)