test fixes to get it running on travis

This commit is contained in:
Lex Berezhny 2018-05-25 13:19:54 -04:00
parent 4e4c4b5f96
commit 246cc234c4
5 changed files with 25 additions and 22 deletions

View file

@ -2,12 +2,11 @@ import os
import re import re
from setuptools import setup, find_packages from setuptools import setup, find_packages
init_file = open(os.path.join(os.path.dirname(__path__), 'torba', '__init__.py')).read() import torba
version = re.search('\d+\.\d+\.\d+', init_file).group()
setup( setup(
name='torba', name='torba',
version=version, version=torba.__version__,
url='https://github.com/lbryio/torba', url='https://github.com/lbryio/torba',
license='MIT', license='MIT',
author='LBRY Inc.', author='LBRY Inc.',
@ -29,7 +28,7 @@ setup(
), ),
packages=find_packages(exclude=('tests',)), packages=find_packages(exclude=('tests',)),
include_package_data=True, include_package_data=True,
python_requires='>=2.7,>=3.6', python_requires='>=2.7',
install_requires=( install_requires=(
'twisted', 'twisted',
'ecdsa', 'ecdsa',

View file

@ -39,25 +39,25 @@ class TestAccount(unittest.TestCase):
) )
self.assertEqual( self.assertEqual(
account.private_key.extended_key_string(), account.private_key.extended_key_string(),
'xprv9s21ZrQH143K2dyhK7SevfRG72bYDRNv25yKPWWm6dqApNxm1Zb1m5gGcBWYfbsPjTr2v5joit8Af2Zp5P' b'xprv9s21ZrQH143K2dyhK7SevfRG72bYDRNv25yKPWWm6dqApNxm1Zb1m5gGcBWYfbsPjTr2v5joit8Af2Zp5P'
'6yz3jMbycrLrRMpeAJxR8qDg8' b'6yz3jMbycrLrRMpeAJxR8qDg8'
) )
self.assertEqual( self.assertEqual(
account.public_key.extended_key_string(), account.public_key.extended_key_string(),
'xpub661MyMwAqRbcF84AR8yfHoMzf4S2ct6mPJtvBtvNeyN9hBHuZ6uGJszkTSn5fQUCdz3XU17eBzFeAUwV6f' b'xpub661MyMwAqRbcF84AR8yfHoMzf4S2ct6mPJtvBtvNeyN9hBHuZ6uGJszkTSn5fQUCdz3XU17eBzFeAUwV6f'
'iW44g14WF52fYC5J483wqQ5ZP' b'iW44g14WF52fYC5J483wqQ5ZP'
) )
self.assertEqual( self.assertEqual(
account.receiving_keys.generate_next_address(), account.receiving_keys.generate_next_address(),
'1PmX9T3sCiDysNtWszJa44SkKcpGc2NaXP' b'1PmX9T3sCiDysNtWszJa44SkKcpGc2NaXP'
) )
private_key = account.get_private_key_for_address('1PmX9T3sCiDysNtWszJa44SkKcpGc2NaXP') private_key = account.get_private_key_for_address(b'1PmX9T3sCiDysNtWszJa44SkKcpGc2NaXP')
self.assertEqual( self.assertEqual(
private_key.extended_key_string(), private_key.extended_key_string(),
'xprv9xNEfQ296VTRaEUDZ8oKq74xw2U6kpj486vFUB4K1wT9U25GX4UwuzFgJN1YuRrqkQ5TTwCpkYnjNpSoHS' b'xprv9xNEfQ296VTRaEUDZ8oKq74xw2U6kpj486vFUB4K1wT9U25GX4UwuzFgJN1YuRrqkQ5TTwCpkYnjNpSoHS'
'BaEigNHPkoeYbuPMRo6mRUjxg' b'BaEigNHPkoeYbuPMRo6mRUjxg'
) )
self.assertIsNone(account.get_private_key_for_address('BcQjRlhDOIrQez1WHfz3whnB33Bp34sUgX')) self.assertIsNone(account.get_private_key_for_address(b'BcQjRlhDOIrQez1WHfz3whnB33Bp34sUgX'))
self.assertEqual( self.assertEqual(
hexlify(private_key.wif()), hexlify(private_key.wif()),
@ -92,12 +92,12 @@ class TestAccount(unittest.TestCase):
self.assertEqual(len(account.receiving_keys.addresses), 2) self.assertEqual(len(account.receiving_keys.addresses), 2)
self.assertEqual( self.assertEqual(
account.receiving_keys.addresses[0], account.receiving_keys.addresses[0],
'1PmX9T3sCiDysNtWszJa44SkKcpGc2NaXP' b'1PmX9T3sCiDysNtWszJa44SkKcpGc2NaXP'
) )
self.assertEqual(len(account.change_keys.addresses), 1) self.assertEqual(len(account.change_keys.addresses), 1)
self.assertEqual( self.assertEqual(
account.change_keys.addresses[0], account.change_keys.addresses[0],
'1PUbu1D1f3c244JPRSJKBCxRqui5NT6geR' b'1PUbu1D1f3c244JPRSJKBCxRqui5NT6geR'
) )
self.maxDiff = None self.maxDiff = None

View file

@ -1,7 +1,11 @@
import mock
from unittest import TestCase from unittest import TestCase
from torba.hash import aes_decrypt, aes_encrypt from torba.hash import aes_decrypt, aes_encrypt
try:
from unittest import mock
except ImportError:
import mock
class TestAESEncryptDecrypt(TestCase): class TestAESEncryptDecrypt(TestCase):

View file

@ -86,12 +86,12 @@ class TestWalletCreation(unittest.TestCase):
self.assertEqual(len(account.receiving_keys.addresses), 2) self.assertEqual(len(account.receiving_keys.addresses), 2)
self.assertEqual( self.assertEqual(
account.receiving_keys.addresses[0], account.receiving_keys.addresses[0],
'1PmX9T3sCiDysNtWszJa44SkKcpGc2NaXP' b'1PmX9T3sCiDysNtWszJa44SkKcpGc2NaXP'
) )
self.assertEqual(len(account.change_keys.addresses), 1) self.assertEqual(len(account.change_keys.addresses), 1)
self.assertEqual( self.assertEqual(
account.change_keys.addresses[0], account.change_keys.addresses[0],
'1PUbu1D1f3c244JPRSJKBCxRqui5NT6geR' b'1PUbu1D1f3c244JPRSJKBCxRqui5NT6geR'
) )
wallet_dict['coins'] = {'btc_mainnet': {'fee_per_byte': 50}} wallet_dict['coins'] = {'btc_mainnet': {'fee_per_byte': 50}}
self.assertDictEqual(wallet_dict, wallet.to_dict()) self.assertDictEqual(wallet_dict, wallet.to_dict())

View file

@ -102,11 +102,11 @@ class Account:
'seed': self.seed, 'seed': self.seed,
'encrypted': self.encrypted, 'encrypted': self.encrypted,
'private_key': self.private_key if self.encrypted else 'private_key': self.private_key if self.encrypted else
self.private_key.extended_key_string(), self.private_key.extended_key_string().decode(),
'public_key': self.public_key.extended_key_string(), 'public_key': self.public_key.extended_key_string().decode(),
'receiving_keys': [hexlify(k).decode('iso-8859-1') for k in self.receiving_keys.child_keys], 'receiving_keys': [hexlify(k).decode() for k in self.receiving_keys.child_keys],
'receiving_gap': self.receiving_keys.minimum_gap, 'receiving_gap': self.receiving_keys.minimum_gap,
'change_keys': [hexlify(k).decode('iso-8859-1') for k in self.change_keys.child_keys], 'change_keys': [hexlify(k).decode() for k in self.change_keys.child_keys],
'change_gap': self.change_keys.minimum_gap 'change_gap': self.change_keys.minimum_gap
} }