update to py3 conventions, BUG with last assert_equal

This commit is contained in:
mdr0id 2019-12-04 08:04:42 -08:00
parent 4c887d528b
commit 7648ebf57e
1 changed files with 6 additions and 7 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright (c) 2019 The Zcash developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -13,7 +13,6 @@
# getaddressutxos
# getaddressmempool
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
from test_framework.test_framework import BitcoinTestFramework
@ -40,7 +39,7 @@ from test_framework.mininode import (
CTxIn, CTxOut, COutPoint,
)
from binascii import hexlify
from binascii import unhexlify, hexlify
class AddressIndexTest(BitcoinTestFramework):
@ -252,7 +251,7 @@ class AddressIndexTest(BitcoinTestFramework):
# Ensure the change from that transaction appears
tx = self.nodes[0].getrawtransaction(txid, 1)
change_vout = filter(lambda v: v['valueZat'] != 3 * COIN, tx['vout'])
change_vout = list(filter(lambda v: v['valueZat'] != 3 * COIN, tx['vout']))
change = change_vout[0]['scriptPubKey']['addresses'][0]
bal = self.nodes[2].getaddressbalance(change)
assert(bal['received'] > 0)
@ -323,7 +322,7 @@ class AddressIndexTest(BitcoinTestFramework):
# so for comparison, remove the 4 (and -4 for output) from the
# deltas list
deltas = self.nodes[1].getaddressdeltas({'addresses': [addr1]})
deltas = filter(lambda d: abs(d['satoshis']) != 4 * COIN, deltas)
deltas = list(filter(lambda d: abs(d['satoshis']) != 4 * COIN, deltas))
assert_equal(len(utxos), len(deltas))
for i in range(len(utxos)):
assert_equal(utxos[i]['address'], addr1)
@ -334,13 +333,13 @@ class AddressIndexTest(BitcoinTestFramework):
# Check that outputs with the same address in the same tx return one txid
# (can't use createrawtransaction() as it combines duplicate addresses)
addr = "t2LMJ6Arw9UWBMWvfUr2QLHM4Xd9w53FftS"
addressHash = "97643ce74b188f4fb6bbbb285e067a969041caf2".decode('hex')
addressHash =unhexlify("97643ce74b188f4fb6bbbb285e067a969041caf2")
scriptPubKey = CScript([OP_HASH160, addressHash, OP_EQUAL])
# Add an unrecognized script type to vout[], a legal script that pays,
# but won't modify the addressindex (since the address can't be extracted).
# (This extra output has no effect on the rest of the test.)
scriptUnknown = CScript([OP_HASH160, OP_DUP, OP_DROP, addressHash, OP_EQUAL])
unspent = filter(lambda u: u['amount'] >= 4, self.nodes[0].listunspent())
unspent = list(filter(lambda u: u['amount'] >= 4, self.nodes[0].listunspent()))
tx = CTransaction()
tx.vin = [CTxIn(COutPoint(int(unspent[0]['txid'], 16), unspent[0]['vout']))]
tx.vout = [