functional_tests: python3 compatibility

and add missing tests
This commit is contained in:
moneromooo-monero 2019-05-29 11:45:25 +00:00
parent 1fac83858a
commit 6b72541dc0
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
7 changed files with 15 additions and 15 deletions

View file

@ -32,6 +32,7 @@
"""Test wallet address book RPC """Test wallet address book RPC
""" """
from __future__ import print_function
from framework.wallet import Wallet from framework.wallet import Wallet
class AddressBookTest(): class AddressBookTest():
@ -40,7 +41,7 @@ class AddressBookTest():
self.test_address_book() self.test_address_book()
def create(self): def create(self):
print 'Creating wallet' print('Creating wallet')
wallet = Wallet() wallet = Wallet()
# close the wallet if any, will throw if none is loaded # close the wallet if any, will throw if none is loaded
try: wallet.close_wallet() try: wallet.close_wallet()
@ -51,7 +52,7 @@ class AddressBookTest():
assert res.seed == seed assert res.seed == seed
def test_address_book(self): def test_address_book(self):
print 'Testing address book' print('Testing address book')
wallet = Wallet() wallet = Wallet()
# empty at start # empty at start

View file

@ -10,7 +10,7 @@ import string
import os import os
USAGE = 'usage: functional_tests_rpc.py <python> <srcdir> <builddir> [<tests-to-run> | all]' USAGE = 'usage: functional_tests_rpc.py <python> <srcdir> <builddir> [<tests-to-run> | all]'
DEFAULT_TESTS = ['bans', 'daemon_info', 'blockchain', 'wallet', 'integrated_address', 'mining', 'transfer', 'txpool', 'multisig', 'cold_signing', 'sign_message', 'proofs', 'get_output_distribution', 'address_book', 'uri'] DEFAULT_TESTS = ['address_book', 'bans', 'blockchain', 'cold_signing', 'daemon_info', 'get_output_distribution', 'integrated_address', 'mining', 'multisig', 'proofs', 'sign_message', 'transfer', 'txpool', 'uri', 'validate_address', 'wallet']
try: try:
python = sys.argv[1] python = sys.argv[1]
srcdir = sys.argv[2] srcdir = sys.argv[2]
@ -135,6 +135,6 @@ else:
if len(FAIL) == 0: if len(FAIL) == 0:
print('Done, ' + str(len(PASS)) + '/' + str(len(tests)) + ' tests passed') print('Done, ' + str(len(PASS)) + '/' + str(len(tests)) + ' tests passed')
else: else:
print('Done, ' + str(len(FAIL)) + '/' + str(len(tests)) + ' tests failed: ' + string.join(FAIL, ', ')) print('Done, ' + str(len(FAIL)) + '/' + str(len(tests)) + ' tests failed: ' + ', '.join(FAIL))
sys.exit(0 if len(FAIL) == 0 else 1) sys.exit(0 if len(FAIL) == 0 else 1)

View file

@ -143,7 +143,7 @@ class MiningTest():
assert res_status.active == False assert res_status.active == False
def submitblock(self): def submitblock(self):
print "Test submitblock" print("Test submitblock")
daemon = Daemon() daemon = Daemon()
res = daemon.get_height() res = daemon.get_height()

View file

@ -48,7 +48,7 @@ from framework.wallet import Wallet
class SpeedTest(): class SpeedTest():
def reset(self): def reset(self):
print 'Resetting blockchain' print('Resetting blockchain')
daemon = Daemon() daemon = Daemon()
res = daemon.get_height() res = daemon.get_height()
daemon.pop_blocks(res.height - 1) daemon.pop_blocks(res.height - 1)

View file

@ -792,7 +792,7 @@ class TransferTest():
if not k in unrecoverable_fields: if not k in unrecoverable_fields:
e[k] = x[k] e[k] = x[k]
new_t_out.append(e) new_t_out.append(e)
assert sorted(old_t_out) == sorted(new_t_out) assert sorted(old_t_out, key = lambda k: k['txid']) == sorted(new_t_out, key = lambda k: k['txid'])
def check_is_key_image_spent(self): def check_is_key_image_spent(self):
daemon = Daemon() daemon = Daemon()

View file

@ -28,11 +28,10 @@
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import time
"""Test address validation RPC calls """Test address validation RPC calls
""" """
from __future__ import print_function
from framework.wallet import Wallet from framework.wallet import Wallet
class AddressValidationTest(): class AddressValidationTest():

View file

@ -58,7 +58,7 @@ class WalletTest():
assert WALLET_DIRECTORY != '' assert WALLET_DIRECTORY != ''
try: try:
os.unlink(WALLET_DIRECTORY + '/' + name) os.unlink(WALLET_DIRECTORY + '/' + name)
except OSError, e: except OSError as e:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
@ -183,7 +183,7 @@ class WalletTest():
res = wallet.label_account(0, "main") res = wallet.label_account(0, "main")
def tags(self): def tags(self):
print 'Testing tags' print('Testing tags')
wallet = Wallet() wallet = Wallet()
res = wallet.get_account_tags() res = wallet.get_account_tags()
assert not 'account_tags' in res or len(res.account_tags) == 0 assert not 'account_tags' in res or len(res.account_tags) == 0
@ -256,7 +256,7 @@ class WalletTest():
assert sorted(subaddress_accounts) == [(0, '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 'main'), (1, '82pP87g1Vkd3LUMssBCumk3MfyEsFqLAaGDf6oxddu61EgSFzt8gCwUD4tr3kp9TUfdPs2CnpD7xLZzyC1Ei9UsW3oyCWDf', 'idx1_new')] assert sorted(subaddress_accounts) == [(0, '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 'main'), (1, '82pP87g1Vkd3LUMssBCumk3MfyEsFqLAaGDf6oxddu61EgSFzt8gCwUD4tr3kp9TUfdPs2CnpD7xLZzyC1Ei9UsW3oyCWDf', 'idx1_new')]
def attributes(self): def attributes(self):
print 'Testing attributes' print('Testing attributes')
wallet = Wallet() wallet = Wallet()
ok = False ok = False
@ -319,13 +319,13 @@ class WalletTest():
languages = res.languages languages = res.languages
languages_local = res.languages_local languages_local = res.languages_local
for language in languages + languages_local: for language in languages + languages_local:
print('Creating ' + language.encode('utf8') + ' wallet') print('Creating ' + language + ' wallet')
wallet.create_wallet(filename = '', language = language) wallet.create_wallet(filename = '', language = language)
res = wallet.query_key('mnemonic') res = wallet.query_key('mnemonic')
wallet.close_wallet() wallet.close_wallet()
def change_password(self): def change_password(self):
print 'Testing password change' print('Testing password change')
wallet = Wallet() wallet = Wallet()
# close the wallet if any, will throw if none is loaded # close the wallet if any, will throw if none is loaded
@ -359,7 +359,7 @@ class WalletTest():
self.remove_wallet_files('test1') self.remove_wallet_files('test1')
def store(self): def store(self):
print 'Testing store' print('Testing store')
wallet = Wallet() wallet = Wallet()
# close the wallet if any, will throw if none is loaded # close the wallet if any, will throw if none is loaded