Standard py2 to py3 updates

This commit is contained in:
mdr0id 2019-12-04 07:29:16 -08:00
parent e241df647f
commit 65a02f0984
50 changed files with 220 additions and 321 deletions

View File

@ -1,12 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
# Exercise the listtransactions API # Exercise the listtransactions API
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 from test_framework.test_framework import BitcoinTestFramework
from decimal import Decimal from decimal import Decimal

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2019 The Zcash developers # Copyright (c) 2019 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
assert_equal, assert_equal,

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
assert_equal, assert_true, initialize_chain_clean, assert_equal, assert_true, initialize_chain_clean,
@ -31,7 +29,7 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
self.sync_all self.sync_all
def setup_chain(self): def setup_chain(self):
print "Initializing test directory "+self.options.tmpdir print("Initializing test directory "+self.options.tmpdir)
initialize_chain_clean(self.options.tmpdir, 2) initialize_chain_clean(self.options.tmpdir, 2)
def run_test(self): def run_test(self):
@ -48,7 +46,7 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
node0_zaddr = self.nodes[0].z_getnewaddress('sapling') node0_zaddr = self.nodes[0].z_getnewaddress('sapling')
recipients = [{'address': node0_zaddr, 'amount': Decimal('10')}] recipients = [{'address': node0_zaddr, 'amount': Decimal('10')}]
myopid = self.nodes[1].z_sendmany(node1_taddr, recipients, 1, Decimal('0')) myopid = self.nodes[1].z_sendmany(node1_taddr, recipients, 1, Decimal('0'))
print wait_and_assert_operationid_status(self.nodes[1], myopid) print(wait_and_assert_operationid_status(self.nodes[1], myopid))
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.nodes[0].generate(1)
self.sync_all() self.sync_all()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -8,8 +8,6 @@
# that spend (directly or indirectly) coinbase transactions. # that spend (directly or indirectly) coinbase transactions.
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, assert_raises, start_node, connect_nodes from test_framework.util import assert_equal, assert_raises, start_node, connect_nodes

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -8,8 +8,6 @@
# the blockchain is re-organized. # the blockchain is re-organized.
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, start_node from test_framework.util import assert_equal, start_node

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -13,8 +13,6 @@
# but less mature coinbase spends are NOT. # but less mature coinbase spends are NOT.
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, assert_greater_than, assert_raises, \ from test_framework.util import assert_equal, assert_greater_than, assert_raises, \

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -7,8 +7,6 @@
# Test proper expiry for transactions >= version 4 # Test proper expiry for transactions >= version 4
# #
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.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, \ from test_framework.util import assert_equal, \
@ -37,7 +35,7 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
bob = self.nodes[2].getnewaddress() bob = self.nodes[2].getnewaddress()
z_bob = self.nodes[2].z_getnewaddress('sapling') z_bob = self.nodes[2].z_getnewaddress('sapling')
print "Splitting network..." print("Splitting network...")
self.split_network() self.split_network()
# Test dependent txs # Test dependent txs
@ -46,7 +44,7 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
assert_equal(firstTxInfo["version"], 4) assert_equal(firstTxInfo["version"], 4)
assert_equal(firstTxInfo["overwintered"], True) assert_equal(firstTxInfo["overwintered"], True)
assert("expiryheight" in firstTxInfo) assert("expiryheight" in firstTxInfo)
print "First tx expiry height:", firstTxInfo['expiryheight'] print("First tx expiry height:", firstTxInfo['expiryheight'])
# Mine first transaction # Mine first transaction
self.nodes[0].generate(1) self.nodes[0].generate(1)
for outpoint in firstTxInfo['vout']: for outpoint in firstTxInfo['vout']:
@ -60,19 +58,19 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
assert(rawTxSigned['complete']) assert(rawTxSigned['complete'])
secondTx = self.nodes[0].sendrawtransaction(rawTxSigned['hex']) secondTx = self.nodes[0].sendrawtransaction(rawTxSigned['hex'])
secondTxInfo = self.nodes[0].getrawtransaction(secondTx, 1) secondTxInfo = self.nodes[0].getrawtransaction(secondTx, 1)
print "Second tx expiry height:", secondTxInfo['expiryheight'] print("Second tx expiry height:", secondTxInfo['expiryheight'])
# Mine second, dependent transaction # Mine second, dependent transaction
self.nodes[0].generate(1) self.nodes[0].generate(1)
print "Mine %d competing blocks on Node 2..." % (2 + TX_EXPIRY_DELTA) print("Mine %d competing blocks on Node 2..." % (2 + TX_EXPIRY_DELTA))
blocks = self.nodes[2].generate(2 + TX_EXPIRY_DELTA) blocks = self.nodes[2].generate(2 + TX_EXPIRY_DELTA)
print "Connect nodes to force a reorg" print("Connect nodes to force a reorg")
connect_nodes_bi(self.nodes,0,2) connect_nodes_bi(self.nodes,0,2)
self.is_network_split = False self.is_network_split = False
print "Syncing blocks" print("Syncing blocks")
sync_blocks(self.nodes) sync_blocks(self.nodes)
print "Ensure that both txs are dropped from mempool of node 0" print("Ensure that both txs are dropped from mempool of node 0")
print "Blockheight node 0:", self.nodes[0].getblockchaininfo()['blocks'] print("Blockheight node 0:", self.nodes[0].getblockchaininfo()['blocks'])
print "Blockheight node 2:", self.nodes[2].getblockchaininfo()['blocks'] print("Blockheight node 2:", self.nodes[2].getblockchaininfo()['blocks'])
assert_equal(set(self.nodes[0].getrawmempool()), set()) assert_equal(set(self.nodes[0].getrawmempool()), set())
assert_equal(set(self.nodes[2].getrawmempool()), set()) assert_equal(set(self.nodes[2].getrawmempool()), set())
@ -84,10 +82,10 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
# Get balance on node 0 # Get balance on node 0
bal = self.nodes[0].z_gettotalbalance() bal = self.nodes[0].z_gettotalbalance()
print "Balance before zsend, after shielding 10: ", bal print("Balance before zsend, after shielding 10: ", bal)
assert_equal(Decimal(bal["private"]), Decimal("9.9999")) assert_equal(Decimal(bal["private"]), Decimal("9.9999"))
print "Splitting network..." print("Splitting network...")
self.split_network() self.split_network()
# Create transactions # Create transactions
@ -103,148 +101,148 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
assert_equal(rawtx["version"], 4) assert_equal(rawtx["version"], 4)
assert_equal(rawtx["overwintered"], True) assert_equal(rawtx["overwintered"], True)
assert_equal(rawtx["expiryheight"], blockheight + 1 + TX_EXPIRY_DELTA) assert_equal(rawtx["expiryheight"], blockheight + 1 + TX_EXPIRY_DELTA)
print "Blockheight at persist_transparent & persist_shielded creation:", self.nodes[0].getblockchaininfo()['blocks'] print("Blockheight at persist_transparent & persist_shielded creation:", self.nodes[0].getblockchaininfo()['blocks'])
print "Expiryheight of persist_transparent:", rawtx['expiryheight'] print("Expiryheight of persist_transparent:", rawtx['expiryheight'])
# Verify shielded transaction is version 4 intended for Sapling branch # Verify shielded transaction is version 4 intended for Sapling branch
rawtx = self.nodes[0].getrawtransaction(persist_shielded, 1) rawtx = self.nodes[0].getrawtransaction(persist_shielded, 1)
print "Expiryheight of persist_shielded", rawtx['expiryheight'] print("Expiryheight of persist_shielded", rawtx['expiryheight'])
assert_equal(rawtx["version"], 4) assert_equal(rawtx["version"], 4)
assert_equal(rawtx["overwintered"], True) assert_equal(rawtx["overwintered"], True)
assert_equal(rawtx["expiryheight"], blockheight + 1 + TX_EXPIRY_DELTA) assert_equal(rawtx["expiryheight"], blockheight + 1 + TX_EXPIRY_DELTA)
print "\n Blockheight advances to less than expiry block height. After reorg, txs should persist in mempool" print("\n Blockheight advances to less than expiry block height. After reorg, txs should persist in mempool")
assert(persist_transparent in self.nodes[0].getrawmempool()) assert(persist_transparent in self.nodes[0].getrawmempool())
assert(persist_shielded in self.nodes[0].getrawmempool()) assert(persist_shielded in self.nodes[0].getrawmempool())
assert_equal(set(self.nodes[2].getrawmempool()), set()) assert_equal(set(self.nodes[2].getrawmempool()), set())
print "mempool node 0:", self.nodes[0].getrawmempool() print("mempool node 0:", self.nodes[0].getrawmempool())
print "mempool node 2:", self.nodes[2].getrawmempool() print("mempool node 2:", self.nodes[2].getrawmempool())
bal = self.nodes[0].z_gettotalbalance() bal = self.nodes[0].z_gettotalbalance()
print "Printing balance before persist_shielded & persist_transparent are initially mined from mempool", bal print("Printing balance before persist_shielded & persist_transparent are initially mined from mempool", bal)
# Txs are mined on node 0; will later be rolled back # Txs are mined on node 0; will later be rolled back
self.nodes[0].generate(1) self.nodes[0].generate(1)
print "Node 0 generated 1 block" print("Node 0 generated 1 block")
print "Node 0 height:", self.nodes[0].getblockchaininfo()['blocks'] print("Node 0 height:", self.nodes[0].getblockchaininfo()['blocks'])
print "Node 2 height:", self.nodes[2].getblockchaininfo()['blocks'] print("Node 2 height:", self.nodes[2].getblockchaininfo()['blocks'])
bal = self.nodes[0].z_gettotalbalance() bal = self.nodes[0].z_gettotalbalance()
print "Printing balance after persist_shielded & persist_transparent are mined:", bal print("Printing balance after persist_shielded & persist_transparent are mined:", bal)
assert_equal(set(self.nodes[0].getrawmempool()), set()) assert_equal(set(self.nodes[0].getrawmempool()), set())
print "Mine 2 competing blocks on Node 2..." print("Mine 2 competing blocks on Node 2...")
blocks = self.nodes[2].generate(2) blocks = self.nodes[2].generate(2)
for block in blocks: for block in blocks:
blk = self.nodes[2].getblock(block) blk = self.nodes[2].getblock(block)
print "Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]) print("Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]))
print "Connect nodes to force a reorg" print("Connect nodes to force a reorg")
connect_nodes_bi(self.nodes,0,2) connect_nodes_bi(self.nodes,0,2)
self.is_network_split = False self.is_network_split = False
print "Syncing blocks" print("Syncing blocks")
sync_blocks(self.nodes) sync_blocks(self.nodes)
print "Ensure that txs are back in mempool of node 0" print("Ensure that txs are back in mempool of node 0")
print "Blockheight node 0:", self.nodes[0].getblockchaininfo()['blocks'] print("Blockheight node 0:", self.nodes[0].getblockchaininfo()['blocks'])
print "Blockheight node 2:", self.nodes[2].getblockchaininfo()['blocks'] print("Blockheight node 2:", self.nodes[2].getblockchaininfo()['blocks'])
print "mempool node 0: ", self.nodes[0].getrawmempool() print("mempool node 0: ", self.nodes[0].getrawmempool())
print "mempool node 2: ", self.nodes[2].getrawmempool() print("mempool node 2: ", self.nodes[2].getrawmempool())
assert(persist_transparent in self.nodes[0].getrawmempool()) assert(persist_transparent in self.nodes[0].getrawmempool())
assert(persist_shielded in self.nodes[0].getrawmempool()) assert(persist_shielded in self.nodes[0].getrawmempool())
bal = self.nodes[0].z_gettotalbalance() bal = self.nodes[0].z_gettotalbalance()
# Mine txs to get them out of the way of mempool sync in split_network() # Mine txs to get them out of the way of mempool sync in split_network()
print "Generating another block on node 0 to clear txs from mempool" print("Generating another block on node 0 to clear txs from mempool")
self.nodes[0].generate(1) self.nodes[0].generate(1)
assert_equal(set(self.nodes[0].getrawmempool()), set()) assert_equal(set(self.nodes[0].getrawmempool()), set())
sync_blocks(self.nodes) sync_blocks(self.nodes)
print "Splitting network..." print("Splitting network...")
self.split_network() self.split_network()
print "\n Blockheight advances to equal expiry block height. After reorg, txs should persist in mempool" print("\n Blockheight advances to equal expiry block height. After reorg, txs should persist in mempool")
myopid = self.nodes[0].z_sendmany(z_alice, recipients) myopid = self.nodes[0].z_sendmany(z_alice, recipients)
persist_shielded_2 = wait_and_assert_operationid_status(self.nodes[0], myopid) persist_shielded_2 = wait_and_assert_operationid_status(self.nodes[0], myopid)
persist_transparent_2 = self.nodes[0].sendtoaddress(bob, 0.01) persist_transparent_2 = self.nodes[0].sendtoaddress(bob, 0.01)
rawtx_trans = self.nodes[0].getrawtransaction(persist_transparent_2, 1) rawtx_trans = self.nodes[0].getrawtransaction(persist_transparent_2, 1)
rawtx_shield = self.nodes[0].getrawtransaction(persist_shielded_2, 1) rawtx_shield = self.nodes[0].getrawtransaction(persist_shielded_2, 1)
print "Blockheight node 0 at persist_transparent_2 creation:", self.nodes[0].getblockchaininfo()['blocks'] print("Blockheight node 0 at persist_transparent_2 creation:", self.nodes[0].getblockchaininfo()['blocks'])
print "Blockheight node 2 at persist_transparent_2 creation:", self.nodes[2].getblockchaininfo()['blocks'] print("Blockheight node 2 at persist_transparent_2 creation:", self.nodes[2].getblockchaininfo()['blocks'])
print "Expiryheight of persist_transparent_2:", rawtx_trans['expiryheight'] print("Expiryheight of persist_transparent_2:", rawtx_trans['expiryheight'])
print "Expiryheight of persist_shielded_2:", rawtx_shield['expiryheight'] print("Expiryheight of persist_shielded_2:", rawtx_shield['expiryheight'])
blocks = self.nodes[2].generate(4) blocks = self.nodes[2].generate(4)
for block in blocks: for block in blocks:
blk = self.nodes[2].getblock(block) blk = self.nodes[2].getblock(block)
print "Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]) print("Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]))
print "Connect nodes to force a reorg" print("Connect nodes to force a reorg")
connect_nodes_bi(self.nodes, 0, 2) connect_nodes_bi(self.nodes, 0, 2)
self.is_network_split = False self.is_network_split = False
sync_blocks(self.nodes) sync_blocks(self.nodes)
print "Ensure that persist_transparent_2 & persist_shielded_2 are in mempool at expiry block height" print("Ensure that persist_transparent_2 & persist_shielded_2 are in mempool at expiry block height")
print "Blockheight node 0:", self.nodes[0].getblockchaininfo()['blocks'] print("Blockheight node 0:", self.nodes[0].getblockchaininfo()['blocks'])
print "Blockheight node 2:", self.nodes[2].getblockchaininfo()['blocks'] print("Blockheight node 2:", self.nodes[2].getblockchaininfo()['blocks'])
print "mempool node 0: ", self.nodes[0].getrawmempool() print("mempool node 0: ", self.nodes[0].getrawmempool())
print "mempool node 2: ", self.nodes[2].getrawmempool() print("mempool node 2: ", self.nodes[2].getrawmempool())
assert(persist_transparent_2 in self.nodes[0].getrawmempool()) assert(persist_transparent_2 in self.nodes[0].getrawmempool())
assert(persist_shielded_2 in self.nodes[0].getrawmempool()) assert(persist_shielded_2 in self.nodes[0].getrawmempool())
# Mine persist txs to get them out of the way of mempool sync in split_network() # Mine persist txs to get them out of the way of mempool sync in split_network()
self.nodes[0].generate(1) self.nodes[0].generate(1)
assert_equal(set(self.nodes[0].getrawmempool()), set()) assert_equal(set(self.nodes[0].getrawmempool()), set())
sync_blocks(self.nodes) sync_blocks(self.nodes)
print "Balance after persist_shielded_2 is mined to remove from mempool: ", self.nodes[0].z_gettotalbalance() print("Balance after persist_shielded_2 is mined to remove from mempool: ", self.nodes[0].z_gettotalbalance())
print "Splitting network..." print("Splitting network...")
self.split_network() self.split_network()
print "\n Blockheight advances to greater than expiry block height. After reorg, txs should expire from mempool" print("\n Blockheight advances to greater than expiry block height. After reorg, txs should expire from mempool")
print "Balance before expire_shielded is sent: ", self.nodes[0].z_gettotalbalance() print("Balance before expire_shielded is sent: ", self.nodes[0].z_gettotalbalance())
myopid = self.nodes[0].z_sendmany(z_alice, recipients) myopid = self.nodes[0].z_sendmany(z_alice, recipients)
expire_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid) expire_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid)
expire_transparent = self.nodes[0].sendtoaddress(bob, 0.01) expire_transparent = self.nodes[0].sendtoaddress(bob, 0.01)
print "Blockheight node 0 at expire_transparent creation:", self.nodes[0].getblockchaininfo()['blocks'] print("Blockheight node 0 at expire_transparent creation:", self.nodes[0].getblockchaininfo()['blocks'])
print "Blockheight node 2 at expire_shielded creation:", self.nodes[2].getblockchaininfo()['blocks'] print("Blockheight node 2 at expire_shielded creation:", self.nodes[2].getblockchaininfo()['blocks'])
print "Expiryheight of expire_transparent:", self.nodes[0].getrawtransaction(expire_transparent, 1)['expiryheight'] print("Expiryheight of expire_transparent:", self.nodes[0].getrawtransaction(expire_transparent, 1)['expiryheight'])
print "Expiryheight of expire_shielded:", self.nodes[0].getrawtransaction(expire_shielded, 1)['expiryheight'] print("Expiryheight of expire_shielded:", self.nodes[0].getrawtransaction(expire_shielded, 1)['expiryheight'])
assert(expire_transparent in self.nodes[0].getrawmempool()) assert(expire_transparent in self.nodes[0].getrawmempool())
assert(expire_shielded in self.nodes[0].getrawmempool()) assert(expire_shielded in self.nodes[0].getrawmempool())
blocks = self.nodes[2].generate(1 + TX_EXPIRY_DELTA + 1) blocks = self.nodes[2].generate(1 + TX_EXPIRY_DELTA + 1)
for block in blocks: for block in blocks:
blk = self.nodes[2].getblock(block) blk = self.nodes[2].getblock(block)
print "Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]) print("Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]))
print "Connect nodes to force a reorg" print("Connect nodes to force a reorg")
connect_nodes_bi(self.nodes, 0, 2) connect_nodes_bi(self.nodes, 0, 2)
self.is_network_split = False self.is_network_split = False
sync_blocks(self.nodes) sync_blocks(self.nodes)
print "Ensure that expire_transparent & expire_shielded are not in mempool after expiry block height" print("Ensure that expire_transparent & expire_shielded are not in mempool after expiry block height")
print "mempool node 0: ", self.nodes[0].getrawmempool() print("mempool node 0: ", self.nodes[0].getrawmempool())
print "mempool node 2: ", self.nodes[2].getrawmempool() print("mempool node 2: ", self.nodes[2].getrawmempool())
assert_equal(set(self.nodes[0].getrawmempool()), set()) assert_equal(set(self.nodes[0].getrawmempool()), set())
print "Ensure balance of node 0 is correct" print("Ensure balance of node 0 is correct")
bal = self.nodes[0].z_gettotalbalance() bal = self.nodes[0].z_gettotalbalance()
print "Balance after expire_shielded has expired: ", bal print("Balance after expire_shielded has expired: ", bal)
assert_equal(Decimal(bal["private"]), Decimal("7.9999")) assert_equal(Decimal(bal["private"]), Decimal("7.9999"))
print "Splitting network..." print("Splitting network...")
self.split_network() self.split_network()
print "\n Blockheight advances to just before expiring soon threshold. Txs should be rejected from entering mempool." print("\n Blockheight advances to just before expiring soon threshold. Txs should be rejected from entering mempool.")
print "Balance before expire_shielded is sent: ", self.nodes[0].z_gettotalbalance() print("Balance before expire_shielded is sent: ", self.nodes[0].z_gettotalbalance())
myopid = self.nodes[0].z_sendmany(z_alice, recipients) myopid = self.nodes[0].z_sendmany(z_alice, recipients)
expire_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid) expire_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid)
expire_transparent = self.nodes[0].sendtoaddress(bob, 0.01) expire_transparent = self.nodes[0].sendtoaddress(bob, 0.01)
print "Blockheight node 0 at expire_transparent creation:", self.nodes[0].getblockchaininfo()['blocks'] print("Blockheight node 0 at expire_transparent creation:", self.nodes[0].getblockchaininfo()['blocks'])
print "Blockheight node 2 at expire_shielded creation:", self.nodes[2].getblockchaininfo()['blocks'] print("Blockheight node 2 at expire_shielded creation:", self.nodes[2].getblockchaininfo()['blocks'])
print "Expiryheight of expire_transparent:", self.nodes[0].getrawtransaction(expire_transparent, 1)['expiryheight'] print("Expiryheight of expire_transparent:", self.nodes[0].getrawtransaction(expire_transparent, 1)['expiryheight'])
print "Expiryheight of expire_shielded:", self.nodes[0].getrawtransaction(expire_shielded, 1)['expiryheight'] print("Expiryheight of expire_shielded:", self.nodes[0].getrawtransaction(expire_shielded, 1)['expiryheight'])
assert(expire_transparent in self.nodes[0].getrawmempool()) assert(expire_transparent in self.nodes[0].getrawmempool())
assert(expire_shielded in self.nodes[0].getrawmempool()) assert(expire_shielded in self.nodes[0].getrawmempool())
blocks = self.nodes[2].generate(1 + TX_EXPIRY_DELTA - TX_EXPIRING_SOON_THRESHOLD - 1) blocks = self.nodes[2].generate(1 + TX_EXPIRY_DELTA - TX_EXPIRING_SOON_THRESHOLD - 1)
for block in blocks: for block in blocks:
blk = self.nodes[2].getblock(block) blk = self.nodes[2].getblock(block)
print "Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]) print("Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]))
print "Connect nodes to force a reorg" print("Connect nodes to force a reorg")
connect_nodes_bi(self.nodes, 0, 2) connect_nodes_bi(self.nodes, 0, 2)
self.is_network_split = False self.is_network_split = False
sync_blocks(self.nodes) sync_blocks(self.nodes)
print "Ensure that expire_transparent & expire_shielded are in node 0 mempool but not node 2 mempool" print("Ensure that expire_transparent & expire_shielded are in node 0 mempool but not node 2 mempool")
print "mempool node 0: ", self.nodes[0].getrawmempool() print("mempool node 0: ", self.nodes[0].getrawmempool())
print "mempool node 2: ", self.nodes[2].getrawmempool() print("mempool node 2: ", self.nodes[2].getrawmempool())
assert(expire_transparent in self.nodes[0].getrawmempool()) assert(expire_transparent in self.nodes[0].getrawmempool())
assert(expire_shielded in self.nodes[0].getrawmempool()) assert(expire_shielded in self.nodes[0].getrawmempool())
assert(expire_transparent not in self.nodes[2].getrawmempool()) assert(expire_transparent not in self.nodes[2].getrawmempool())

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -56,7 +57,7 @@ class MergeToAddressHelper:
test.sync_all() test.sync_all()
def run_test(self, test): def run_test(self, test):
print "Mining blocks..." print("Mining blocks...")
test.nodes[0].generate(1) test.nodes[0].generate(1)
do_not_shield_taddr = test.nodes[0].getnewaddress() do_not_shield_taddr = test.nodes[0].getnewaddress()

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2019 The Zcash developers # Copyright (c) 2019 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, get_coinbase_address, \ from test_framework.util import assert_equal, get_coinbase_address, \
@ -21,7 +19,7 @@ class MergeToAddressMixedNotes(BitcoinTestFramework):
initialize_chain_clean(self.options.tmpdir, 4) initialize_chain_clean(self.options.tmpdir, 4)
def run_test(self): def run_test(self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].generate(102) self.nodes[0].generate(102)
self.sync_all() self.sync_all()

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from mergetoaddress_helper import MergeToAddressHelper from mergetoaddress_helper import MergeToAddressHelper

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from mergetoaddress_helper import MergeToAddressHelper from mergetoaddress_helper import MergeToAddressHelper

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -7,8 +7,6 @@
# Test merkleblock fetch/validation # Test merkleblock fetch/validation
# #
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
import string import string
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
@ -38,7 +36,7 @@ class MerkleBlockTest(BitcoinTestFramework):
self.sync_all() self.sync_all()
def run_test(self): def run_test(self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].generate(105) self.nodes[0].generate(105)
self.sync_all() self.sync_all()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -7,17 +7,11 @@
# Test node handling # Test node handling
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, connect_nodes_bi, p2p_port from test_framework.util import assert_equal, connect_nodes_bi, p2p_port
import time import time
import urllib
try:
import urllib.parse as urlparse
except ImportError:
import urlparse
class NodeHandlingTest (BitcoinTestFramework): class NodeHandlingTest (BitcoinTestFramework):
def run_test(self): def run_test(self):
@ -51,7 +45,7 @@ class NodeHandlingTest (BitcoinTestFramework):
########################### ###########################
# RPC disconnectnode test # # RPC disconnectnode test #
########################### ###########################
url = urlparse.urlparse(self.nodes[1].url) url = urllib.parse.urlparse(self.nodes[1].url)
self.nodes[0].disconnectnode(url.hostname+":"+str(p2p_port(1))) self.nodes[0].disconnectnode(url.hostname+":"+str(p2p_port(1)))
time.sleep(2) #disconnecting a node needs a little bit of time time.sleep(2) #disconnecting a node needs a little bit of time
for node in self.nodes[0].getpeerinfo(): for node in self.nodes[0].getpeerinfo():

View File

@ -4,17 +4,15 @@
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
# #
from test_framework.mininode import * from test_framework.mininode import CBlockHeader, CInv, NodeConn, NodeConnCB, \
#CBlockHeader, CInv, NodeConn, NodeConnCB, \ NetworkThread, msg_block, msg_headers, msg_inv, msg_ping, msg_pong, \
# NetworkThread, msg_block, msg_headers, msg_inv, msg_ping, msg_pong, \ mininode_lock
# mininode_lock
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, initialize_chain_clean, \
#assert_equal, initialize_chain_clean, \ start_node, p2p_port
# start_node, p2p_port
from test_framework.blocktools import create_block, create_coinbase from test_framework.blocktools import create_block, create_coinbase
#import os import os
import time import time
''' '''
@ -159,7 +157,7 @@ class AcceptBlockTest(BitcoinTestFramework):
# This should be accepted. # This should be accepted.
blocks_h2 = [] # the height 2 blocks on each node's chain blocks_h2 = [] # the height 2 blocks on each node's chain
block_time = time.time() + 1 block_time = time.time() + 1
for i in range(2): for i in xrange(2):
blocks_h2.append(create_block(tips[i], create_coinbase(), block_time)) blocks_h2.append(create_block(tips[i], create_coinbase(), block_time))
blocks_h2[i].solve() blocks_h2[i].solve()
block_time += 1 block_time += 1
@ -169,11 +167,11 @@ class AcceptBlockTest(BitcoinTestFramework):
[ x.sync_with_ping() for x in [test_node, white_node] ] [ x.sync_with_ping() for x in [test_node, white_node] ]
assert_equal(self.nodes[0].getblockcount(), 2) assert_equal(self.nodes[0].getblockcount(), 2)
assert_equal(self.nodes[1].getblockcount(), 2) assert_equal(self.nodes[1].getblockcount(), 2)
print("First height 2 block accepted by both nodes") print "First height 2 block accepted by both nodes"
# 3. Send another block that builds on the original tip. # 3. Send another block that builds on the original tip.
blocks_h2f = [] # Blocks at height 2 that fork off the main chain blocks_h2f = [] # Blocks at height 2 that fork off the main chain
for i in range(2): for i in xrange(2):
blocks_h2f.append(create_block(tips[i], create_coinbase(), blocks_h2[i].nTime+1)) blocks_h2f.append(create_block(tips[i], create_coinbase(), blocks_h2[i].nTime+1))
blocks_h2f[i].solve() blocks_h2f[i].solve()
test_node.send_message(msg_block(blocks_h2f[0])) test_node.send_message(msg_block(blocks_h2f[0]))
@ -188,11 +186,11 @@ class AcceptBlockTest(BitcoinTestFramework):
if x['hash'] == blocks_h2f[1].hash: if x['hash'] == blocks_h2f[1].hash:
assert_equal(x['status'], "valid-headers") assert_equal(x['status'], "valid-headers")
print("Second height 2 block accepted only from whitelisted peer") print "Second height 2 block accepted only from whitelisted peer"
# 4. Now send another block that builds on the forking chain. # 4. Now send another block that builds on the forking chain.
blocks_h3 = [] blocks_h3 = []
for i in range(2): for i in xrange(2):
blocks_h3.append(create_block(blocks_h2f[i].sha256, create_coinbase(), blocks_h2f[i].nTime+1)) blocks_h3.append(create_block(blocks_h2f[i].sha256, create_coinbase(), blocks_h2f[i].nTime+1))
blocks_h3[i].solve() blocks_h3[i].solve()
test_node.send_message(msg_block(blocks_h3[0])) test_node.send_message(msg_block(blocks_h3[0]))
@ -208,13 +206,13 @@ class AcceptBlockTest(BitcoinTestFramework):
# But this block should be accepted by node0 since it has more work. # But this block should be accepted by node0 since it has more work.
try: try:
self.nodes[0].getblock(blocks_h3[0].hash) self.nodes[0].getblock(blocks_h3[0].hash)
print("Unrequested more-work block accepted from non-whitelisted peer") print "Unrequested more-work block accepted from non-whitelisted peer"
except: except:
raise AssertionError("Unrequested more work block was not processed") raise AssertionError("Unrequested more work block was not processed")
# Node1 should have accepted and reorged. # Node1 should have accepted and reorged.
assert_equal(self.nodes[1].getblockcount(), 3) assert_equal(self.nodes[1].getblockcount(), 3)
print("Successfully reorged to length 3 chain from whitelisted peer") print "Successfully reorged to length 3 chain from whitelisted peer"
# 4b. Now mine 288 more blocks and deliver; all should be processed but # 4b. Now mine 288 more blocks and deliver; all should be processed but
# the last (height-too-high) on node0. Node1 should process the tip if # the last (height-too-high) on node0. Node1 should process the tip if
@ -222,8 +220,8 @@ class AcceptBlockTest(BitcoinTestFramework):
tips = blocks_h3 tips = blocks_h3
headers_message = msg_headers() headers_message = msg_headers()
all_blocks = [] # node0's blocks all_blocks = [] # node0's blocks
for j in range(2): for j in xrange(2):
for i in range(288): for i in xrange(288):
next_block = create_block(tips[j].sha256, create_coinbase(), tips[j].nTime+1) next_block = create_block(tips[j].sha256, create_coinbase(), tips[j].nTime+1)
next_block.solve() next_block.solve()
if j==0: if j==0:

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \ from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \
msg_filteradd, msg_filterclear, mininode_lock, SAPLING_PROTO_VERSION msg_filteradd, msg_filterclear, mininode_lock, SAPLING_PROTO_VERSION
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
@ -48,7 +46,7 @@ class TestNode(NodeConnCB):
class NodeBloomTest(BitcoinTestFramework): class NodeBloomTest(BitcoinTestFramework):
def setup_chain(self): def setup_chain(self):
print "Initializing test directory "+self.options.tmpdir print("Initializing test directory "+self.options.tmpdir)
initialize_chain_clean(self.options.tmpdir, 2) initialize_chain_clean(self.options.tmpdir, 2)
def setup_network(self): def setup_network(self):

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.mininode import ( from test_framework.mininode import (
NodeConn, NodeConn,
NodeConnCB, NodeConnCB,
@ -54,7 +52,7 @@ class TestManager(NodeConnCB):
class NUPeerManagementTest(BitcoinTestFramework): class NUPeerManagementTest(BitcoinTestFramework):
def setup_chain(self): def setup_chain(self):
print "Initializing test directory "+self.options.tmpdir print("Initializing test directory "+self.options.tmpdir)
initialize_chain_clean(self.options.tmpdir, 1) initialize_chain_clean(self.options.tmpdir, 1)
def setup_network(self): def setup_network(self):
@ -70,7 +68,7 @@ class NUPeerManagementTest(BitcoinTestFramework):
# Launch Sprout, Overwinter, and Sapling mininodes # Launch Sprout, Overwinter, and Sapling mininodes
nodes = [] nodes = []
for x in xrange(10): for x in range(10):
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
test, "regtest", SPROUT_PROTO_VERSION)) test, "regtest", SPROUT_PROTO_VERSION))
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
@ -34,7 +32,7 @@ class PaymentDisclosureTest (BitcoinTestFramework):
self.sync_all() self.sync_all()
def run_test (self): def run_test (self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].generate(4) self.nodes[0].generate(4)
self.sync_all() self.sync_all()

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
start_node, connect_nodes start_node, connect_nodes
@ -31,7 +29,7 @@ class PrioritiseTransactionTest (BitcoinTestFramework):
def run_test (self): def run_test (self):
# tx priority is calculated: priority = sum(input_value_in_base_units * input_age)/size_in_bytes # tx priority is calculated: priority = sum(input_value_in_base_units * input_age)/size_in_bytes
print "Mining 11kb blocks..." print("Mining 11kb blocks...")
self.nodes[0].generate(501) self.nodes[0].generate(501)
base_fee = self.nodes[0].getnetworkinfo()['relayfee'] base_fee = self.nodes[0].getnetworkinfo()['relayfee']

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -13,8 +13,6 @@
# pip install python-qpid-proton # pip install python-qpid-proton
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, bytes_to_hex_str, \ from test_framework.util import assert_equal, bytes_to_hex_str, \
start_nodes start_nodes
@ -37,7 +35,7 @@ class Server(MessagingHandler):
self.txidseq = -1 self.txidseq = -1
def on_start(self, event): def on_start(self, event):
print "Proton listening on:", self.url print("Proton listening on:", self.url)
self.container = event.container self.container = event.container
self.acceptor = event.container.listen(self.url) self.acceptor = event.container.listen(self.url)
@ -106,7 +104,7 @@ class ProtonTest (BitcoinTestFramework):
assert_equal(len(self.server.txids), self.numblocks) assert_equal(len(self.server.txids), self.numblocks)
# verify that each block has the correct coinbase txid # verify that each block has the correct coinbase txid
for i in xrange(0, self.numblocks): for i in range(0, self.numblocks):
height = baseheight + i + 1 height = baseheight + i + 1
blockhash = self.nodes[0].getblockhash(height) blockhash = self.nodes[0].getblockhash(height)
assert_equal(blockhash, self.server.blockhashes[i]) assert_equal(blockhash, self.server.blockhashes[i])

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -8,8 +8,6 @@
# that spend (directly or indirectly) coinbase transactions. # that spend (directly or indirectly) coinbase transactions.
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
@ -65,7 +63,7 @@ class RawTransactionsTest(BitcoinTestFramework):
errorString = "" errorString = ""
try: try:
rawtx = self.nodes[2].sendrawtransaction(rawtx['hex']) rawtx = self.nodes[2].sendrawtransaction(rawtx['hex'])
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Missing inputs" in errorString, True); assert_equal("Missing inputs" in errorString, True);

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import wait_and_assert_operationid_status from test_framework.util import wait_and_assert_operationid_status

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -7,8 +7,6 @@
# Test -reindex with CheckBlockIndex # Test -reindex with CheckBlockIndex
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
start_node, stop_node, wait_bitcoinds start_node, stop_node, wait_bitcoinds
@ -31,7 +29,7 @@ class ReindexTest(BitcoinTestFramework):
wait_bitcoinds() wait_bitcoinds()
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug", "-reindex", "-checkblockindex=1"]) self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug", "-reindex", "-checkblockindex=1"])
assert_equal(self.nodes[0].getblockcount(), 3) assert_equal(self.nodes[0].getblockcount(), 3)
print "Success" print("Success")
if __name__ == '__main__': if __name__ == '__main__':
ReindexTest().main() ReindexTest().main()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -7,8 +7,6 @@
# Test reorg limit # Test reorg limit
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
check_node, check_node,
@ -19,7 +17,7 @@ from time import sleep
def check_stopped(i, timeout=10): def check_stopped(i, timeout=10):
stopped = False stopped = False
for x in xrange(1, timeout): for x in range(1, timeout):
ret = check_node(i) ret = check_node(i)
if ret is None: if ret is None:
sleep(1) sleep(1)
@ -36,39 +34,39 @@ class ReorgLimitTest(BitcoinTestFramework):
self.split_network() self.split_network()
print "Test the maximum-allowed reorg:" print("Test the maximum-allowed reorg:")
print "Mine 99 blocks on Node 0" print("Mine 99 blocks on Node 0")
self.nodes[0].generate(99) self.nodes[0].generate(99)
assert(self.nodes[0].getblockcount() == 299) assert(self.nodes[0].getblockcount() == 299)
assert(self.nodes[2].getblockcount() == 200) assert(self.nodes[2].getblockcount() == 200)
print "Mine competing 100 blocks on Node 2" print("Mine competing 100 blocks on Node 2")
self.nodes[2].generate(100) self.nodes[2].generate(100)
assert(self.nodes[0].getblockcount() == 299) assert(self.nodes[0].getblockcount() == 299)
assert(self.nodes[2].getblockcount() == 300) assert(self.nodes[2].getblockcount() == 300)
print "Connect nodes to force a reorg" print("Connect nodes to force a reorg")
connect_nodes_bi(self.nodes, 0, 2) connect_nodes_bi(self.nodes, 0, 2)
self.is_network_split = False self.is_network_split = False
sync_blocks(self.nodes) sync_blocks(self.nodes)
print "Check Node 0 is still running and on the correct chain" print("Check Node 0 is still running and on the correct chain")
assert(self.nodes[0].getblockcount() == 300) assert(self.nodes[0].getblockcount() == 300)
self.split_network() self.split_network()
print "Test the minimum-rejected reorg:" print("Test the minimum-rejected reorg:")
print "Mine 100 blocks on Node 0" print("Mine 100 blocks on Node 0")
self.nodes[0].generate(100) self.nodes[0].generate(100)
assert(self.nodes[0].getblockcount() == 400) assert(self.nodes[0].getblockcount() == 400)
assert(self.nodes[2].getblockcount() == 300) assert(self.nodes[2].getblockcount() == 300)
print "Mine competing 101 blocks on Node 2" print("Mine competing 101 blocks on Node 2")
self.nodes[2].generate(101) self.nodes[2].generate(101)
assert(self.nodes[0].getblockcount() == 400) assert(self.nodes[0].getblockcount() == 400)
assert(self.nodes[2].getblockcount() == 401) assert(self.nodes[2].getblockcount() == 401)
print "Sync nodes to force a reorg" print("Sync nodes to force a reorg")
connect_nodes_bi(self.nodes, 0, 2) connect_nodes_bi(self.nodes, 0, 2)
self.is_network_split = False self.is_network_split = False
# sync_blocks uses RPC calls to wait for nodes to be synced, so don't # sync_blocks uses RPC calls to wait for nodes to be synced, so don't
@ -76,7 +74,7 @@ class ReorgLimitTest(BitcoinTestFramework):
# when Node 0 stops. Instead, we explicitly check for the process itself # when Node 0 stops. Instead, we explicitly check for the process itself
# to stop. # to stop.
print "Check Node 0 is no longer running" print("Check Node 0 is no longer running")
assert(check_stopped(0)) assert(check_stopped(0))
# Dummy stop to enable the test to tear down # Dummy stop to enable the test to tear down

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
start_nodes, start_node, connect_nodes_bi, bitcoind_processes start_nodes, start_node, connect_nodes_bi, bitcoind_processes

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# #
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -19,8 +19,6 @@ that flag, we use a block time before the switchover date).
NOTE: This test is very slow and may take more than 40 minutes to run. NOTE: This test is very slow and may take more than 40 minutes to run.
''' '''
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 ComparisonTestFramework from test_framework.test_framework import ComparisonTestFramework
from test_framework.comptool import TestInstance, TestManager from test_framework.comptool import TestInstance, TestManager
from test_framework.mininode import NetworkThread from test_framework.mininode import NetworkThread
@ -107,7 +105,7 @@ def ParseScript(json_script):
parsed_script += CScriptNum(int(x, 0)) parsed_script += CScriptNum(int(x, 0))
elif x.startswith("0x"): elif x.startswith("0x"):
# Raw hex data, inserted NOT pushed onto stack: # Raw hex data, inserted NOT pushed onto stack:
for i in xrange(2, len(x), 2): for i in range(2, len(x), 2):
parsed_script = CScript(bytes(parsed_script) + bytes(chr(int(x[i:i+2],16)))) parsed_script = CScript(bytes(parsed_script) + bytes(chr(int(x[i:i+2],16))))
elif x.startswith("'") and x.endswith("'") and len(x) >= 2: elif x.startswith("'") and x.endswith("'") and len(x) >= 2:
# Single-quoted string, pushed as data. # Single-quoted string, pushed as data.
@ -118,7 +116,7 @@ def ParseScript(json_script):
if tryopname in OPCODES_BY_NAME: if tryopname in OPCODES_BY_NAME:
parsed_script += CScriptOp(OPCODES_BY_NAME["OP_" + x]) parsed_script += CScriptOp(OPCODES_BY_NAME["OP_" + x])
else: else:
print "ParseScript: error parsing '%s'" % x print("ParseScript: error parsing '%s'" % x)
return "" return ""
return parsed_script return parsed_script
@ -177,7 +175,7 @@ class ScriptTest(ComparisonTestFramework):
self.tip = block.sha256 self.tip = block.sha256
test.blocks_and_transactions = [[block, True]] test.blocks_and_transactions = [[block, True]]
for i in xrange(100): for i in range(100):
block = create_block(self.tip, create_coinbase(), self.block_time) block = create_block(self.tip, create_coinbase(), self.block_time)
self.block_time += 1 self.block_time += 1
block.solve() block.solve()
@ -243,7 +241,7 @@ class ScriptTest(ComparisonTestFramework):
else: else:
self.block_time = 1333230000 + counter # Before the BIP16 switchover self.block_time = 1333230000 + counter # Before the BIP16 switchover
print "Script test: [%s]" % script_test print("Script test: [%s]" % script_test)
yield self.generate_test_instance(scriptpubkey, scriptsig) yield self.generate_test_instance(scriptpubkey, scriptsig)
counter += 1 counter += 1

View File

@ -1,6 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_true, initialize_chain_clean, start_node from test_framework.util import assert_equal, assert_true, initialize_chain_clean, start_node
@ -9,7 +7,7 @@ from test_framework.authproxy import JSONRPCException
class SignOfflineTest (BitcoinTestFramework): class SignOfflineTest (BitcoinTestFramework):
# Setup Methods # Setup Methods
def setup_chain(self): def setup_chain(self):
print "Initializing test directory " + self.options.tmpdir print("Initializing test directory " + self.options.tmpdir)
initialize_chain_clean(self.options.tmpdir, 2) initialize_chain_clean(self.options.tmpdir, 2)
def setup_network(self): def setup_network(self):
@ -19,7 +17,7 @@ class SignOfflineTest (BitcoinTestFramework):
# Tests # Tests
def run_test(self): def run_test(self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].generate(101) self.nodes[0].generate(101)
offline_node = start_node(1, self.options.tmpdir, ["-maxconnections=0", "-nuparams=2bb40e60:10"]) offline_node = start_node(1, self.options.tmpdir, ["-maxconnections=0", "-nuparams=2bb40e60:10"])

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2015 The Bitcoin Core developers # Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
start_nodes start_nodes

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2019 The Zcash developers # Copyright (c) 2019 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -26,8 +26,6 @@
# 7. Verify zcashd rejected the block # 7. Verify zcashd rejected the block
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
assert_equal, assert_equal,

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -7,8 +7,6 @@
# Test proper accounting with malleable transactions # Test proper accounting with malleable transactions
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, connect_nodes, \ from test_framework.util import assert_equal, connect_nodes, \
sync_blocks, gather_inputs sync_blocks, gather_inputs

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, assert_greater_than, \ from test_framework.util import assert_equal, assert_greater_than, \
@ -29,7 +27,7 @@ class WalletTest (BitcoinTestFramework):
self.sync_all() self.sync_all()
def run_test (self): def run_test (self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].generate(4) self.nodes[0].generate(4)
self.sync_all() self.sync_all()
@ -106,7 +104,7 @@ class WalletTest (BitcoinTestFramework):
signed_tx = self.nodes[2].signrawtransaction(raw_tx) signed_tx = self.nodes[2].signrawtransaction(raw_tx)
try: try:
self.nodes[2].sendrawtransaction(signed_tx["hex"]) self.nodes[2].sendrawtransaction(signed_tx["hex"])
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert("absurdly high fees" in errorString) assert("absurdly high fees" in errorString)
assert("900000000 > 10000000" in errorString) assert("900000000 > 10000000" in errorString)
@ -291,10 +289,10 @@ class WalletTest (BitcoinTestFramework):
num_z_recipients = 2100 num_z_recipients = 2100
amount_per_recipient = Decimal('0.00000001') amount_per_recipient = Decimal('0.00000001')
errorString = '' errorString = ''
for i in xrange(0,num_t_recipients): for i in range(0,num_t_recipients):
newtaddr = self.nodes[2].getnewaddress() newtaddr = self.nodes[2].getnewaddress()
recipients.append({"address":newtaddr, "amount":amount_per_recipient}) recipients.append({"address":newtaddr, "amount":amount_per_recipient})
for i in xrange(0,num_z_recipients): for i in range(0,num_z_recipients):
newzaddr = self.nodes[2].z_getnewaddress('sprout') newzaddr = self.nodes[2].z_getnewaddress('sprout')
recipients.append({"address":newzaddr, "amount":amount_per_recipient}) recipients.append({"address":newzaddr, "amount":amount_per_recipient})
@ -309,7 +307,7 @@ class WalletTest (BitcoinTestFramework):
try: try:
self.nodes[0].z_sendmany(myzaddr, recipients) self.nodes[0].z_sendmany(myzaddr, recipients)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert("size of raw transaction would be larger than limit" in errorString) assert("size of raw transaction would be larger than limit" in errorString)
@ -395,7 +393,7 @@ class WalletTest (BitcoinTestFramework):
errorString = "" errorString = ""
try: try:
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "1f-4") txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "1f-4")
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Invalid amount" in errorString, True) assert_equal("Invalid amount" in errorString, True)
@ -403,7 +401,7 @@ class WalletTest (BitcoinTestFramework):
errorString = "" errorString = ""
try: try:
self.nodes[0].generate("2") #use a string to as block amount parameter must fail because it's not interpreted as amount self.nodes[0].generate("2") #use a string to as block amount parameter must fail because it's not interpreted as amount
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("not an integer" in errorString, True) assert_equal("not an integer" in errorString, True)
@ -417,9 +415,9 @@ class WalletTest (BitcoinTestFramework):
try: try:
myopid = self.nodes[0].z_sendmany(myzaddr, recipients) myopid = self.nodes[0].z_sendmany(myzaddr, recipients)
assert(myopid) assert(myopid)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
print errorString print(errorString)
assert(False) assert(False)
# This fee is larger than the default fee and since amount=0 # This fee is larger than the default fee and since amount=0
@ -431,7 +429,7 @@ class WalletTest (BitcoinTestFramework):
try: try:
myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, fee) myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, fee)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert('Small transaction amount' in errorString) assert('Small transaction amount' in errorString)
@ -444,9 +442,9 @@ class WalletTest (BitcoinTestFramework):
try: try:
myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, fee) myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, fee)
assert(myopid) assert(myopid)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
print errorString print(errorString)
assert(False) assert(False)
# Make sure amount=0, fee=0 transaction are valid to add to mempool # Make sure amount=0, fee=0 transaction are valid to add to mempool
@ -459,9 +457,9 @@ class WalletTest (BitcoinTestFramework):
try: try:
myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, fee) myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, fee)
assert(myopid) assert(myopid)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
print errorString print(errorString)
assert(False) assert(False)

View File

@ -1,12 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2016 The Zcash developers # Copyright (c) 2016 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
# This is a regression test for #1941. # This is a regression test for #1941.
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
initialize_datadir, start_nodes, start_node, connect_nodes_bi, \ initialize_datadir, start_nodes, start_node, connect_nodes_bi, \
@ -44,7 +42,7 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
self.sync_all() self.sync_all()
def run_test (self): def run_test (self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].setmocktime(starttime) self.nodes[0].setmocktime(starttime)
self.nodes[0].generate(101) self.nodes[0].generate(101)

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal from test_framework.util import assert_equal
@ -34,7 +32,7 @@ class WalletAddressesTest(BitcoinTestFramework):
# Current height = 200 -> Sapling # Current height = 200 -> Sapling
# Default address type is Sapling # Default address type is Sapling
print "Testing height 200 (Sapling)" print("Testing height 200 (Sapling)")
addr_checks('sapling') addr_checks('sapling')
self.nodes[0].generate(1) self.nodes[0].generate(1)
@ -42,7 +40,7 @@ class WalletAddressesTest(BitcoinTestFramework):
# Current height = 201 -> Sapling # Current height = 201 -> Sapling
# Default address type is Sapling # Default address type is Sapling
print "Testing height 201 (Sapling)" print("Testing height 201 (Sapling)")
addr_checks('sapling') addr_checks('sapling')
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
start_nodes, stop_nodes, connect_nodes_bi, \ start_nodes, stop_nodes, connect_nodes_bi, \
@ -27,7 +25,7 @@ class WalletAnchorForkTest (BitcoinTestFramework):
self.sync_all() self.sync_all()
def run_test (self): def run_test (self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].generate(4) self.nodes[0].generate(4)
self.sync_all() self.sync_all()

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2019 The Zcash developers # Copyright (c) 2019 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
connect_nodes_bi, connect_nodes_bi,
@ -83,13 +81,13 @@ class WalletChangeAddressesTest(BitcoinTestFramework):
saplingAddr = self.nodes[0].z_getnewaddress('sapling') saplingAddr = self.nodes[0].z_getnewaddress('sapling')
sproutAddr = self.nodes[0].z_getnewaddress('sprout') sproutAddr = self.nodes[0].z_getnewaddress('sprout')
print print()
print('Checking z_sendmany(taddr->Sapling)') print('Checking z_sendmany(taddr->Sapling)')
check_change_taddr_reuse(saplingAddr) check_change_taddr_reuse(saplingAddr)
print print()
print('Checking z_sendmany(taddr->Sprout)') print('Checking z_sendmany(taddr->Sprout)')
check_change_taddr_reuse(sproutAddr) check_change_taddr_reuse(sproutAddr)
print print()
print('Checking z_sendmany(taddr->taddr)') print('Checking z_sendmany(taddr->taddr)')
check_change_taddr_reuse(taddr) check_change_taddr_reuse(taddr)

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_true, assert_false, wait_and_assert_operationid_status from test_framework.util import assert_equal, assert_true, assert_false, wait_and_assert_operationid_status

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_true, start_nodes from test_framework.util import assert_equal, assert_true, start_nodes

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
assert_equal, assert_equal,

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_true, assert_false from test_framework.util import assert_equal, assert_true, assert_false
from test_framework.util import wait_and_assert_operationid_status from test_framework.util import wait_and_assert_operationid_status

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2016 The Zcash developers # Copyright (c) 2016 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_true, bitcoind_processes, \ from test_framework.util import assert_equal, assert_true, bitcoind_processes, \
connect_nodes_bi, start_node, start_nodes, wait_and_assert_operationid_status, \ connect_nodes_bi, start_node, start_nodes, wait_and_assert_operationid_status, \

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
assert_equal, assert_equal,
@ -112,22 +110,22 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
errorString = "" errorString = ""
try: try:
self.nodes[0].createrawtransaction([], {}, 0, 499999999) self.nodes[0].createrawtransaction([], {}, 0, 499999999)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("", errorString) assert_equal("", errorString)
try: try:
self.nodes[0].createrawtransaction([], {}, 0, -1) self.nodes[0].createrawtransaction([], {}, 0, -1)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Invalid parameter, expiryheight must be nonnegative and less than 500000000" in errorString, True) assert_equal("Invalid parameter, expiryheight must be nonnegative and less than 500000000" in errorString, True)
try: try:
self.nodes[0].createrawtransaction([], {}, 0, 500000000) self.nodes[0].createrawtransaction([], {}, 0, 500000000)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Invalid parameter, expiryheight must be nonnegative and less than 500000000" in errorString, True) assert_equal("Invalid parameter, expiryheight must be nonnegative and less than 500000000" in errorString, True)
try: try:
self.nodes[0].createrawtransaction([], {}, 0, 200) self.nodes[0].createrawtransaction([], {}, 0, 200)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Invalid parameter, expiryheight should be at least 203 to avoid transaction expiring soon" in errorString, True) assert_equal("Invalid parameter, expiryheight should be at least 203 to avoid transaction expiring soon" in errorString, True)

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
assert_equal, assert_true, assert_equal, assert_true,

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import ( from test_framework.util import (

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2017 The Zcash developers # Copyright (c) 2017 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
@ -35,7 +33,7 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
self.sync_all() self.sync_all()
def run_test (self): def run_test (self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].generate(1) self.nodes[0].generate(1)
self.nodes[0].generate(4) self.nodes[0].generate(4)
@ -64,42 +62,42 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
self.nodes[2].importaddress(mytaddr) self.nodes[2].importaddress(mytaddr)
try: try:
self.nodes[2].z_shieldcoinbase(mytaddr, myzaddr) self.nodes[2].z_shieldcoinbase(mytaddr, myzaddr)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Could not find any coinbase funds to shield" in errorString, True) assert_equal("Could not find any coinbase funds to shield" in errorString, True)
# Shielding will fail because fee is negative # Shielding will fail because fee is negative
try: try:
self.nodes[0].z_shieldcoinbase("*", myzaddr, -1) self.nodes[0].z_shieldcoinbase("*", myzaddr, -1)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Amount out of range" in errorString, True) assert_equal("Amount out of range" in errorString, True)
# Shielding will fail because fee is larger than MAX_MONEY # Shielding will fail because fee is larger than MAX_MONEY
try: try:
self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('21000000.00000001')) self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('21000000.00000001'))
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Amount out of range" in errorString, True) assert_equal("Amount out of range" in errorString, True)
# Shielding will fail because fee is larger than sum of utxos # Shielding will fail because fee is larger than sum of utxos
try: try:
self.nodes[0].z_shieldcoinbase("*", myzaddr, 999) self.nodes[0].z_shieldcoinbase("*", myzaddr, 999)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Insufficient coinbase funds" in errorString, True) assert_equal("Insufficient coinbase funds" in errorString, True)
# Shielding will fail because limit parameter must be at least 0 # Shielding will fail because limit parameter must be at least 0
try: try:
self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('0.001'), -1) self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('0.001'), -1)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Limit on maximum number of utxos cannot be negative" in errorString, True) assert_equal("Limit on maximum number of utxos cannot be negative" in errorString, True)
# Shielding will fail because limit parameter is absurdly large # Shielding will fail because limit parameter is absurdly large
try: try:
self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('0.001'), 99999999999999) self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('0.001'), 99999999999999)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("JSON integer out of range" in errorString, True) assert_equal("JSON integer out of range" in errorString, True)

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2016 The Zcash developers # Copyright (c) 2016 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.mininode import COIN from test_framework.mininode import COIN
@ -44,7 +42,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
self.sync_all() self.sync_all()
def run_test (self): def run_test (self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].generate(4) self.nodes[0].generate(4)
self.sync_all() self.sync_all()
@ -72,7 +70,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
errorString = "" errorString = ""
try: try:
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Coinbase funds can only be sent to a zaddr" in errorString, True) assert_equal("Coinbase funds can only be sent to a zaddr" in errorString, True)
@ -231,7 +229,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
errorString = "" errorString = ""
try: try:
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 99999) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 99999)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Insufficient funds" in errorString, True) assert_equal("Insufficient funds" in errorString, True)
@ -246,7 +244,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
# Send will fail because of insufficient funds unless sender uses coinbase utxos # Send will fail because of insufficient funds unless sender uses coinbase utxos
try: try:
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 21) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 21)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Insufficient funds, coinbase funds can only be spent after they have been sent to a zaddr" in errorString, True) assert_equal("Insufficient funds, coinbase funds can only be spent after they have been sent to a zaddr" in errorString, True)
@ -261,7 +259,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
# Note that regtest chainparams does not require standard tx, so setting the amount to be # Note that regtest chainparams does not require standard tx, so setting the amount to be
# less than the dust threshold, e.g. 0.00000001 will not result in mempool rejection. # less than the dust threshold, e.g. 0.00000001 will not result in mempool rejection.
start_time = timeit.default_timer() start_time = timeit.default_timer()
for i in xrange(0,num_t_recipients): for i in range(0,num_t_recipients):
newtaddr = self.nodes[2].getnewaddress() newtaddr = self.nodes[2].getnewaddress()
recipients.append({"address":newtaddr, "amount":amount_per_recipient}) recipients.append({"address":newtaddr, "amount":amount_per_recipient})
elapsed = timeit.default_timer() - start_time elapsed = timeit.default_timer() - start_time
@ -299,21 +297,21 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
# Send will fail because fee is negative # Send will fail because fee is negative
try: try:
self.nodes[0].z_sendmany(myzaddr, recipients, 1, -1) self.nodes[0].z_sendmany(myzaddr, recipients, 1, -1)
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Amount out of range" in errorString, True) assert_equal("Amount out of range" in errorString, True)
# Send will fail because fee is larger than MAX_MONEY # Send will fail because fee is larger than MAX_MONEY
try: try:
self.nodes[0].z_sendmany(myzaddr, recipients, 1, Decimal('21000000.00000001')) self.nodes[0].z_sendmany(myzaddr, recipients, 1, Decimal('21000000.00000001'))
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("Amount out of range" in errorString, True) assert_equal("Amount out of range" in errorString, True)
# Send will fail because fee is larger than sum of outputs # Send will fail because fee is larger than sum of outputs
try: try:
self.nodes[0].z_sendmany(myzaddr, recipients, 1, (amount_per_recipient * num_t_recipients) + Decimal('0.00000001')) self.nodes[0].z_sendmany(myzaddr, recipients, 1, (amount_per_recipient * num_t_recipients) + Decimal('0.00000001'))
except JSONRPCException,e: except JSONRPCException as e:
errorString = e.error['message'] errorString = e.error['message']
assert_equal("is greater than the sum of outputs" in errorString, True) assert_equal("is greater than the sum of outputs" in errorString, True)
@ -339,7 +337,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
send_amount = num_recipients * amount_per_recipient send_amount = num_recipients * amount_per_recipient
custom_fee = Decimal('0.00012345') custom_fee = Decimal('0.00012345')
zbalance = self.nodes[0].z_getbalance(myzaddr) zbalance = self.nodes[0].z_getbalance(myzaddr)
for i in xrange(0,num_recipients): for i in range(0,num_recipients):
newzaddr = self.nodes[2].z_getnewaddress('sprout') newzaddr = self.nodes[2].z_getnewaddress('sprout')
recipients.append({"address":newzaddr, "amount":amount_per_recipient}) recipients.append({"address":newzaddr, "amount":amount_per_recipient})
myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, custom_fee) myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, custom_fee)

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2016 The Zcash developers # Copyright (c) 2016 The Zcash developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
start_nodes, connect_nodes_bi, wait_and_assert_operationid_status, \ start_nodes, connect_nodes_bi, wait_and_assert_operationid_status, \
@ -29,7 +27,7 @@ class WalletTreeStateTest (BitcoinTestFramework):
self.sync_all() self.sync_all()
def run_test (self): def run_test (self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].generate(100) self.nodes[0].generate(100)
self.sync_all() self.sync_all()
@ -80,7 +78,7 @@ class WalletTreeStateTest (BitcoinTestFramework):
myopid = self.nodes[0].z_sendmany(myzaddr, recipients) myopid = self.nodes[0].z_sendmany(myzaddr, recipients)
# Wait for Tx 2 to begin executing... # Wait for Tx 2 to begin executing...
for x in xrange(1, 60): for x in range(1, 60):
results = self.nodes[0].z_getoperationstatus([myopid]) results = self.nodes[0].z_getoperationstatus([myopid])
status = results[0]["status"] status = results[0]["status"]
if status == "executing": if status == "executing":

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -33,8 +33,6 @@ Shutdown again, restore using importwallet,
and confirm again balances are correct. and confirm again balances are correct.
""" """
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \

View File

@ -1,10 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # 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 test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, initialize_chain_clean, \ from test_framework.util import assert_equal, initialize_chain_clean, \
@ -26,7 +24,7 @@ class ZapWalletTXesTest (BitcoinTestFramework):
self.sync_all() self.sync_all()
def run_test (self): def run_test (self):
print "Mining blocks..." print("Mining blocks...")
self.nodes[0].generate(4) self.nodes[0].generate(4)
self.sync_all() self.sync_all()
self.nodes[1].generate(101) self.nodes[1].generate(101)
@ -72,8 +70,8 @@ class ZapWalletTXesTest (BitcoinTestFramework):
aException = False aException = False
try: try:
tx3 = self.nodes[0].gettransaction(txid3) tx3 = self.nodes[0].gettransaction(txid3)
except JSONRPCException,e: except JSONRPCException as e:
print e print(e)
aException = True aException = True
assert_equal(aException, True) # there must be a expection because the unconfirmed wallettx0 must be gone by now assert_equal(aException, True) # there must be a expection because the unconfirmed wallettx0 must be gone by now

View File

@ -1,11 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python3
# #
# Test joinsplit semantics # Test joinsplit semantics
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, start_node, \ from test_framework.util import assert_equal, start_node, \
gather_inputs gather_inputs
@ -53,7 +51,7 @@ class JoinSplitTest(BitcoinTestFramework):
self.nodes[0].generate(1) self.nodes[0].generate(1)
self.sync_all() self.sync_all()
print "Done!" print("Done!")
receive_result = self.nodes[0].zcrawreceive(zcsecretkey, joinsplit_result["encryptednote1"]) receive_result = self.nodes[0].zcrawreceive(zcsecretkey, joinsplit_result["encryptednote1"])
assert_equal(receive_result["exists"], True) assert_equal(receive_result["exists"], True)

View File

@ -1,11 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python3
# #
# Tests a joinsplit double-spend and a subsequent reorg. # Tests a joinsplit double-spend and a subsequent reorg.
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, connect_nodes, \ from test_framework.util import assert_equal, connect_nodes, \
@ -133,12 +131,12 @@ class JoinSplitTest(BitcoinTestFramework):
# Wait until node[1] receives AB before we attempt to double-spend # Wait until node[1] receives AB before we attempt to double-spend
# with BC. # with BC.
print "Waiting for AB_txid...\n" print("Waiting for AB_txid...\n")
while True: while True:
if self.txid_in_mempool(self.nodes[1], AB_txid): if self.txid_in_mempool(self.nodes[1], AB_txid):
break break
time.sleep(0.2) time.sleep(0.2)
print "Done!\n" print("Done!\n")
self.expect_cannot_joinsplit(self.nodes[1], joinsplit_BC["rawtxn"]) self.expect_cannot_joinsplit(self.nodes[1], joinsplit_BC["rawtxn"])

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2015 The Bitcoin Core developers # Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php . # file COPYING or https://www.opensource.org/licenses/mit-license.php .
@ -7,10 +7,8 @@
# Test ZMQ interface # Test ZMQ interface
# #
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 from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, bytes_to_hex_str, start_nodes from test_framework.util import assert_equal, bytes_to_hex_str, start_nodes, wait_and_assert_operationid_status
import zmq import zmq
import struct import struct
@ -38,7 +36,7 @@ class ZMQTest(BitcoinTestFramework):
genhashes = self.nodes[0].generate(1) genhashes = self.nodes[0].generate(1)
self.sync_all() self.sync_all()
print "listen..." print("listen...")
msg = self.zmqSubSocket.recv_multipart() msg = self.zmqSubSocket.recv_multipart()
topic = msg[0] topic = msg[0]
body = msg[1] body = msg[1]