Merge pull request #5584

eeebad66 functional_tests: fix python3 compatibility (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2019-06-01 20:32:39 +02:00
commit 256f8d8b66
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
15 changed files with 60 additions and 59 deletions

View File

@ -28,6 +28,7 @@
# 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.
from __future__ import print_function
import time
"""Test peer baning RPC calls
@ -42,7 +43,7 @@ from framework.daemon import Daemon
class BanTest():
def run_test(self):
print 'Testing bans'
print('Testing bans')
daemon = Daemon()
res = daemon.get_bans()

View File

@ -28,6 +28,7 @@
# 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.
from __future__ import print_function
import time
"""Test daemon blockchain RPC calls
@ -50,7 +51,7 @@ class BlockchainTest():
self._test_alt_chains()
def reset(self):
print 'Resetting blockchain'
print('Resetting blockchain')
daemon = Daemon()
daemon.pop_blocks(1000)
daemon.flush_txpool()
@ -58,7 +59,7 @@ class BlockchainTest():
def _test_generateblocks(self, blocks):
assert blocks >= 2
print "Test generating", blocks, 'blocks'
print("Test generating", blocks, 'blocks')
daemon = Daemon()
@ -182,14 +183,14 @@ class BlockchainTest():
for idx in tx.output_indices:
assert idx == running_output_index
running_output_index += 1
res_out = daemon.get_outs([{'amount': 0, 'index': i} for i in tx.output_indices], get_txid = True)
res_out = daemon.get_outs([{'amount': 0, 'index': idx} for idx in tx.output_indices], get_txid = True)
assert len(res_out.outs) == len(tx.output_indices)
for out in res_out.outs:
assert len(out.key) == 64
assert len(out.mask) == 64
assert not out.unlocked
assert out.height == i + 1
assert out.txid == txids[i + 1]
assert out.height == i
assert out.txid == txids[i]
for i in range(height + nblocks - 1):
res_sum = daemon.get_coinbase_tx_sum(i, 1)
@ -255,7 +256,7 @@ class BlockchainTest():
alt_blocks[i] = txid
nonce += 1
print 'mining 3 on 1'
print('mining 3 on 1')
# three more on [1]
chain1 = []
res = daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 3, prev_block = alt_blocks[1], starting_nonce = nonce)
@ -275,7 +276,7 @@ class BlockchainTest():
for txid in alt_blocks:
assert txid in res.blks_hashes or txid == alt_blocks[1]
print 'mining 4 on 3'
print('mining 4 on 3')
# 4 more on [3], the chain will reorg when we mine the 4th
top_block_hash = blk_hash
prev_block = alt_blocks[3]

View File

@ -28,11 +28,10 @@
# 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.
import time
"""Test cold tx signing
"""
from __future__ import print_function
from framework.daemon import Daemon
from framework.wallet import Wallet
@ -44,13 +43,13 @@ class ColdSigningTest():
self.transfer()
def reset(self):
print 'Resetting blockchain'
print('Resetting blockchain')
daemon = Daemon()
daemon.pop_blocks(1000)
daemon.flush_txpool()
def create(self, idx):
print 'Creating hot and cold wallet'
print('Creating hot and cold wallet')
self.hot_wallet = Wallet(idx = 0)
# close the wallet if any, will throw if none is loaded
@ -116,7 +115,7 @@ class ColdSigningTest():
assert len(res.unsigned_txset) > 0
unsigned_txset = res.unsigned_txset
print 'Signing transaction with cold wallet'
print('Signing transaction with cold wallet')
res = self.cold_wallet.describe_transfer(unsigned_txset = unsigned_txset)
assert len(res.desc) == 1
desc = res.desc[0]
@ -140,7 +139,7 @@ class ColdSigningTest():
txid = res.tx_hash_list[0]
assert len(txid) == 64
print 'Submitting transaction with hot wallet'
print('Submitting transaction with hot wallet')
res = self.hot_wallet.submit_transfer(signed_txset)
assert len(res.tx_hash_list) > 0
assert res.tx_hash_list[0] == txid

View File

@ -36,6 +36,7 @@ Test the following RPCs:
"""
from __future__ import print_function
from framework.daemon import Daemon
class DaemonGetInfoTest():

View File

@ -10,7 +10,7 @@ import string
import os
USAGE = 'usage: functional_tests_rpc.py <python> <srcdir> <builddir> [<tests-to-run> | all]'
DEFAULT_TESTS = ['daemon_info', 'blockchain', 'wallet_address', 'integrated_address', 'mining', 'transfer', 'txpool', 'multisig', 'cold_signing', 'sign_message', 'proofs', 'get_output_distribution']
DEFAULT_TESTS = ['bans', 'daemon_info', 'blockchain', 'wallet_address', 'integrated_address', 'mining', 'transfer', 'txpool', 'multisig', 'cold_signing', 'sign_message', 'proofs', 'get_output_distribution']
try:
python = sys.argv[1]
srcdir = sys.argv[2]

View File

@ -28,11 +28,10 @@
# 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.
import time
"""Test get_output_distribution RPC
"""
from __future__ import print_function
from framework.daemon import Daemon
from framework.wallet import Wallet
@ -43,7 +42,7 @@ class GetOutputDistributionTest():
self.test_get_output_distribution()
def reset(self):
print 'Resetting blockchain'
print('Resetting blockchain')
daemon = Daemon()
daemon.pop_blocks(1000)
daemon.flush_txpool()
@ -56,7 +55,7 @@ class GetOutputDistributionTest():
res = self.wallet.restore_deterministic_wallet(seed = 'velvet lymph giddy number token physics poetry unquoted nibs useful sabotage limits benches lifestyle eden nitrogen anvil fewest avoid batch vials washing fences goat unquoted')
def test_get_output_distribution(self):
print "Test get_output_distribution"
print("Test get_output_distribution")
daemon = Daemon()

View File

@ -28,8 +28,6 @@
# 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.
import time
"""Test integrated address RPC calls
Test the following RPCs:
@ -38,6 +36,7 @@ Test the following RPCs:
"""
from __future__ import print_function
from framework.wallet import Wallet
class IntegratedAddressTest():
@ -46,7 +45,7 @@ class IntegratedAddressTest():
self.check()
def create(self):
print 'Creating wallet'
print('Creating wallet')
wallet = Wallet()
# close the wallet if any, will throw if none is loaded
try: wallet.close_wallet()
@ -59,7 +58,7 @@ class IntegratedAddressTest():
def check(self):
wallet = Wallet()
print 'Checking local address'
print('Checking local address')
res = wallet.make_integrated_address(payment_id = '0123456789abcdef')
assert res.integrated_address == '4CMe2PUhs4J4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfSbLRB61BQVATzerHGj'
assert res.payment_id == '0123456789abcdef'
@ -67,7 +66,7 @@ class IntegratedAddressTest():
assert res.standard_address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
assert res.payment_id == '0123456789abcdef'
print 'Checking different address'
print('Checking different address')
res = wallet.make_integrated_address(standard_address = '46r4nYSevkfBUMhuykdK3gQ98XDqDTYW1hNLaXNvjpsJaSbNtdXh1sKMsdVgqkaihChAzEy29zEDPMR3NHQvGoZCLGwTerK', payment_id = '1122334455667788')
assert res.integrated_address == '4GYjoMG9Y2BBUMhuykdK3gQ98XDqDTYW1hNLaXNvjpsJaSbNtdXh1sKMsdVgqkaihChAzEy29zEDPMR3NHQvGoZCVSs1ZojwrDCGS5rUuo'
assert res.payment_id == '1122334455667788'
@ -75,7 +74,7 @@ class IntegratedAddressTest():
assert res.standard_address == '46r4nYSevkfBUMhuykdK3gQ98XDqDTYW1hNLaXNvjpsJaSbNtdXh1sKMsdVgqkaihChAzEy29zEDPMR3NHQvGoZCLGwTerK'
assert res.payment_id == '1122334455667788'
print 'Checking bad payment id'
print('Checking bad payment id')
fails = 0
try: wallet.make_integrated_address(standard_address = '46r4nYSevkfBUMhuykdK3gQ98XDqDTYW1hNLaXNvjpsJaSbNtdXh1sKMsdVgqkaihChAzEy29zEDPMR3NHQvGoZCLGwTerK', payment_id = '11223344556677880')
except: fails += 1
@ -89,7 +88,7 @@ class IntegratedAddressTest():
except: fails += 1
assert fails == 5
print 'Checking bad standard address'
print('Checking bad standard address')
fails = 0
try: wallet.make_integrated_address(standard_address = '46r4nYSevkfBUMhuykdK3gQ98XDqDTYW1hNLaXNvjpsJaSbNtdXh1sKMsdVgqkaihChAzEy29zEDPMR3NHQvGoZCLGwTerr', payment_id = '1122334455667788')
except: fails += 1

View File

@ -28,6 +28,7 @@
# 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.
from __future__ import print_function
import time
"""Test daemon mining RPC calls
@ -48,13 +49,13 @@ class MiningTest():
self.mine()
def reset(self):
print 'Resetting blockchain'
print('Resetting blockchain')
daemon = Daemon()
daemon.pop_blocks(1000)
daemon.flush_txpool()
def create(self):
print 'Creating wallet'
print('Creating wallet')
wallet = Wallet()
# close the wallet if any, will throw if none is loaded
try: wallet.close_wallet()
@ -62,7 +63,7 @@ class MiningTest():
res = wallet.restore_deterministic_wallet(seed = 'velvet lymph giddy number token physics poetry unquoted nibs useful sabotage limits benches lifestyle eden nitrogen anvil fewest avoid batch vials washing fences goat unquoted')
def mine(self):
print "Test mining"
print("Test mining")
daemon = Daemon()
wallet = Wallet()

View File

@ -28,7 +28,7 @@
# 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.
import time
from __future__ import print_function
"""Test multisig transfers
"""
@ -70,7 +70,7 @@ class MultisigTest():
self.check_transaction(txid)
def reset(self):
print 'Resetting blockchain'
print('Resetting blockchain')
daemon = Daemon()
daemon.pop_blocks(1000)
daemon.flush_txpool()

View File

@ -28,7 +28,7 @@
# 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.
import time
from __future__ import print_function
"""Test misc proofs (tx key, send, receive, reserve)
"""
@ -47,7 +47,7 @@ class ProofsTest():
self.check_reserve_proof()
def reset(self):
print 'Resetting blockchain'
print('Resetting blockchain')
daemon = Daemon()
daemon.pop_blocks(1000)
daemon.flush_txpool()

View File

@ -28,7 +28,7 @@
# 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.
import time
from __future__ import print_function
"""Test message signing/verification RPC calls
@ -46,7 +46,7 @@ class MessageSigningTest():
self.check_signing()
def create(self):
print 'Creating wallets'
print('Creating wallets')
seeds = [
'velvet lymph giddy number token physics poetry unquoted nibs useful sabotage limits benches lifestyle eden nitrogen anvil fewest avoid batch vials washing fences goat unquoted',
'peeled mixture ionic radar utopia puddle buying illness nuns gadget river spout cavernous bounced paradise drunk looking cottage jump tequila melting went winter adjust spout',
@ -66,7 +66,7 @@ class MessageSigningTest():
assert res.seed == seeds[i]
def check_signing(self):
print 'Signing/verifing messages'
print('Signing/verifing messages')
messages = ['foo', '']
for message in messages:
res = self.wallet[0].sign(message)

View File

@ -40,7 +40,7 @@ Test the following RPCs:
import time
from time import sleep
from decimal import Decimal
from __future__ import print_function
from framework.daemon import Daemon
from framework.wallet import Wallet

View File

@ -28,7 +28,7 @@
# 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.
import time
from __future__ import print_function
import json
"""Test simple transfers
@ -48,13 +48,13 @@ class TransferTest():
self.sweep_single()
def reset(self):
print 'Resetting blockchain'
print('Resetting blockchain')
daemon = Daemon()
daemon.pop_blocks(1000)
daemon.flush_txpool()
def create(self):
print 'Creating wallets'
print('Creating wallets')
seeds = [
'velvet lymph giddy number token physics poetry unquoted nibs useful sabotage limits benches lifestyle eden nitrogen anvil fewest avoid batch vials washing fences goat unquoted',
'peeled mixture ionic radar utopia puddle buying illness nuns gadget river spout cavernous bounced paradise drunk looking cottage jump tequila melting went winter adjust spout',
@ -297,7 +297,7 @@ class TransferTest():
assert res.unlocked_balance <= res.balance
assert res.blocks_to_unlock == 9
print 'Creating multi out transfer'
print('Creating multi out transfer')
self.wallet[0].refresh()

View File

@ -28,7 +28,7 @@
# 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.
import time
from __future__ import print_function
"""Test txpool
"""
@ -44,13 +44,13 @@ class TransferTest():
self.check_txpool()
def reset(self):
print 'Resetting blockchain'
print('Resetting blockchain')
daemon = Daemon()
daemon.pop_blocks(1000)
daemon.flush_txpool()
def create(self):
print 'Creating wallet'
print('Creating wallet')
wallet = Wallet()
# close the wallet if any, will throw if none is loaded
try: wallet.close_wallet()
@ -114,15 +114,16 @@ class TransferTest():
assert sorted(res.tx_hashes) == sorted(txes.keys())
print('Flushing 2 transactions')
daemon.flush_txpool([txes.keys()[1], txes.keys()[3]])
txes_keys = list(txes.keys())
daemon.flush_txpool([txes_keys[1], txes_keys[3]])
res = daemon.get_transaction_pool()
assert len(res.transactions) == txpool_size - 2
assert len([x for x in res.transactions if x.id_hash == txes.keys()[1]]) == 0
assert len([x for x in res.transactions if x.id_hash == txes.keys()[3]]) == 0
assert len([x for x in res.transactions if x.id_hash == txes_keys[1]]) == 0
assert len([x for x in res.transactions if x.id_hash == txes_keys[3]]) == 0
new_keys = txes.keys()
new_keys.remove(txes.keys()[1])
new_keys.remove(txes.keys()[3])
new_keys = list(txes.keys())
new_keys.remove(txes_keys[1])
new_keys.remove(txes_keys[3])
res = daemon.get_transaction_pool_hashes()
assert sorted(res.tx_hashes) == sorted(new_keys)

View File

@ -29,8 +29,6 @@
# 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.
import time
"""Test transaction creation RPC calls
Test the following RPCs:
@ -38,6 +36,7 @@ Test the following RPCs:
"""
from __future__ import print_function
from framework.wallet import Wallet
from framework.daemon import Daemon
@ -52,13 +51,13 @@ class WalletAddressTest():
self.languages()
def reset(self):
print 'Resetting blockchain'
print('Resetting blockchain')
daemon = Daemon()
daemon.pop_blocks(1000)
daemon.flush_txpool()
def create(self):
print 'Creating wallet'
print('Creating wallet')
wallet = Wallet()
# close the wallet if any, will throw if none is loaded
try: wallet.close_wallet()
@ -69,7 +68,7 @@ class WalletAddressTest():
assert res.seed == seed
def check_main_address(self):
print 'Getting address'
print('Getting address')
wallet = Wallet()
res = wallet.get_address()
assert res.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', res
@ -79,7 +78,7 @@ class WalletAddressTest():
assert res.addresses[0].used == False
def check_keys(self):
print 'Checking keys'
print('Checking keys')
wallet = Wallet()
res = wallet.query_key('view_key')
assert res.key == '49774391fa5e8d249fc2c5b45dadef13534bf2483dede880dac88f061e809100'
@ -89,7 +88,7 @@ class WalletAddressTest():
assert res.key == 'velvet lymph giddy number token physics poetry unquoted nibs useful sabotage limits benches lifestyle eden nitrogen anvil fewest avoid batch vials washing fences goat unquoted'
def create_subaddresses(self):
print 'Creating subaddresses'
print('Creating subaddresses')
wallet = Wallet()
res = wallet.create_account("idx1")
assert res.account_index == 1, res
@ -160,7 +159,7 @@ class WalletAddressTest():
assert res.index == {'major': 1, 'minor': 0}
def open_close(self):
print 'Testing open/close'
print('Testing open/close')
wallet = Wallet()
res = wallet.get_address()
@ -200,7 +199,7 @@ class WalletAddressTest():
except: pass
languages = res.languages
for language in languages:
print 'Creating ' + str(language) + ' wallet'
print('Creating ' + str(language) + ' wallet')
wallet.create_wallet(filename = '', language = language)
res = wallet.query_key('mnemonic')
wallet.close_wallet()