Update cmp to py3 functions, update map return to list for py3

This commit is contained in:
mdr0id 2019-12-04 07:10:11 -08:00
parent d093e45db4
commit e241df647f
1 changed files with 5 additions and 9 deletions

View File

@ -1,11 +1,10 @@
#!/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 functools import reduce
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
@ -40,11 +39,8 @@ class KeyImportExportTest (BitcoinTestFramework):
def verify_utxos(node, amounts):
utxos = node.listunspent(1, 10**9, [addr])
def cmp_confirmations_high_to_low(a, b):
return cmp(b["confirmations"], a["confirmations"])
utxos.sort(cmp_confirmations_high_to_low)
utxos.sort(key=lambda x: x["confirmations"])
utxos.reverse()
try:
assert_equal(amounts, [utxo["amount"] for utxo in utxos])
@ -66,7 +62,7 @@ class KeyImportExportTest (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(