update to py3 conventions, update cmp to be py3 compatible, update map to return list for py3

This commit is contained in:
mdr0id 2019-12-04 07:48:08 -08:00
parent c3de8a7da5
commit 1e71f89ffd
1 changed files with 7 additions and 13 deletions

View File

@ -1,15 +1,13 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2017 The Zcash developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_greater_than, start_nodes,\
initialize_chain_clean, connect_nodes_bi, wait_and_assert_operationid_status
initialize_chain_clean, connect_nodes_bi, wait_and_assert_operationid_status, wait_and_assert_operationid_status_result
from functools import reduce
import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
@ -48,11 +46,7 @@ class ZkeyImportExportTest (BitcoinTestFramework):
def verify_utxos(node, amts, zaddr):
amts.sort(reverse=True)
txs = node.z_listreceivedbyaddress(zaddr)
def cmp_confirmations_high_to_low(a, b):
return cmp(b["amount"], a["amount"])
txs.sort(cmp_confirmations_high_to_low)
txs.sort(key=lambda x: x["amount"], reverse=True)
print("Sorted txs", txs)
print("amts", amts)
@ -94,11 +88,11 @@ class ZkeyImportExportTest (BitcoinTestFramework):
# verify_utxos(charlie, [])
# the amounts of each txn embodied which generates a single UTXO:
amounts = map(Decimal, ['2.3', '3.7', '0.1', '0.5', '1.0', '0.19'])
amounts = list(map(Decimal, ['2.3', '3.7', '0.1', '0.5', '1.0', '0.19']))
# Internal test consistency assertion:
assert_greater_than(
get_private_balance(alice),
Decimal(get_private_balance(alice)),
reduce(Decimal.__add__, amounts))
logging.info("Sending pre-export txns...")
@ -141,7 +135,7 @@ class ZkeyImportExportTest (BitcoinTestFramework):
verify_utxos(charlie, amounts, ipk_zaddr2["address"])
# keep track of the fees incurred by bob (his sends)
bob_fee = Decimal(0)
bob_fee = Decimal("0")
# Try to reproduce zombie balance reported in #1936
# At generated zaddr, receive ZEC, and send ZEC back out. bob -> alice