Auto merge of #4236 - mdr0id:rpc_py2_to_py3, r=mdr0id
RPC Python2 to Python3 Update Updates to allow RPCs to run in Python3.
This commit is contained in:
commit
b5e38edfda
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -13,7 +13,6 @@
|
|||
# getaddressutxos
|
||||
# getaddressmempool
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
||||
|
@ -40,7 +39,7 @@ from test_framework.mininode import (
|
|||
CTxIn, CTxOut, COutPoint,
|
||||
)
|
||||
|
||||
from binascii import hexlify
|
||||
from binascii import hexlify, unhexlify
|
||||
|
||||
|
||||
class AddressIndexTest(BitcoinTestFramework):
|
||||
|
@ -252,7 +251,7 @@ class AddressIndexTest(BitcoinTestFramework):
|
|||
|
||||
# Ensure the change from that transaction appears
|
||||
tx = self.nodes[0].getrawtransaction(txid, 1)
|
||||
change_vout = filter(lambda v: v['valueZat'] != 3 * COIN, tx['vout'])
|
||||
change_vout = list(filter(lambda v: v['valueZat'] != 3 * COIN, tx['vout']))
|
||||
change = change_vout[0]['scriptPubKey']['addresses'][0]
|
||||
bal = self.nodes[2].getaddressbalance(change)
|
||||
assert(bal['received'] > 0)
|
||||
|
@ -323,7 +322,7 @@ class AddressIndexTest(BitcoinTestFramework):
|
|||
# so for comparison, remove the 4 (and -4 for output) from the
|
||||
# deltas list
|
||||
deltas = self.nodes[1].getaddressdeltas({'addresses': [addr1]})
|
||||
deltas = filter(lambda d: abs(d['satoshis']) != 4 * COIN, deltas)
|
||||
deltas = list(filter(lambda d: abs(d['satoshis']) != 4 * COIN, deltas))
|
||||
assert_equal(len(utxos), len(deltas))
|
||||
for i in range(len(utxos)):
|
||||
assert_equal(utxos[i]['address'], addr1)
|
||||
|
@ -334,13 +333,13 @@ class AddressIndexTest(BitcoinTestFramework):
|
|||
# Check that outputs with the same address in the same tx return one txid
|
||||
# (can't use createrawtransaction() as it combines duplicate addresses)
|
||||
addr = "t2LMJ6Arw9UWBMWvfUr2QLHM4Xd9w53FftS"
|
||||
addressHash = "97643ce74b188f4fb6bbbb285e067a969041caf2".decode('hex')
|
||||
addressHash = unhexlify("97643ce74b188f4fb6bbbb285e067a969041caf2")
|
||||
scriptPubKey = CScript([OP_HASH160, addressHash, OP_EQUAL])
|
||||
# Add an unrecognized script type to vout[], a legal script that pays,
|
||||
# but won't modify the addressindex (since the address can't be extracted).
|
||||
# (This extra output has no effect on the rest of the test.)
|
||||
scriptUnknown = CScript([OP_HASH160, OP_DUP, OP_DROP, addressHash, OP_EQUAL])
|
||||
unspent = filter(lambda u: u['amount'] >= 4, self.nodes[0].listunspent())
|
||||
unspent = list(filter(lambda u: u['amount'] >= 4, self.nodes[0].listunspent()))
|
||||
tx = CTransaction()
|
||||
tx.vin = [CTxIn(COutPoint(int(unspent[0]['txid'], 16), unspent[0]['vout']))]
|
||||
tx.vout = [
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
#
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import ComparisonTestFramework
|
||||
from test_framework.util import start_nodes
|
||||
from test_framework.mininode import CTransaction, NetworkThread
|
||||
|
@ -13,8 +11,7 @@ from test_framework.blocktools import create_coinbase, create_block
|
|||
from test_framework.comptool import TestInstance, TestManager
|
||||
from test_framework.script import CScript, OP_1NEGATE, OP_NOP2, OP_DROP
|
||||
from binascii import unhexlify
|
||||
import cStringIO
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
'''
|
||||
This test is meant to exercise BIP65 (CHECKLOCKTIMEVERIFY).
|
||||
|
@ -50,7 +47,7 @@ class BIP65Test(ComparisonTestFramework):
|
|||
rawtx = node.createrawtransaction(inputs, outputs)
|
||||
signresult = node.signrawtransaction(rawtx)
|
||||
tx = CTransaction()
|
||||
f = cStringIO.StringIO(unhexlify(signresult['hex']))
|
||||
f = BytesIO(unhexlify(signresult['hex']))
|
||||
tx.deserialize(f)
|
||||
return tx
|
||||
|
||||
|
@ -67,8 +64,8 @@ class BIP65Test(ComparisonTestFramework):
|
|||
self.coinbase_blocks = self.nodes[0].generate(1)
|
||||
self.nodes[0].generate(100)
|
||||
hashTip = self.nodes[0].getbestblockhash()
|
||||
hashFinalSaplingRoot = int("0x" + self.nodes[0].getblock(hashTip)['finalsaplingroot'] + "L", 0)
|
||||
self.tip = int ("0x" + hashTip + "L", 0)
|
||||
hashFinalSaplingRoot = int("0x" + self.nodes[0].getblock(hashTip)['finalsaplingroot'] , 0)
|
||||
self.tip = int ("0x" + hashTip , 0)
|
||||
self.nodeaddress = self.nodes[0].getnewaddress()
|
||||
|
||||
'''Check that the rules are enforced.'''
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
#
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import ComparisonTestFramework
|
||||
from test_framework.util import start_nodes
|
||||
from test_framework.mininode import CTransaction, NetworkThread
|
||||
|
@ -13,7 +11,7 @@ from test_framework.blocktools import create_coinbase, create_block
|
|||
from test_framework.comptool import TestInstance, TestManager
|
||||
from test_framework.script import CScript
|
||||
from binascii import unhexlify
|
||||
import cStringIO
|
||||
import io
|
||||
|
||||
|
||||
'''
|
||||
|
@ -49,7 +47,7 @@ class BIP66Test(ComparisonTestFramework):
|
|||
rawtx = node.createrawtransaction(inputs, outputs)
|
||||
signresult = node.signrawtransaction(rawtx)
|
||||
tx = CTransaction()
|
||||
f = cStringIO.StringIO(unhexlify(signresult['hex']))
|
||||
f = io.BytesIO(unhexlify(signresult['hex']))
|
||||
tx.deserialize(f)
|
||||
return tx
|
||||
|
||||
|
@ -74,8 +72,8 @@ class BIP66Test(ComparisonTestFramework):
|
|||
self.coinbase_blocks = self.nodes[0].generate(1)
|
||||
self.nodes[0].generate(100)
|
||||
hashTip = self.nodes[0].getbestblockhash()
|
||||
hashFinalSaplingRoot = int("0x" + self.nodes[0].getblock(hashTip)['finalsaplingroot'] + "L", 0)
|
||||
self.tip = int ("0x" + hashTip + "L", 0)
|
||||
hashFinalSaplingRoot = int("0x" + self.nodes[0].getblock(hashTip)['finalsaplingroot'], 0)
|
||||
self.tip = int ("0x"+hashTip , 0)
|
||||
self.nodeaddress = self.nodes[0].getnewaddress()
|
||||
|
||||
'''Check that the rules are enforced.'''
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -8,8 +8,6 @@
|
|||
# rpc/blockchain.cpp.
|
||||
#
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
import decimal
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
@ -42,13 +40,13 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
node = self.nodes[0]
|
||||
res = node.gettxoutsetinfo()
|
||||
|
||||
assert_equal(res[u'total_amount'], decimal.Decimal('2181.25000000')) # 150*12.5 + 49*6.25
|
||||
assert_equal(res[u'transactions'], 200)
|
||||
assert_equal(res[u'height'], 200)
|
||||
assert_equal(res[u'txouts'], 349) # 150*2 + 49
|
||||
assert_equal(res[u'bytes_serialized'], 14951), # 32*199 + 48*90 + 49*60 + 27*49
|
||||
assert_equal(len(res[u'bestblock']), 64)
|
||||
assert_equal(len(res[u'hash_serialized']), 64)
|
||||
assert_equal(res['total_amount'], decimal.Decimal('2181.25000000')) # 150*12.5 + 49*6.25
|
||||
assert_equal(res['transactions'], 200)
|
||||
assert_equal(res['height'], 200)
|
||||
assert_equal(res['txouts'], 349) # 150*2 + 49
|
||||
assert_equal(res['bytes_serialized'], 14951), # 32*199 + 48*90 + 49*60 + 27*49
|
||||
assert_equal(len(res['bestblock']), 64)
|
||||
assert_equal(len(res['hash_serialized']), 64)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2015 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_nodes
|
||||
start_nodes, hex_str_to_bytes, bytes_to_hex_str
|
||||
from test_framework.mininode import CTransaction
|
||||
from binascii import hexlify, unhexlify
|
||||
from cStringIO import StringIO
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
class DecodeScriptTest(BitcoinTestFramework):
|
||||
|
@ -135,7 +132,7 @@ class DecodeScriptTest(BitcoinTestFramework):
|
|||
assert_equal('OP_DUP OP_HASH160 dc863734a218bfe83ef770ee9d41a27f824a6e56 OP_EQUALVERIFY OP_CHECKSIG', rpc_result['vout'][0]['scriptPubKey']['asm'])
|
||||
assert_equal('OP_HASH160 2a5edea39971049a540474c6a99edf0aa4074c58 OP_EQUAL', rpc_result['vout'][1]['scriptPubKey']['asm'])
|
||||
txSave = CTransaction()
|
||||
txSave.deserialize(StringIO(unhexlify(tx)))
|
||||
txSave.deserialize(BytesIO(hex_str_to_bytes(tx)))
|
||||
|
||||
# make sure that a specifically crafted op_return value will not pass all the IsDERSignature checks and then get decoded as a sighash type
|
||||
tx = '01000000015ded05872fdbda629c7d3d02b194763ce3b9b1535ea884e3c8e765d42e316724020000006b48304502204c10d4064885c42638cbff3585915b322de33762598321145ba033fc796971e2022100bb153ad3baa8b757e30a2175bd32852d2e1cb9080f84d7e32fcdfd667934ef1b012103163c0ff73511ea1743fb5b98384a2ff09dd06949488028fd819f4d83f56264efffffffff0200000000000000000b6a0930060201000201000180380100000000001976a9141cabd296e753837c086da7a45a6c2fe0d49d7b7b88ac00000000'
|
||||
|
@ -151,7 +148,7 @@ class DecodeScriptTest(BitcoinTestFramework):
|
|||
# some more full transaction tests of varying specific scriptSigs. used instead of
|
||||
# tests in decodescript_script_sig because the decodescript RPC is specifically
|
||||
# for working on scriptPubKeys (argh!).
|
||||
push_signature = hexlify(txSave.vin[0].scriptSig)[2:(0x48*2+4)]
|
||||
push_signature = bytes_to_hex_str(txSave.vin[0].scriptSig)[2:(0x48*2+4)]
|
||||
signature = push_signature[2:]
|
||||
der_signature = signature[:-2]
|
||||
signature_sighash_decoded = der_signature + '[ALL]'
|
||||
|
@ -160,25 +157,24 @@ class DecodeScriptTest(BitcoinTestFramework):
|
|||
signature_2_sighash_decoded = der_signature + '[NONE|ANYONECANPAY]'
|
||||
|
||||
# 1) P2PK scriptSig
|
||||
txSave.vin[0].scriptSig = unhexlify(push_signature)
|
||||
rpc_result = self.nodes[0].decoderawtransaction(hexlify(txSave.serialize()))
|
||||
txSave.vin[0].scriptSig = hex_str_to_bytes(push_signature)
|
||||
rpc_result = self.nodes[0].decoderawtransaction(bytes_to_hex_str(txSave.serialize()))
|
||||
assert_equal(signature_sighash_decoded, rpc_result['vin'][0]['scriptSig']['asm'])
|
||||
|
||||
# make sure that the sighash decodes come out correctly for a more complex / lesser used case.
|
||||
txSave.vin[0].scriptSig = unhexlify(push_signature_2)
|
||||
rpc_result = self.nodes[0].decoderawtransaction(hexlify(txSave.serialize()))
|
||||
txSave.vin[0].scriptSig = hex_str_to_bytes(push_signature_2)
|
||||
rpc_result = self.nodes[0].decoderawtransaction(bytes_to_hex_str(txSave.serialize()))
|
||||
assert_equal(signature_2_sighash_decoded, rpc_result['vin'][0]['scriptSig']['asm'])
|
||||
|
||||
# 2) multisig scriptSig
|
||||
txSave.vin[0].scriptSig = unhexlify('00' + push_signature + push_signature_2)
|
||||
rpc_result = self.nodes[0].decoderawtransaction(hexlify(txSave.serialize()))
|
||||
txSave.vin[0].scriptSig = hex_str_to_bytes('00' + push_signature + push_signature_2)
|
||||
rpc_result = self.nodes[0].decoderawtransaction(bytes_to_hex_str(txSave.serialize()))
|
||||
assert_equal('0 ' + signature_sighash_decoded + ' ' + signature_2_sighash_decoded, rpc_result['vin'][0]['scriptSig']['asm'])
|
||||
|
||||
# 3) test a scriptSig that contains more than push operations.
|
||||
# in fact, it contains an OP_RETURN with data specially crafted to cause improper decode if the code does not catch it.
|
||||
txSave.vin[0].scriptSig = unhexlify('6a143011020701010101010101020601010101010101')
|
||||
rpc_result = self.nodes[0].decoderawtransaction(hexlify(txSave.serialize()))
|
||||
print(hexlify('636174'))
|
||||
txSave.vin[0].scriptSig = hex_str_to_bytes('6a143011020701010101010101020601010101010101')
|
||||
rpc_result = self.nodes[0].decoderawtransaction(bytes_to_hex_str(txSave.serialize()))
|
||||
assert_equal('OP_RETURN 3011020701010101010101020601010101010101', rpc_result['vin'][0]['scriptSig']['asm'])
|
||||
|
||||
def run_test(self):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# Exercise API with -disablewallet.
|
||||
#
|
||||
|
||||
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.util import initialize_chain_clean, start_nodes
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
|
@ -49,7 +48,7 @@ class FinalSaplingRootTest(BitcoinTestFramework):
|
|||
|
||||
# Verify all generated blocks contain the empty root of the Sapling tree.
|
||||
blockcount = self.nodes[0].getblockcount()
|
||||
for height in xrange(1, blockcount + 1):
|
||||
for height in range(1, blockcount + 1):
|
||||
blk = self.nodes[0].getblock(str(height))
|
||||
assert_equal(blk["finalsaplingroot"], SAPLING_TREE_EMPTY_ROOT)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# Test -alertnotify
|
||||
#
|
||||
|
||||
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.util import start_node, connect_nodes
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, assert_greater_than, \
|
||||
|
@ -33,8 +31,8 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test(self):
|
||||
print "Mining blocks..."
|
||||
feeTolerance = Decimal(0.00000002) #if the fee's positive delta is higher than this value tests will fail, neg. delta always fail the tests
|
||||
print("Mining blocks...")
|
||||
feeTolerance = Decimal("0.00000002") #if the fee's positive delta is higher than this value tests will fail, neg. delta always fail the tests
|
||||
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
|
@ -46,11 +44,11 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
watchonly_amount = 200
|
||||
self.nodes[3].importpubkey(watchonly_pubkey, "", True)
|
||||
watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount)
|
||||
self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10);
|
||||
self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10)
|
||||
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5);
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0);
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0);
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5)
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0)
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0)
|
||||
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
|
@ -123,12 +121,12 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
for aUtx in listunspent:
|
||||
if aUtx['amount'] == 5.0:
|
||||
utx = aUtx
|
||||
break;
|
||||
break
|
||||
|
||||
assert_equal(utx!=False, True)
|
||||
|
||||
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']}]
|
||||
outputs = { self.nodes[0].getnewaddress() : 1.0 }
|
||||
outputs = { self.nodes[0].getnewaddress() : Decimal('1.0') }
|
||||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
|
||||
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
|
||||
assert_equal(utx['txid'], dec_tx['vin'][0]['txid'])
|
||||
|
@ -152,12 +150,12 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
for aUtx in listunspent:
|
||||
if aUtx['amount'] == 5.0:
|
||||
utx = aUtx
|
||||
break;
|
||||
break
|
||||
|
||||
assert_equal(utx!=False, True)
|
||||
|
||||
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']}]
|
||||
outputs = { self.nodes[0].getnewaddress() : Decimal(5.0) - fee - feeTolerance }
|
||||
outputs = { self.nodes[0].getnewaddress() : Decimal('5.0') - fee - feeTolerance }
|
||||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
|
||||
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
|
||||
assert_equal(utx['txid'], dec_tx['vin'][0]['txid'])
|
||||
|
@ -182,12 +180,12 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
for aUtx in listunspent:
|
||||
if aUtx['amount'] == 1.0:
|
||||
utx = aUtx
|
||||
break;
|
||||
break
|
||||
|
||||
assert_equal(utx!=False, True)
|
||||
|
||||
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']}]
|
||||
outputs = { self.nodes[0].getnewaddress() : 1.0 }
|
||||
outputs = { self.nodes[0].getnewaddress() : Decimal('1.0') }
|
||||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
|
||||
|
||||
# 4-byte version + 4-byte versionGroupId + 1-byte vin count + 36-byte prevout then script_len
|
||||
|
@ -204,7 +202,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
matchingOuts = 0
|
||||
for i, out in enumerate(dec_tx['vout']):
|
||||
totalOut += out['value']
|
||||
if outputs.has_key(out['scriptPubKey']['addresses'][0]):
|
||||
if out['scriptPubKey']['addresses'][0] in outputs :
|
||||
matchingOuts+=1
|
||||
else:
|
||||
assert_equal(i, rawtxfund['changepos'])
|
||||
|
@ -244,7 +242,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
matchingOuts = 0
|
||||
for out in dec_tx['vout']:
|
||||
totalOut += out['value']
|
||||
if outputs.has_key(out['scriptPubKey']['addresses'][0]):
|
||||
if out['scriptPubKey']['addresses'][0] in outputs:
|
||||
matchingOuts+=1
|
||||
|
||||
assert_equal(matchingOuts, 1)
|
||||
|
@ -286,7 +284,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
matchingOuts = 0
|
||||
for out in dec_tx['vout']:
|
||||
totalOut += out['value']
|
||||
if outputs.has_key(out['scriptPubKey']['addresses'][0]):
|
||||
if out['scriptPubKey']['addresses'][0] in outputs:
|
||||
matchingOuts+=1
|
||||
|
||||
assert_equal(matchingOuts, 2)
|
||||
|
@ -304,10 +302,10 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
errorString = ""
|
||||
try:
|
||||
rawtxfund = self.nodes[2].fundrawtransaction(rawtx)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
|
||||
assert_equal("Insufficient" in errorString, True);
|
||||
assert_equal("Insufficient" in errorString, True)
|
||||
|
||||
|
||||
|
||||
|
@ -319,11 +317,11 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
|
||||
|
||||
#create same transaction over sendtoaddress
|
||||
txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1);
|
||||
txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1)
|
||||
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
|
||||
|
||||
#compare fee
|
||||
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
|
||||
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
|
||||
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
|
||||
############################################################
|
||||
|
||||
|
@ -334,11 +332,11 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
rawTx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
|
||||
#create same transaction over sendtoaddress
|
||||
txId = self.nodes[0].sendmany("", outputs);
|
||||
txId = self.nodes[0].sendmany("", outputs)
|
||||
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
|
||||
|
||||
#compare fee
|
||||
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
|
||||
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
|
||||
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
|
||||
############################################################
|
||||
|
||||
|
@ -361,11 +359,11 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
|
||||
|
||||
#create same transaction over sendtoaddress
|
||||
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
|
||||
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
|
||||
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
|
||||
|
||||
#compare fee
|
||||
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
|
||||
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
|
||||
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
|
||||
############################################################
|
||||
|
||||
|
@ -394,11 +392,11 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
|
||||
|
||||
#create same transaction over sendtoaddress
|
||||
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
|
||||
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
|
||||
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']
|
||||
|
||||
#compare fee
|
||||
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
|
||||
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
|
||||
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
|
||||
############################################################
|
||||
|
||||
|
@ -417,7 +415,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
|
||||
|
||||
# send 1.2 BTC to msig addr
|
||||
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2);
|
||||
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2)
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
|
@ -455,7 +453,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
|
||||
error = False
|
||||
try:
|
||||
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2);
|
||||
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2)
|
||||
except:
|
||||
error = True
|
||||
assert(error)
|
||||
|
@ -485,13 +483,13 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
###############################################
|
||||
|
||||
#empty node1, send some small coins from node0 to node1
|
||||
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
|
||||
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
for i in range(0,20):
|
||||
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
|
||||
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
@ -503,11 +501,11 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
fundedTx = self.nodes[1].fundrawtransaction(rawTx)
|
||||
|
||||
#create same transaction over sendtoaddress
|
||||
txId = self.nodes[1].sendmany("", outputs);
|
||||
txId = self.nodes[1].sendmany("", outputs)
|
||||
signedFee = self.nodes[1].getrawmempool(True)[txId]['fee']
|
||||
|
||||
#compare fee
|
||||
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
|
||||
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
|
||||
assert(feeDelta >= 0 and feeDelta <= feeTolerance*19) #~19 inputs
|
||||
|
||||
|
||||
|
@ -516,13 +514,13 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
#############################################
|
||||
|
||||
#again, empty node1, send some small coins from node0 to node1
|
||||
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
|
||||
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
for i in range(0,20):
|
||||
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
|
||||
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2016 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, connect_nodes_bi, \
|
||||
initialize_chain_clean, start_nodes
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import AuthServiceProxy
|
||||
from test_framework.util import random_transaction
|
||||
|
@ -53,7 +51,7 @@ class GetBlockTemplateLPTest(BitcoinTestFramework):
|
|||
'''
|
||||
|
||||
def run_test(self):
|
||||
print "Warning: this test will take about 70 seconds in the best case. Be patient."
|
||||
print("Warning: this test will take about 70 seconds in the best case. Be patient.")
|
||||
self.nodes[0].generate(10)
|
||||
templat = self.nodes[0].getblocktemplate()
|
||||
longpollid = templat['longpollid']
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,7 +7,6 @@
|
|||
# on chains of different lengths, and join the network together again.
|
||||
# This gives us two tips, verify that it works.
|
||||
|
||||
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.util import assert_equal
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -65,7 +65,7 @@ class GetrawtransactionTest(BitcoinTestFramework):
|
|||
tx_a = self.nodes[2].getrawtransaction(txid_a, 1)
|
||||
|
||||
# txid_b is not yet confirmed, so height is invalid (-1)
|
||||
vout = filter(lambda o: o['value'] == 2, tx_a['vout'])
|
||||
vout = list(filter(lambda o: o['value'] == 2, tx_a['vout']))
|
||||
assert_equal(vout[0]['spentTxId'], txid_b)
|
||||
assert_equal(vout[0]['spentIndex'], 0)
|
||||
assert_equal(vout[0]['spentHeight'], -1)
|
||||
|
@ -84,7 +84,7 @@ class GetrawtransactionTest(BitcoinTestFramework):
|
|||
assert_equal(tx_a['vin'][0]['value'], 10) # coinbase
|
||||
assert_equal(tx_a['vin'][0]['valueSat'], 10*COIN)
|
||||
# we want the non-change (payment) output
|
||||
vout = filter(lambda o: o['value'] == 2, tx_a['vout'])
|
||||
vout = list(filter(lambda o: o['value'] == 2, tx_a['vout']))
|
||||
assert_equal(vout[0]['spentTxId'], txid_b)
|
||||
assert_equal(vout[0]['spentIndex'], 0)
|
||||
assert_equal(vout[0]['spentHeight'], 107)
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
#
|
||||
# Test hard fork detection
|
||||
#
|
||||
|
||||
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.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, start_node
|
||||
|
@ -31,7 +29,7 @@ class HardForkDetectionTest(BitcoinTestFramework):
|
|||
errorString = ""
|
||||
try:
|
||||
self.nodes[0].getbalance()
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
|
||||
assert_equal("Safe mode:" in errorString, True)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,21 +7,11 @@
|
|||
# Test rpc http basics
|
||||
#
|
||||
|
||||
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.util import assert_equal, start_nodes
|
||||
from test_framework.util import assert_equal, start_nodes, str_to_b64str
|
||||
|
||||
import base64
|
||||
|
||||
try:
|
||||
import http.client as httplib
|
||||
except ImportError:
|
||||
import httplib
|
||||
try:
|
||||
import urllib.parse as urlparse
|
||||
except ImportError:
|
||||
import urlparse
|
||||
from http.client import HTTPConnection
|
||||
from urllib.parse import urlparse
|
||||
|
||||
class HTTPBasicsTest (BitcoinTestFramework):
|
||||
def setup_nodes(self):
|
||||
|
@ -32,72 +22,72 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||
#################################################
|
||||
# lowlevel check for http persistent connection #
|
||||
#################################################
|
||||
url = urlparse.urlparse(self.nodes[0].url)
|
||||
url = urlparse(self.nodes[0].url)
|
||||
authpair = url.username + ':' + url.password
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpair)}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
|
||||
|
||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
||||
conn = HTTPConnection(url.hostname, url.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
out1 = conn.getresponse().read()
|
||||
assert_equal('"error":null' in out1, True)
|
||||
assert_equal(b'"error":null' in out1, True)
|
||||
assert_equal(conn.sock!=None, True) # according to http/1.1 connection must still be open!
|
||||
|
||||
# send 2nd request without closing connection
|
||||
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
|
||||
out2 = conn.getresponse().read()
|
||||
assert_equal('"error":null' in out2, True) # must also response with a correct json-rpc message
|
||||
assert_equal(b'"error":null' in out2, True) # must also response with a correct json-rpc message
|
||||
assert_equal(conn.sock!=None, True) # according to http/1.1 connection must still be open!
|
||||
conn.close()
|
||||
|
||||
# same should be if we add keep-alive because this should be the std. behaviour
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpair), "Connection": "keep-alive"}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair), "Connection": "keep-alive"}
|
||||
|
||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
||||
conn = HTTPConnection(url.hostname, url.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
out1 = conn.getresponse().read()
|
||||
assert_equal('"error":null' in out1, True)
|
||||
assert_equal(b'"error":null' in out1, True)
|
||||
assert_equal(conn.sock!=None, True) # according to http/1.1 connection must still be open!
|
||||
|
||||
# send 2nd request without closing connection
|
||||
conn.request('POST', '/', '{"method": "getchaintips"}', headers)
|
||||
out2 = conn.getresponse().read()
|
||||
assert_equal('"error":null' in out2, True) # must also response with a correct json-rpc message
|
||||
assert_equal(b'"error":null' in out2, True) # must also response with a correct json-rpc message
|
||||
assert_equal(conn.sock!=None, True) # according to http/1.1 connection must still be open!
|
||||
conn.close()
|
||||
|
||||
# now do the same with "Connection: close"
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpair), "Connection":"close"}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair), "Connection":"close"}
|
||||
|
||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
||||
conn = HTTPConnection(url.hostname, url.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
out1 = conn.getresponse().read()
|
||||
assert_equal('"error":null' in out1, True)
|
||||
assert_equal(b'"error":null' in out1, True)
|
||||
assert_equal(conn.sock!=None, False) # now the connection must be closed after the response
|
||||
|
||||
# node1 (2nd node) is running with disabled keep-alive option
|
||||
urlNode1 = urlparse.urlparse(self.nodes[1].url)
|
||||
urlNode1 = urlparse(self.nodes[1].url)
|
||||
authpair = urlNode1.username + ':' + urlNode1.password
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpair)}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
|
||||
|
||||
conn = httplib.HTTPConnection(urlNode1.hostname, urlNode1.port)
|
||||
conn = HTTPConnection(urlNode1.hostname, urlNode1.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
out1 = conn.getresponse().read()
|
||||
assert_equal('"error":null' in out1, True)
|
||||
assert_equal(b'"error":null' in out1, True)
|
||||
|
||||
# node2 (third node) is running with standard keep-alive parameters which means keep-alive is on
|
||||
urlNode2 = urlparse.urlparse(self.nodes[2].url)
|
||||
urlNode2 = urlparse(self.nodes[2].url)
|
||||
authpair = urlNode2.username + ':' + urlNode2.password
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpair)}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
|
||||
|
||||
conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port)
|
||||
conn = HTTPConnection(urlNode2.hostname, urlNode2.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
out1 = conn.getresponse().read()
|
||||
assert_equal('"error":null' in out1, True)
|
||||
assert_equal(b'"error":null' in out1, True)
|
||||
assert_equal(conn.sock!=None, True) # connection must be closed because bitcoind should use keep-alive by default
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# Test InvalidateBlock code
|
||||
#
|
||||
|
||||
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.util import initialize_chain_clean, start_node, \
|
||||
connect_nodes_bi, sync_blocks
|
||||
|
@ -28,46 +26,46 @@ class InvalidateTest(BitcoinTestFramework):
|
|||
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug"]))
|
||||
|
||||
def run_test(self):
|
||||
print "Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:"
|
||||
print "Mine 4 blocks on Node 0"
|
||||
print("Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:")
|
||||
print("Mine 4 blocks on Node 0")
|
||||
self.nodes[0].generate(4)
|
||||
assert(self.nodes[0].getblockcount() == 4)
|
||||
besthash = self.nodes[0].getbestblockhash()
|
||||
|
||||
print "Mine competing 6 blocks on Node 1"
|
||||
print("Mine competing 6 blocks on Node 1")
|
||||
self.nodes[1].generate(6)
|
||||
assert(self.nodes[1].getblockcount() == 6)
|
||||
|
||||
print "Connect nodes to force a reorg"
|
||||
print("Connect nodes to force a reorg")
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
sync_blocks(self.nodes[0:2])
|
||||
assert(self.nodes[0].getblockcount() == 6)
|
||||
badhash = self.nodes[1].getblockhash(2)
|
||||
|
||||
print "Invalidate block 2 on node 0 and verify we reorg to node 0's original chain"
|
||||
print("Invalidate block 2 on node 0 and verify we reorg to node 0's original chain")
|
||||
self.nodes[0].invalidateblock(badhash)
|
||||
newheight = self.nodes[0].getblockcount()
|
||||
newhash = self.nodes[0].getbestblockhash()
|
||||
if (newheight != 4 or newhash != besthash):
|
||||
raise AssertionError("Wrong tip for node0, hash %s, height %d"%(newhash,newheight))
|
||||
|
||||
print "\nMake sure we won't reorg to a lower work chain:"
|
||||
print("\nMake sure we won't reorg to a lower work chain:")
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
print "Sync node 2 to node 1 so both have 6 blocks"
|
||||
print("Sync node 2 to node 1 so both have 6 blocks")
|
||||
sync_blocks(self.nodes[1:3])
|
||||
assert(self.nodes[2].getblockcount() == 6)
|
||||
print "Invalidate block 5 on node 1 so its tip is now at 4"
|
||||
print("Invalidate block 5 on node 1 so its tip is now at 4")
|
||||
self.nodes[1].invalidateblock(self.nodes[1].getblockhash(5))
|
||||
assert(self.nodes[1].getblockcount() == 4)
|
||||
print "Invalidate block 3 on node 2, so its tip is now 2"
|
||||
print("Invalidate block 3 on node 2, so its tip is now 2")
|
||||
self.nodes[2].invalidateblock(self.nodes[2].getblockhash(3))
|
||||
assert(self.nodes[2].getblockcount() == 2)
|
||||
print "..and then mine a block"
|
||||
print("..and then mine a block")
|
||||
self.nodes[2].generate(1)
|
||||
print "Verify all nodes are at the right height"
|
||||
print("Verify all nodes are at the right height")
|
||||
time.sleep(5)
|
||||
for i in xrange(3):
|
||||
print i,self.nodes[i].getblockcount()
|
||||
for i in range(3):
|
||||
print(i,self.nodes[i].getblockcount())
|
||||
assert(self.nodes[2].getblockcount() == 3)
|
||||
assert(self.nodes[0].getblockcount() == 4)
|
||||
node1height = self.nodes[1].getblockcount()
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
#
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import ComparisonTestFramework
|
||||
from test_framework.util import assert_equal
|
||||
from test_framework.comptool import TestManager, TestInstance
|
||||
|
@ -60,7 +58,7 @@ class InvalidBlockRequestTest(ComparisonTestFramework):
|
|||
Now we need that block to mature so we can spend the coinbase.
|
||||
'''
|
||||
test = TestInstance(sync_every_block=False)
|
||||
for i in xrange(100):
|
||||
for i in range(100):
|
||||
block = create_block(self.tip, create_coinbase(), self.block_time)
|
||||
block.solve()
|
||||
self.tip = block.sha256
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from decimal import Decimal
|
||||
from functools import reduce
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_greater_than, start_nodes, initialize_chain_clean, connect_nodes_bi
|
||||
|
||||
|
@ -40,11 +39,8 @@ class KeyImportExportTest (BitcoinTestFramework):
|
|||
|
||||
def verify_utxos(node, amounts):
|
||||
utxos = node.listunspent(1, 10**9, [addr])
|
||||
|
||||
def cmp_confirmations_high_to_low(a, b):
|
||||
return cmp(b["confirmations"], a["confirmations"])
|
||||
|
||||
utxos.sort(cmp_confirmations_high_to_low)
|
||||
utxos.sort(key=lambda x: x["confirmations"])
|
||||
utxos.reverse()
|
||||
|
||||
try:
|
||||
assert_equal(amounts, [utxo["amount"] for utxo in utxos])
|
||||
|
@ -66,7 +62,7 @@ class KeyImportExportTest (BitcoinTestFramework):
|
|||
verify_utxos(charlie, [])
|
||||
|
||||
# the amounts of each txn embodied which generates a single UTXO:
|
||||
amounts = map(Decimal, ['2.3', '3.7', '0.1', '0.5', '1.0', '0.19'])
|
||||
amounts = list(map(Decimal, ['2.3', '3.7', '0.1', '0.5', '1.0', '0.19']))
|
||||
|
||||
# Internal test consistency assertion:
|
||||
assert_greater_than(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
|
||||
# Add python-bitcoinrpc to module search path:
|
||||
|
||||
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.util import check_json_precision, initialize_chain, \
|
||||
start_nodes, start_node, stop_nodes, wait_bitcoinds, bitcoind_processes
|
||||
|
@ -51,7 +49,7 @@ def run_test(nodes, tmpdir):
|
|||
try:
|
||||
addr = nodes[0].getnewaddress()
|
||||
raise AssertionError('Keypool should be exhausted after one address')
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
assert(e.error['code']==-12)
|
||||
|
||||
# put three new keys in the keypool
|
||||
|
@ -71,7 +69,7 @@ def run_test(nodes, tmpdir):
|
|||
try:
|
||||
addr = nodes[0].getrawchangeaddress()
|
||||
raise AssertionError('Keypool should be exhausted after three addresses')
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
assert(e.error['code']==-12)
|
||||
|
||||
|
||||
|
@ -111,7 +109,7 @@ def main():
|
|||
print("JSONRPC error: "+e.error['message'])
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
except Exception as e:
|
||||
print("Unexpected exception caught during testing: "+str(sys.exc_info()[0]))
|
||||
print("Unexpected exception caught during testing: ", e.error['message'], str(sys.exc_info()[0]))
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
|
||||
if not options.nocleanup:
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
# 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 decimal import Decimal
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
#
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \
|
||||
EarlyDisconnectError, CInv, msg_inv, mininode_lock
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
@ -75,9 +73,9 @@ class TestManager(NodeConnCB):
|
|||
raise AssertionError("Error, test failed: block %064x requested more than once" % key)
|
||||
if total_requests > MAX_REQUESTS:
|
||||
raise AssertionError("Error, too many blocks (%d) requested" % total_requests)
|
||||
print "Round %d: success (total requests: %d)" % (count, total_requests)
|
||||
print("Round %d: success (total requests: %d)" % (count, total_requests))
|
||||
except AssertionError as e:
|
||||
print "TEST FAILED: ", e.args
|
||||
print("TEST FAILED: ", e.args)
|
||||
|
||||
self.disconnectOkay = True
|
||||
self.connection.disconnect_node()
|
||||
|
@ -90,7 +88,7 @@ class MaxBlocksInFlightTest(BitcoinTestFramework):
|
|||
help="Binary to test max block requests behavior")
|
||||
|
||||
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)
|
||||
|
||||
def setup_network(self):
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
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.util import (
|
||||
assert_equal,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal, assert_true, initialize_chain_clean,
|
||||
|
@ -31,7 +29,7 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
|
|||
self.sync_all
|
||||
|
||||
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)
|
||||
|
||||
def run_test(self):
|
||||
|
@ -47,8 +45,8 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
|
|||
node1_taddr = get_coinbase_address(self.nodes[1])
|
||||
node0_zaddr = self.nodes[0].z_getnewaddress('sapling')
|
||||
recipients = [{'address': node0_zaddr, 'amount': Decimal('10')}]
|
||||
myopid = self.nodes[1].z_sendmany(node1_taddr, recipients, 1, Decimal('0'))
|
||||
print wait_and_assert_operationid_status(self.nodes[1], myopid)
|
||||
myopid = self.nodes[1].z_sendmany(node1_taddr, recipients, 1, 0)
|
||||
print(wait_and_assert_operationid_status(self.nodes[1], myopid))
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
@ -132,7 +130,7 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
|
|||
|
||||
# Create a shielded Y transaction
|
||||
recipients = [{'address': node0_zaddr, 'amount': Decimal('10')}]
|
||||
myopid = self.nodes[0].z_sendmany(node0_zaddr, recipients, 1, Decimal('0'))
|
||||
myopid = self.nodes[0].z_sendmany(node0_zaddr, recipients, 1,0)
|
||||
shielded = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
assert(shielded != None)
|
||||
y_txids.append(shielded)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -8,8 +8,6 @@
|
|||
# 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.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, assert_raises, start_node, connect_nodes
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -8,8 +8,6 @@
|
|||
# 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.util import assert_equal, start_node
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -13,8 +13,6 @@
|
|||
# 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.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, assert_greater_than, assert_raises, \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# 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.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, \
|
||||
|
@ -37,7 +35,7 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
bob = self.nodes[2].getnewaddress()
|
||||
z_bob = self.nodes[2].z_getnewaddress('sapling')
|
||||
|
||||
print "Splitting network..."
|
||||
print("Splitting network...")
|
||||
self.split_network()
|
||||
|
||||
# Test dependent txs
|
||||
|
@ -46,7 +44,7 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
assert_equal(firstTxInfo["version"], 4)
|
||||
assert_equal(firstTxInfo["overwintered"], True)
|
||||
assert("expiryheight" in firstTxInfo)
|
||||
print "First tx expiry height:", firstTxInfo['expiryheight']
|
||||
print("First tx expiry height:", firstTxInfo['expiryheight'])
|
||||
# Mine first transaction
|
||||
self.nodes[0].generate(1)
|
||||
for outpoint in firstTxInfo['vout']:
|
||||
|
@ -60,19 +58,19 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
assert(rawTxSigned['complete'])
|
||||
secondTx = self.nodes[0].sendrawtransaction(rawTxSigned['hex'])
|
||||
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
|
||||
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)
|
||||
print "Connect nodes to force a reorg"
|
||||
print("Connect nodes to force a reorg")
|
||||
connect_nodes_bi(self.nodes,0,2)
|
||||
self.is_network_split = False
|
||||
print "Syncing blocks"
|
||||
print("Syncing blocks")
|
||||
sync_blocks(self.nodes)
|
||||
print "Ensure that both txs are dropped from mempool of node 0"
|
||||
print "Blockheight node 0:", self.nodes[0].getblockchaininfo()['blocks']
|
||||
print "Blockheight node 2:", self.nodes[2].getblockchaininfo()['blocks']
|
||||
print("Ensure that both txs are dropped from mempool of node 0")
|
||||
print("Blockheight node 0:", self.nodes[0].getblockchaininfo()['blocks'])
|
||||
print("Blockheight node 2:", self.nodes[2].getblockchaininfo()['blocks'])
|
||||
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
||||
assert_equal(set(self.nodes[2].getrawmempool()), set())
|
||||
|
||||
|
@ -84,10 +82,10 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
|
||||
# Get balance on node 0
|
||||
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"))
|
||||
|
||||
print "Splitting network..."
|
||||
print("Splitting network...")
|
||||
self.split_network()
|
||||
|
||||
# Create transactions
|
||||
|
@ -103,148 +101,148 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
assert_equal(rawtx["version"], 4)
|
||||
assert_equal(rawtx["overwintered"], True)
|
||||
assert_equal(rawtx["expiryheight"], blockheight + 1 + TX_EXPIRY_DELTA)
|
||||
print "Blockheight at persist_transparent & persist_shielded creation:", self.nodes[0].getblockchaininfo()['blocks']
|
||||
print "Expiryheight of persist_transparent:", rawtx['expiryheight']
|
||||
print("Blockheight at persist_transparent & persist_shielded creation:", self.nodes[0].getblockchaininfo()['blocks'])
|
||||
print("Expiryheight of persist_transparent:", rawtx['expiryheight'])
|
||||
# Verify shielded transaction is version 4 intended for Sapling branch
|
||||
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["overwintered"], True)
|
||||
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_shielded in self.nodes[0].getrawmempool())
|
||||
assert_equal(set(self.nodes[2].getrawmempool()), set())
|
||||
print "mempool node 0:", self.nodes[0].getrawmempool()
|
||||
print "mempool node 2:", self.nodes[2].getrawmempool()
|
||||
print("mempool node 0:", self.nodes[0].getrawmempool())
|
||||
print("mempool node 2:", self.nodes[2].getrawmempool())
|
||||
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
|
||||
self.nodes[0].generate(1)
|
||||
print "Node 0 generated 1 block"
|
||||
print "Node 0 height:", self.nodes[0].getblockchaininfo()['blocks']
|
||||
print "Node 2 height:", self.nodes[2].getblockchaininfo()['blocks']
|
||||
print("Node 0 generated 1 block")
|
||||
print("Node 0 height:", self.nodes[0].getblockchaininfo()['blocks'])
|
||||
print("Node 2 height:", self.nodes[2].getblockchaininfo()['blocks'])
|
||||
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())
|
||||
|
||||
print "Mine 2 competing blocks on Node 2..."
|
||||
print("Mine 2 competing blocks on Node 2...")
|
||||
blocks = self.nodes[2].generate(2)
|
||||
for block in blocks:
|
||||
blk = self.nodes[2].getblock(block)
|
||||
print "Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"])
|
||||
print "Connect nodes to force a reorg"
|
||||
print("Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]))
|
||||
print("Connect nodes to force a reorg")
|
||||
connect_nodes_bi(self.nodes,0,2)
|
||||
self.is_network_split = False
|
||||
|
||||
print "Syncing blocks"
|
||||
print("Syncing blocks")
|
||||
sync_blocks(self.nodes)
|
||||
|
||||
print "Ensure that txs are back in mempool of node 0"
|
||||
print "Blockheight node 0:", self.nodes[0].getblockchaininfo()['blocks']
|
||||
print "Blockheight node 2:", self.nodes[2].getblockchaininfo()['blocks']
|
||||
print "mempool node 0: ", self.nodes[0].getrawmempool()
|
||||
print "mempool node 2: ", self.nodes[2].getrawmempool()
|
||||
print("Ensure that txs are back in mempool of node 0")
|
||||
print("Blockheight node 0:", self.nodes[0].getblockchaininfo()['blocks'])
|
||||
print("Blockheight node 2:", self.nodes[2].getblockchaininfo()['blocks'])
|
||||
print("mempool node 0: ", self.nodes[0].getrawmempool())
|
||||
print("mempool node 2: ", self.nodes[2].getrawmempool())
|
||||
assert(persist_transparent in self.nodes[0].getrawmempool())
|
||||
assert(persist_shielded in self.nodes[0].getrawmempool())
|
||||
bal = self.nodes[0].z_gettotalbalance()
|
||||
# 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)
|
||||
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
||||
sync_blocks(self.nodes)
|
||||
|
||||
print "Splitting network..."
|
||||
print("Splitting 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)
|
||||
persist_shielded_2 = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
persist_transparent_2 = self.nodes[0].sendtoaddress(bob, 0.01)
|
||||
rawtx_trans = self.nodes[0].getrawtransaction(persist_transparent_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 2 at persist_transparent_2 creation:", self.nodes[2].getblockchaininfo()['blocks']
|
||||
print "Expiryheight of persist_transparent_2:", rawtx_trans['expiryheight']
|
||||
print "Expiryheight of persist_shielded_2:", rawtx_shield['expiryheight']
|
||||
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("Expiryheight of persist_transparent_2:", rawtx_trans['expiryheight'])
|
||||
print("Expiryheight of persist_shielded_2:", rawtx_shield['expiryheight'])
|
||||
blocks = self.nodes[2].generate(4)
|
||||
for block in blocks:
|
||||
blk = self.nodes[2].getblock(block)
|
||||
print "Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"])
|
||||
print "Connect nodes to force a reorg"
|
||||
print("Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]))
|
||||
print("Connect nodes to force a reorg")
|
||||
connect_nodes_bi(self.nodes, 0, 2)
|
||||
self.is_network_split = False
|
||||
sync_blocks(self.nodes)
|
||||
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 2:", self.nodes[2].getblockchaininfo()['blocks']
|
||||
print "mempool node 0: ", self.nodes[0].getrawmempool()
|
||||
print "mempool node 2: ", self.nodes[2].getrawmempool()
|
||||
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 2:", self.nodes[2].getblockchaininfo()['blocks'])
|
||||
print("mempool node 0: ", self.nodes[0].getrawmempool())
|
||||
print("mempool node 2: ", self.nodes[2].getrawmempool())
|
||||
assert(persist_transparent_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()
|
||||
self.nodes[0].generate(1)
|
||||
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
||||
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()
|
||||
|
||||
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("\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())
|
||||
myopid = self.nodes[0].z_sendmany(z_alice, recipients)
|
||||
expire_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
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 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_shielded:", self.nodes[0].getrawtransaction(expire_shielded, 1)['expiryheight']
|
||||
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("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'])
|
||||
assert(expire_transparent in self.nodes[0].getrawmempool())
|
||||
assert(expire_shielded in self.nodes[0].getrawmempool())
|
||||
blocks = self.nodes[2].generate(1 + TX_EXPIRY_DELTA + 1)
|
||||
for block in blocks:
|
||||
blk = self.nodes[2].getblock(block)
|
||||
print "Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"])
|
||||
print "Connect nodes to force a reorg"
|
||||
print("Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]))
|
||||
print("Connect nodes to force a reorg")
|
||||
connect_nodes_bi(self.nodes, 0, 2)
|
||||
self.is_network_split = False
|
||||
sync_blocks(self.nodes)
|
||||
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 2: ", self.nodes[2].getrawmempool()
|
||||
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 2: ", self.nodes[2].getrawmempool())
|
||||
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()
|
||||
print "Balance after expire_shielded has expired: ", bal
|
||||
print("Balance after expire_shielded has expired: ", bal)
|
||||
assert_equal(Decimal(bal["private"]), Decimal("7.9999"))
|
||||
|
||||
print "Splitting network..."
|
||||
print("Splitting network...")
|
||||
self.split_network()
|
||||
|
||||
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("\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())
|
||||
myopid = self.nodes[0].z_sendmany(z_alice, recipients)
|
||||
expire_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
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 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_shielded:", self.nodes[0].getrawtransaction(expire_shielded, 1)['expiryheight']
|
||||
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("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'])
|
||||
assert(expire_transparent 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)
|
||||
for block in blocks:
|
||||
blk = self.nodes[2].getblock(block)
|
||||
print "Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"])
|
||||
print "Connect nodes to force a reorg"
|
||||
print("Height: {0}, Mined block txs: {1}".format(blk["height"], blk["tx"]))
|
||||
print("Connect nodes to force a reorg")
|
||||
connect_nodes_bi(self.nodes, 0, 2)
|
||||
self.is_network_split = False
|
||||
sync_blocks(self.nodes)
|
||||
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 2: ", self.nodes[2].getrawmempool()
|
||||
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 2: ", self.nodes[2].getrawmempool())
|
||||
assert(expire_transparent in self.nodes[0].getrawmempool())
|
||||
assert(expire_shielded in self.nodes[0].getrawmempool())
|
||||
assert(expire_transparent not in self.nodes[2].getrawmempool())
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -56,7 +57,7 @@ class MergeToAddressHelper:
|
|||
test.sync_all()
|
||||
|
||||
def run_test(self, test):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
|
||||
test.nodes[0].generate(1)
|
||||
do_not_shield_taddr = test.nodes[0].getnewaddress()
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from decimal import Decimal
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, get_coinbase_address, \
|
||||
|
@ -21,7 +19,7 @@ class MergeToAddressMixedNotes(BitcoinTestFramework):
|
|||
initialize_chain_clean(self.options.tmpdir, 4)
|
||||
|
||||
def run_test(self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
self.nodes[0].generate(102)
|
||||
self.sync_all()
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from mergetoaddress_helper import MergeToAddressHelper
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from mergetoaddress_helper import MergeToAddressHelper
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# 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
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
|
@ -38,7 +36,7 @@ class MerkleBlockTest(BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test(self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
self.nodes[0].generate(105)
|
||||
self.sync_all()
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2015 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
@ -12,18 +12,11 @@ from test_framework.util import (
|
|||
assert_equal,
|
||||
initialize_chain,
|
||||
start_nodes,
|
||||
str_to_b64str,
|
||||
)
|
||||
import base64
|
||||
import os
|
||||
|
||||
try:
|
||||
import http.client as httplib
|
||||
except ImportError:
|
||||
import httplib
|
||||
try:
|
||||
import urllib.parse as urlparse
|
||||
except ImportError:
|
||||
import urlparse
|
||||
from http.client import HTTPConnection
|
||||
from urllib.parse import urlparse
|
||||
|
||||
class HTTPBasicsTest (BitcoinTestFramework):
|
||||
def setup_nodes(self):
|
||||
|
@ -44,7 +37,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||
##################################################
|
||||
# Check correctness of the rpcauth config option #
|
||||
##################################################
|
||||
url = urlparse.urlparse(self.nodes[0].url)
|
||||
url = urlparse(self.nodes[0].url)
|
||||
|
||||
#Old authpair
|
||||
authpair = url.username + ':' + url.password
|
||||
|
@ -58,9 +51,9 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||
password2 = "8/F3uMDw4KSEbw96U3CA1C4X05dkHDN2BPFjTgZW4KI="
|
||||
authpairnew = "rt:"+password
|
||||
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpair)}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
|
||||
|
||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
||||
conn = HTTPConnection(url.hostname, url.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
resp = conn.getresponse()
|
||||
|
@ -68,9 +61,9 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||
conn.close()
|
||||
|
||||
#Use new authpair to confirm both work
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpairnew)}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
||||
|
||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
||||
conn = HTTPConnection(url.hostname, url.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
resp = conn.getresponse()
|
||||
|
@ -79,9 +72,9 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||
|
||||
#Wrong login name with rt's password
|
||||
authpairnew = "rtwrong:"+password
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpairnew)}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
||||
|
||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
||||
conn = HTTPConnection(url.hostname, url.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
resp = conn.getresponse()
|
||||
|
@ -90,9 +83,9 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||
|
||||
#Wrong password for rt
|
||||
authpairnew = "rt:"+password+"wrong"
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpairnew)}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
||||
|
||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
||||
conn = HTTPConnection(url.hostname, url.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
resp = conn.getresponse()
|
||||
|
@ -101,9 +94,9 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||
|
||||
#Correct for rt2
|
||||
authpairnew = "rt2:"+password2
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpairnew)}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
||||
|
||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
||||
conn = HTTPConnection(url.hostname, url.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
resp = conn.getresponse()
|
||||
|
@ -112,9 +105,9 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
|||
|
||||
#Wrong password for rt2
|
||||
authpairnew = "rt2:"+password2+"wrong"
|
||||
headers = {"Authorization": "Basic " + base64.b64encode(authpairnew)}
|
||||
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
||||
|
||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
||||
conn = HTTPConnection(url.hostname, url.port)
|
||||
conn.connect()
|
||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||
resp = conn.getresponse()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,17 +7,11 @@
|
|||
# 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.util import assert_equal, connect_nodes_bi, p2p_port
|
||||
|
||||
import time
|
||||
|
||||
try:
|
||||
import urllib.parse as urlparse
|
||||
except ImportError:
|
||||
import urlparse
|
||||
from urllib.parse import urlparse
|
||||
|
||||
class NodeHandlingTest (BitcoinTestFramework):
|
||||
def run_test(self):
|
||||
|
@ -51,7 +45,7 @@ class NodeHandlingTest (BitcoinTestFramework):
|
|||
###########################
|
||||
# RPC disconnectnode test #
|
||||
###########################
|
||||
url = urlparse.urlparse(self.nodes[1].url)
|
||||
url = urlparse(self.nodes[1].url)
|
||||
self.nodes[0].disconnectnode(url.hostname+":"+str(p2p_port(1)))
|
||||
time.sleep(2) #disconnecting a node needs a little bit of time
|
||||
for node in self.nodes[0].getpeerinfo():
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
#
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.mininode import CBlockHeader, CInv, NodeConn, NodeConnCB, \
|
||||
NetworkThread, msg_block, msg_headers, msg_inv, msg_ping, msg_pong, \
|
||||
mininode_lock
|
||||
|
@ -153,13 +151,13 @@ class AcceptBlockTest(BitcoinTestFramework):
|
|||
|
||||
# 1. Have both nodes mine a block (leave IBD)
|
||||
[ n.generate(1) for n in self.nodes ]
|
||||
tips = [ int ("0x" + n.getbestblockhash() + "L", 0) for n in self.nodes ]
|
||||
tips = [ int ("0x" + n.getbestblockhash(), 0) for n in self.nodes ]
|
||||
|
||||
# 2. Send one block that builds on each tip.
|
||||
# This should be accepted.
|
||||
blocks_h2 = [] # the height 2 blocks on each node's chain
|
||||
block_time = time.time() + 1
|
||||
for i in xrange(2):
|
||||
for i in range(2):
|
||||
blocks_h2.append(create_block(tips[i], create_coinbase(), block_time))
|
||||
blocks_h2[i].solve()
|
||||
block_time += 1
|
||||
|
@ -169,11 +167,11 @@ class AcceptBlockTest(BitcoinTestFramework):
|
|||
[ x.sync_with_ping() for x in [test_node, white_node] ]
|
||||
assert_equal(self.nodes[0].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.
|
||||
blocks_h2f = [] # Blocks at height 2 that fork off the main chain
|
||||
for i in xrange(2):
|
||||
for i in range(2):
|
||||
blocks_h2f.append(create_block(tips[i], create_coinbase(), blocks_h2[i].nTime+1))
|
||||
blocks_h2f[i].solve()
|
||||
test_node.send_message(msg_block(blocks_h2f[0]))
|
||||
|
@ -188,11 +186,11 @@ class AcceptBlockTest(BitcoinTestFramework):
|
|||
if x['hash'] == blocks_h2f[1].hash:
|
||||
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.
|
||||
blocks_h3 = []
|
||||
for i in xrange(2):
|
||||
for i in range(2):
|
||||
blocks_h3.append(create_block(blocks_h2f[i].sha256, create_coinbase(), blocks_h2f[i].nTime+1))
|
||||
blocks_h3[i].solve()
|
||||
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.
|
||||
try:
|
||||
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:
|
||||
raise AssertionError("Unrequested more work block was not processed")
|
||||
|
||||
# Node1 should have accepted and reorged.
|
||||
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
|
||||
# the last (height-too-high) on node0. Node1 should process the tip if
|
||||
|
@ -222,8 +220,8 @@ class AcceptBlockTest(BitcoinTestFramework):
|
|||
tips = blocks_h3
|
||||
headers_message = msg_headers()
|
||||
all_blocks = [] # node0's blocks
|
||||
for j in xrange(2):
|
||||
for i in xrange(288):
|
||||
for j in range(2):
|
||||
for i in range(288):
|
||||
next_block = create_block(tips[j].sha256, create_coinbase(), tips[j].nTime+1)
|
||||
next_block.solve()
|
||||
if j==0:
|
||||
|
@ -241,7 +239,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
|||
raise AssertionError("Unrequested block too far-ahead should have been ignored")
|
||||
except:
|
||||
if x == all_blocks[287]:
|
||||
print "Unrequested block too far-ahead not processed"
|
||||
print("Unrequested block too far-ahead not processed")
|
||||
else:
|
||||
raise AssertionError("Unrequested block with more work should have been accepted")
|
||||
|
||||
|
@ -251,7 +249,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
|||
try:
|
||||
white_node.sync_with_ping()
|
||||
self.nodes[1].getblock(tips[1].hash)
|
||||
print "Unrequested block far ahead of tip accepted from whitelisted peer"
|
||||
print("Unrequested block far ahead of tip accepted from whitelisted peer")
|
||||
except:
|
||||
raise AssertionError("Unrequested block from whitelisted peer not accepted")
|
||||
|
||||
|
@ -267,7 +265,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
|||
# a getdata request for this block.
|
||||
test_node.sync_with_ping()
|
||||
assert_equal(self.nodes[0].getblockcount(), 2)
|
||||
print "Unrequested block that would complete more-work chain was ignored"
|
||||
print("Unrequested block that would complete more-work chain was ignored")
|
||||
|
||||
# 6. Try to get node to request the missing block.
|
||||
# Poke the node with an inv for block at height 3 and see if that
|
||||
|
@ -283,14 +281,14 @@ class AcceptBlockTest(BitcoinTestFramework):
|
|||
|
||||
# Check that the getdata includes the right block
|
||||
assert_equal(getdata.inv[0].hash, blocks_h2f[0].sha256)
|
||||
print "Inv at tip triggered getdata for unprocessed block"
|
||||
print("Inv at tip triggered getdata for unprocessed block")
|
||||
|
||||
# 7. Send the missing block for the third time (now it is requested)
|
||||
test_node.send_message(msg_block(blocks_h2f[0]))
|
||||
|
||||
test_node.sync_with_ping()
|
||||
assert_equal(self.nodes[0].getblockcount(), 290)
|
||||
print "Successfully reorged to longer chain from non-whitelisted peer"
|
||||
print("Successfully reorged to longer chain from non-whitelisted peer")
|
||||
|
||||
[ c.disconnect_node() for c in connections ]
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \
|
||||
msg_filteradd, msg_filterclear, mininode_lock, SAPLING_PROTO_VERSION
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
@ -48,7 +46,7 @@ class TestNode(NodeConnCB):
|
|||
class NodeBloomTest(BitcoinTestFramework):
|
||||
|
||||
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)
|
||||
|
||||
def setup_network(self):
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.mininode import (
|
||||
NodeConn,
|
||||
NodeConnCB,
|
||||
|
@ -54,7 +52,7 @@ class TestManager(NodeConnCB):
|
|||
class NUPeerManagementTest(BitcoinTestFramework):
|
||||
|
||||
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)
|
||||
|
||||
def setup_network(self):
|
||||
|
@ -70,7 +68,7 @@ class NUPeerManagementTest(BitcoinTestFramework):
|
|||
|
||||
# Launch Sprout, Overwinter, and Sapling mininodes
|
||||
nodes = []
|
||||
for x in xrange(10):
|
||||
for x in range(10):
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
||||
test, "regtest", SPROUT_PROTO_VERSION))
|
||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.mininode import NodeConn, NetworkThread, CInv, \
|
||||
msg_mempool, msg_getdata, msg_tx, mininode_lock, SAPLING_PROTO_VERSION
|
||||
|
@ -13,13 +11,11 @@ from test_framework.util import assert_equal, connect_nodes_bi, fail, \
|
|||
initialize_chain_clean, p2p_port, start_nodes, sync_blocks, sync_mempools
|
||||
from tx_expiry_helper import TestNode, create_transaction
|
||||
|
||||
from binascii import hexlify
|
||||
|
||||
|
||||
class TxExpiringSoonTest(BitcoinTestFramework):
|
||||
|
||||
def setup_chain(self):
|
||||
print "Initializing test directory " + self.options.tmpdir
|
||||
print("Initializing test directory " + self.options.tmpdir)
|
||||
initialize_chain_clean(self.options.tmpdir, 3)
|
||||
|
||||
def setup_network(self):
|
||||
|
@ -165,7 +161,7 @@ class TxExpiringSoonTest(BitcoinTestFramework):
|
|||
|
||||
# Confirm tx2 cannot be submitted to a mempool because it is expiring soon.
|
||||
try:
|
||||
rawtx2 = hexlify(tx2.serialize())
|
||||
rawtx2 = tx2.serialize().hex()
|
||||
self.nodes[2].sendrawtransaction(rawtx2)
|
||||
fail("Sending transaction should have failed")
|
||||
except JSONRPCException as e:
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.mininode import NodeConn, NetworkThread, \
|
||||
msg_tx, SAPLING_PROTO_VERSION
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
@ -18,7 +16,7 @@ import time
|
|||
class TxExpiryDoSTest(BitcoinTestFramework):
|
||||
|
||||
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)
|
||||
|
||||
def setup_network(self):
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
|
@ -34,7 +32,7 @@ class PaymentDisclosureTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test (self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
|
||||
self.nodes[0].generate(4)
|
||||
self.sync_all()
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_node, connect_nodes
|
||||
|
@ -31,7 +29,7 @@ class PrioritiseTransactionTest (BitcoinTestFramework):
|
|||
def run_test (self):
|
||||
# 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)
|
||||
|
||||
base_fee = self.nodes[0].getnetworkinfo()['relayfee']
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -13,8 +13,6 @@
|
|||
# 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.util import assert_equal, bytes_to_hex_str, \
|
||||
start_nodes
|
||||
|
@ -37,7 +35,7 @@ class Server(MessagingHandler):
|
|||
self.txidseq = -1
|
||||
|
||||
def on_start(self, event):
|
||||
print "Proton listening on:", self.url
|
||||
print("Proton listening on:", self.url)
|
||||
self.container = event.container
|
||||
self.acceptor = event.container.listen(self.url)
|
||||
|
||||
|
@ -91,9 +89,9 @@ class ProtonTest (BitcoinTestFramework):
|
|||
baseheight = self.nodes[0].getblockcount() # 200 blocks already mined
|
||||
|
||||
# generate some blocks
|
||||
self.nodes[0].generate(self.numblocks/2)
|
||||
self.nodes[0].generate(self.numblocks//2)
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(self.numblocks/2)
|
||||
self.nodes[1].generate(self.numblocks//2)
|
||||
self.sync_all()
|
||||
|
||||
# wait for server to finish
|
||||
|
@ -106,7 +104,7 @@ class ProtonTest (BitcoinTestFramework):
|
|||
assert_equal(len(self.server.txids), self.numblocks)
|
||||
|
||||
# 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
|
||||
blockhash = self.nodes[0].getblockhash(height)
|
||||
assert_equal(blockhash, self.server.blockhashes[i])
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2015 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
import socket
|
||||
import os
|
||||
|
||||
|
@ -58,7 +56,7 @@ class ProxyTest(BitcoinTestFramework):
|
|||
self.conf3.unauth = True
|
||||
self.conf3.auth = True
|
||||
else:
|
||||
print "Warning: testing without local IPv6 support"
|
||||
print("Warning: testing without local IPv6 support")
|
||||
|
||||
self.serv1 = Socks5Server(self.conf1)
|
||||
self.serv1.start()
|
||||
|
@ -89,7 +87,7 @@ class ProxyTest(BitcoinTestFramework):
|
|||
assert(isinstance(cmd, Socks5Command))
|
||||
# Note: bitcoind's SOCKS5 implementation only sends atyp DOMAINNAME, even if connecting directly to IPv4/IPv6
|
||||
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
|
||||
assert_equal(cmd.addr, "15.61.23.23")
|
||||
assert_equal(cmd.addr, b"15.61.23.23")
|
||||
assert_equal(cmd.port, 1234)
|
||||
if not auth:
|
||||
assert_equal(cmd.username, None)
|
||||
|
@ -103,7 +101,7 @@ class ProxyTest(BitcoinTestFramework):
|
|||
assert(isinstance(cmd, Socks5Command))
|
||||
# Note: bitcoind's SOCKS5 implementation only sends atyp DOMAINNAME, even if connecting directly to IPv4/IPv6
|
||||
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
|
||||
assert_equal(cmd.addr, "1233:3432:2434:2343:3234:2345:6546:4534")
|
||||
assert_equal(cmd.addr, b"1233:3432:2434:2343:3234:2345:6546:4534")
|
||||
assert_equal(cmd.port, 5443)
|
||||
if not auth:
|
||||
assert_equal(cmd.username, None)
|
||||
|
@ -116,7 +114,7 @@ class ProxyTest(BitcoinTestFramework):
|
|||
cmd = proxies[2].queue.get()
|
||||
assert(isinstance(cmd, Socks5Command))
|
||||
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
|
||||
assert_equal(cmd.addr, "bitcoinostk4e4re.onion")
|
||||
assert_equal(cmd.addr, b"bitcoinostk4e4re.onion")
|
||||
assert_equal(cmd.port, 8333)
|
||||
if not auth:
|
||||
assert_equal(cmd.username, None)
|
||||
|
@ -128,7 +126,7 @@ class ProxyTest(BitcoinTestFramework):
|
|||
cmd = proxies[3].queue.get()
|
||||
assert(isinstance(cmd, Socks5Command))
|
||||
assert_equal(cmd.atyp, AddressType.DOMAINNAME)
|
||||
assert_equal(cmd.addr, "node.noumenon")
|
||||
assert_equal(cmd.addr, b"node.noumenon")
|
||||
assert_equal(cmd.port, 8333)
|
||||
if not auth:
|
||||
assert_equal(cmd.username, None)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -11,8 +11,6 @@
|
|||
# This test takes 30 mins or more (up to 2 hours)
|
||||
# ********
|
||||
|
||||
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.authproxy import JSONRPCException
|
||||
from test_framework.util import initialize_chain_clean, start_node, \
|
||||
|
@ -35,11 +33,11 @@ class PruneTest(BitcoinTestFramework):
|
|||
|
||||
# create one script_pubkey
|
||||
script_pubkey = "6a4d0200" #OP_RETURN OP_PUSH2 512 bytes
|
||||
for i in xrange (512):
|
||||
for i in range (512):
|
||||
script_pubkey = script_pubkey + "01"
|
||||
# concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change
|
||||
self.txouts = "81"
|
||||
for k in xrange(128):
|
||||
for k in range(128):
|
||||
# add txout value
|
||||
self.txouts = self.txouts + "0000000000000000"
|
||||
# add length of script_pubkey
|
||||
|
@ -81,7 +79,7 @@ class PruneTest(BitcoinTestFramework):
|
|||
sync_blocks(self.nodes[0:2])
|
||||
self.nodes[0].generate(150)
|
||||
# Then mine enough full blocks to create more than 550MB of data
|
||||
for i in xrange(645):
|
||||
for i in range(645):
|
||||
self.mine_full_block(self.nodes[0], self.address[0])
|
||||
|
||||
sync_blocks(self.nodes[0:3])
|
||||
|
@ -89,11 +87,11 @@ class PruneTest(BitcoinTestFramework):
|
|||
def test_height_min(self):
|
||||
if not os.path.isfile(self.prunedir+"blk00000.dat"):
|
||||
raise AssertionError("blk00000.dat is missing, pruning too early")
|
||||
print "Success"
|
||||
print "Though we're already using more than 550MB, current usage:", calc_usage(self.prunedir)
|
||||
print "Mining 25 more blocks should cause the first block file to be pruned"
|
||||
print("Success")
|
||||
print("Though we're already using more than 550MB, current usage:", calc_usage(self.prunedir))
|
||||
print("Mining 25 more blocks should cause the first block file to be pruned")
|
||||
# Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this
|
||||
for i in xrange(25):
|
||||
for i in range(25):
|
||||
self.mine_full_block(self.nodes[0],self.address[0])
|
||||
|
||||
waitstart = time.time()
|
||||
|
@ -102,17 +100,17 @@ class PruneTest(BitcoinTestFramework):
|
|||
if time.time() - waitstart > 10:
|
||||
raise AssertionError("blk00000.dat not pruned when it should be")
|
||||
|
||||
print "Success"
|
||||
print("Success")
|
||||
usage = calc_usage(self.prunedir)
|
||||
print "Usage should be below target:", usage
|
||||
print("Usage should be below target:", usage)
|
||||
if (usage > 550):
|
||||
raise AssertionError("Pruning target not being met")
|
||||
|
||||
def create_chain_with_staleblocks(self):
|
||||
# Create stale blocks in manageable sized chunks
|
||||
print "Mine 24 (stale) blocks on Node 1, followed by 25 (main chain) block reorg from Node 0, for 12 rounds"
|
||||
print("Mine 24 (stale) blocks on Node 1, followed by 25 (main chain) block reorg from Node 0, for 12 rounds")
|
||||
|
||||
for j in xrange(12):
|
||||
for j in range(12):
|
||||
# Disconnect node 0 so it can mine a longer reorg chain without knowing about node 1's soon-to-be-stale chain
|
||||
# Node 2 stays connected, so it hears about the stale blocks and then reorg's when node0 reconnects
|
||||
# Stopping node 0 also clears its mempool, so it doesn't have node1's transactions to accidentally mine
|
||||
|
@ -120,7 +118,7 @@ class PruneTest(BitcoinTestFramework):
|
|||
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900)
|
||||
# Mine 24 blocks in node 1
|
||||
self.utxo = self.nodes[1].listunspent()
|
||||
for i in xrange(24):
|
||||
for i in range(24):
|
||||
if j == 0:
|
||||
self.mine_full_block(self.nodes[1],self.address[1])
|
||||
else:
|
||||
|
@ -128,7 +126,7 @@ class PruneTest(BitcoinTestFramework):
|
|||
|
||||
# Reorg back with 25 block chain from node 0
|
||||
self.utxo = self.nodes[0].listunspent()
|
||||
for i in xrange(25):
|
||||
for i in range(25):
|
||||
self.mine_full_block(self.nodes[0],self.address[0])
|
||||
|
||||
# Create connections in the order so both nodes can see the reorg at the same time
|
||||
|
@ -136,7 +134,7 @@ class PruneTest(BitcoinTestFramework):
|
|||
connect_nodes(self.nodes[2], 0)
|
||||
sync_blocks(self.nodes[0:3])
|
||||
|
||||
print "Usage can be over target because of high stale rate:", calc_usage(self.prunedir)
|
||||
print("Usage can be over target because of high stale rate:", calc_usage(self.prunedir))
|
||||
|
||||
def reorg_test(self):
|
||||
# Node 1 will mine a 300 block chain starting 287 blocks back from Node 0 and Node 2's tip
|
||||
|
@ -147,11 +145,11 @@ class PruneTest(BitcoinTestFramework):
|
|||
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
|
||||
|
||||
height = self.nodes[1].getblockcount()
|
||||
print "Current block height:", height
|
||||
print("Current block height:", height)
|
||||
|
||||
invalidheight = height-287
|
||||
badhash = self.nodes[1].getblockhash(invalidheight)
|
||||
print "Invalidating block at height:",invalidheight,badhash
|
||||
print("Invalidating block at height:",invalidheight,badhash)
|
||||
self.nodes[1].invalidateblock(badhash)
|
||||
|
||||
# We've now switched to our previously mined-24 block fork on node 1, but thats not what we want
|
||||
|
@ -163,29 +161,29 @@ class PruneTest(BitcoinTestFramework):
|
|||
curhash = self.nodes[1].getblockhash(invalidheight - 1)
|
||||
|
||||
assert(self.nodes[1].getblockcount() == invalidheight - 1)
|
||||
print "New best height", self.nodes[1].getblockcount()
|
||||
print("New best height", self.nodes[1].getblockcount())
|
||||
|
||||
# Reboot node1 to clear those giant tx's from mempool
|
||||
stop_node(self.nodes[1],1)
|
||||
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
|
||||
|
||||
print "Generating new longer chain of 300 more blocks"
|
||||
print("Generating new longer chain of 300 more blocks")
|
||||
self.nodes[1].generate(300)
|
||||
|
||||
print "Reconnect nodes"
|
||||
print("Reconnect nodes")
|
||||
connect_nodes(self.nodes[0], 1)
|
||||
connect_nodes(self.nodes[2], 1)
|
||||
sync_blocks(self.nodes[0:3])
|
||||
|
||||
print "Verify height on node 2:",self.nodes[2].getblockcount()
|
||||
print "Usage possibly still high bc of stale blocks in block files:", calc_usage(self.prunedir)
|
||||
print("Verify height on node 2:",self.nodes[2].getblockcount())
|
||||
print("Usage possibly still high bc of stale blocks in block files:", calc_usage(self.prunedir))
|
||||
|
||||
print "Mine 220 more blocks so we have requisite history (some blocks will be big and cause pruning of previous chain)"
|
||||
print("Mine 220 more blocks so we have requisite history (some blocks will be big and cause pruning of previous chain)")
|
||||
self.nodes[0].generate(220) #node 0 has many large tx's in its mempool from the disconnects
|
||||
sync_blocks(self.nodes[0:3])
|
||||
|
||||
usage = calc_usage(self.prunedir)
|
||||
print "Usage should be below target:", usage
|
||||
print("Usage should be below target:", usage)
|
||||
if (usage > 550):
|
||||
raise AssertionError("Pruning target not being met")
|
||||
|
||||
|
@ -197,7 +195,7 @@ class PruneTest(BitcoinTestFramework):
|
|||
self.nodes[2].getblock(self.forkhash)
|
||||
raise AssertionError("Old block wasn't pruned so can't test redownload")
|
||||
except JSONRPCException:
|
||||
print "Will need to redownload block",self.forkheight
|
||||
print("Will need to redownload block",self.forkheight)
|
||||
|
||||
# Verify that we have enough history to reorg back to the fork point
|
||||
# Although this is more than 288 blocks, because this chain was written more recently
|
||||
|
@ -221,14 +219,14 @@ class PruneTest(BitcoinTestFramework):
|
|||
# At this point node 2 is within 288 blocks of the fork point so it will preserve its ability to reorg
|
||||
if self.nodes[2].getblockcount() < self.mainchainheight:
|
||||
blocks_to_mine = first_reorg_height + 1 - self.mainchainheight
|
||||
print "Rewind node 0 to prev main chain to mine longer chain to trigger redownload. Blocks needed:", blocks_to_mine
|
||||
print("Rewind node 0 to prev main chain to mine longer chain to trigger redownload. Blocks needed:", blocks_to_mine)
|
||||
self.nodes[0].invalidateblock(curchainhash)
|
||||
assert(self.nodes[0].getblockcount() == self.mainchainheight)
|
||||
assert(self.nodes[0].getbestblockhash() == self.mainchainhash2)
|
||||
goalbesthash = self.nodes[0].generate(blocks_to_mine)[-1]
|
||||
goalbestheight = first_reorg_height + 1
|
||||
|
||||
print "Verify node 2 reorged back to the main chain, some blocks of which it had to redownload"
|
||||
print("Verify node 2 reorged back to the main chain, some blocks of which it had to redownload")
|
||||
waitstart = time.time()
|
||||
while self.nodes[2].getblockcount() < goalbestheight:
|
||||
time.sleep(0.1)
|
||||
|
@ -241,7 +239,7 @@ class PruneTest(BitcoinTestFramework):
|
|||
def mine_full_block(self, node, address):
|
||||
# Want to create a full block
|
||||
# We'll generate a 66k transaction below, and 14 of them is close to the 1MB block limit
|
||||
for j in xrange(14):
|
||||
for j in range(14):
|
||||
if len(self.utxo) < 14:
|
||||
self.utxo = node.listunspent()
|
||||
inputs=[]
|
||||
|
@ -265,8 +263,8 @@ class PruneTest(BitcoinTestFramework):
|
|||
|
||||
|
||||
def run_test(self):
|
||||
print "Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)"
|
||||
print "Mining a big blockchain of 995 blocks"
|
||||
print("Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)")
|
||||
print("Mining a big blockchain of 995 blocks")
|
||||
self.create_big_chain()
|
||||
# Chain diagram key:
|
||||
# * blocks on main chain
|
||||
|
@ -277,12 +275,12 @@ class PruneTest(BitcoinTestFramework):
|
|||
# Start by mining a simple chain that all nodes have
|
||||
# N0=N1=N2 **...*(995)
|
||||
|
||||
print "Check that we haven't started pruning yet because we're below PruneAfterHeight"
|
||||
print("Check that we haven't started pruning yet because we're below PruneAfterHeight")
|
||||
self.test_height_min()
|
||||
# Extend this chain past the PruneAfterHeight
|
||||
# N0=N1=N2 **...*(1020)
|
||||
|
||||
print "Check that we'll exceed disk space target if we have a very high stale block rate"
|
||||
print("Check that we'll exceed disk space target if we have a very high stale block rate")
|
||||
self.create_chain_with_staleblocks()
|
||||
# Disconnect N0
|
||||
# And mine a 24 block chain on N1 and a separate 25 block chain on N0
|
||||
|
@ -306,7 +304,7 @@ class PruneTest(BitcoinTestFramework):
|
|||
self.mainchainheight = self.nodes[2].getblockcount() #1320
|
||||
self.mainchainhash2 = self.nodes[2].getblockhash(self.mainchainheight)
|
||||
|
||||
print "Check that we can survive a 288 block reorg still"
|
||||
print("Check that we can survive a 288 block reorg still")
|
||||
(self.forkheight,self.forkhash) = self.reorg_test() #(1033, )
|
||||
# Now create a 288 block reorg by mining a longer chain on N1
|
||||
# First disconnect N1
|
||||
|
@ -339,7 +337,7 @@ class PruneTest(BitcoinTestFramework):
|
|||
# \
|
||||
# *...**(1320)
|
||||
|
||||
print "Test that we can rerequest a block we previously pruned if needed for a reorg"
|
||||
print("Test that we can rerequest a block we previously pruned if needed for a reorg")
|
||||
self.reorg_back()
|
||||
# Verify that N2 still has block 1033 on current chain (@), but not on main chain (*)
|
||||
# Invalidate 1033 on current chain (@) on N2 and we should be able to reorg to
|
||||
|
@ -359,7 +357,7 @@ class PruneTest(BitcoinTestFramework):
|
|||
#
|
||||
# N1 doesn't change because 1033 on main chain (*) is invalid
|
||||
|
||||
print "Done"
|
||||
print("Done")
|
||||
|
||||
if __name__ == '__main__':
|
||||
PruneTest().main()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -8,8 +8,6 @@
|
|||
# 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.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
|
@ -65,7 +63,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
errorString = ""
|
||||
try:
|
||||
rawtx = self.nodes[2].sendrawtransaction(rawtx['hex'])
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
|
||||
assert_equal("Missing inputs" in errorString, True);
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
# Exercise the listreceivedbyaddress 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 decimal import Decimal
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import wait_and_assert_operationid_status
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# 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.util import assert_equal, initialize_chain_clean, \
|
||||
start_node, stop_node, wait_bitcoinds
|
||||
|
@ -31,7 +29,7 @@ class ReindexTest(BitcoinTestFramework):
|
|||
wait_bitcoinds()
|
||||
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug", "-reindex", "-checkblockindex=1"])
|
||||
assert_equal(self.nodes[0].getblockcount(), 3)
|
||||
print "Success"
|
||||
print("Success")
|
||||
|
||||
if __name__ == '__main__':
|
||||
ReindexTest().main()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# 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.util import (
|
||||
check_node,
|
||||
|
@ -19,7 +17,7 @@ from time import sleep
|
|||
|
||||
def check_stopped(i, timeout=10):
|
||||
stopped = False
|
||||
for x in xrange(1, timeout):
|
||||
for x in range(1, timeout):
|
||||
ret = check_node(i)
|
||||
if ret is None:
|
||||
sleep(1)
|
||||
|
@ -36,39 +34,39 @@ class ReorgLimitTest(BitcoinTestFramework):
|
|||
|
||||
self.split_network()
|
||||
|
||||
print "Test the maximum-allowed reorg:"
|
||||
print "Mine 99 blocks on Node 0"
|
||||
print("Test the maximum-allowed reorg:")
|
||||
print("Mine 99 blocks on Node 0")
|
||||
self.nodes[0].generate(99)
|
||||
assert(self.nodes[0].getblockcount() == 299)
|
||||
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)
|
||||
assert(self.nodes[0].getblockcount() == 299)
|
||||
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)
|
||||
self.is_network_split = False
|
||||
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)
|
||||
|
||||
self.split_network()
|
||||
|
||||
print "Test the minimum-rejected reorg:"
|
||||
print "Mine 100 blocks on Node 0"
|
||||
print("Test the minimum-rejected reorg:")
|
||||
print("Mine 100 blocks on Node 0")
|
||||
self.nodes[0].generate(100)
|
||||
assert(self.nodes[0].getblockcount() == 400)
|
||||
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)
|
||||
assert(self.nodes[0].getblockcount() == 400)
|
||||
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)
|
||||
self.is_network_split = False
|
||||
# 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
|
||||
# to stop.
|
||||
|
||||
print "Check Node 0 is no longer running"
|
||||
print("Check Node 0 is no longer running")
|
||||
assert(check_stopped(0))
|
||||
|
||||
# Dummy stop to enable the test to tear down
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# Test REST 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.util import assert_equal, assert_greater_than, \
|
||||
initialize_chain_clean, start_nodes, connect_nodes_bi
|
||||
|
@ -16,17 +14,13 @@ from test_framework.util import assert_equal, assert_greater_than, \
|
|||
import struct
|
||||
import binascii
|
||||
import json
|
||||
import StringIO
|
||||
import io
|
||||
from codecs import encode
|
||||
from decimal import Decimal
|
||||
|
||||
try:
|
||||
import http.client as httplib
|
||||
except ImportError:
|
||||
import httplib
|
||||
try:
|
||||
import urllib.parse as urlparse
|
||||
except ImportError:
|
||||
import urlparse
|
||||
from http.client import HTTPConnection
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
def deser_uint256(f):
|
||||
r = 0
|
||||
|
@ -37,17 +31,17 @@ def deser_uint256(f):
|
|||
|
||||
# allows simple http get calls
|
||||
def http_get_call(host, port, path, response_object = 0):
|
||||
conn = httplib.HTTPConnection(host, port)
|
||||
conn = HTTPConnection(host, port)
|
||||
conn.request('GET', path)
|
||||
|
||||
if response_object:
|
||||
return conn.getresponse()
|
||||
|
||||
return conn.getresponse().read()
|
||||
return conn.getresponse().read().decode("utf-8")
|
||||
|
||||
# allows simple http post calls with a request body
|
||||
def http_post_call(host, port, path, requestdata = '', response_object = 0):
|
||||
conn = httplib.HTTPConnection(host, port)
|
||||
conn = HTTPConnection(host, port)
|
||||
conn.request('POST', path, requestdata)
|
||||
|
||||
if response_object:
|
||||
|
@ -71,8 +65,8 @@ class RESTTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test(self):
|
||||
url = urlparse.urlparse(self.nodes[0].url)
|
||||
print "Mining blocks..."
|
||||
url = urlparse(self.nodes[0].url)
|
||||
print("Mining blocks...")
|
||||
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
@ -151,11 +145,11 @@ class RESTTest (BitcoinTestFramework):
|
|||
binaryRequest += struct.pack("i", 0);
|
||||
|
||||
bin_response = http_post_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', binaryRequest)
|
||||
output = StringIO.StringIO()
|
||||
output = io.BytesIO()
|
||||
output.write(bin_response)
|
||||
output.seek(0)
|
||||
chainHeight = struct.unpack("i", output.read(4))[0]
|
||||
hashFromBinResponse = hex(deser_uint256(output))[2:].zfill(65).rstrip("L")
|
||||
hashFromBinResponse = hex(deser_uint256(output))[2:].zfill(64)
|
||||
|
||||
assert_equal(bb_hash, hashFromBinResponse) # check if getutxo's chaintip during calculation was fine
|
||||
assert_equal(chainHeight, 102) # chain height must be 102
|
||||
|
@ -247,7 +241,7 @@ class RESTTest (BitcoinTestFramework):
|
|||
assert_equal(response_hex.status, 200)
|
||||
assert_greater_than(int(response_hex.getheader('content-length')), 354)
|
||||
response_hex_str = response_hex.read()
|
||||
assert_equal(response_str.encode("hex")[0:354], response_hex_str[0:354])
|
||||
assert_equal(encode(response_str, "hex_codec")[0:354], response_hex_str[0:354])
|
||||
|
||||
# compare with hex block header
|
||||
response_header_hex = http_get_call(url.hostname, url.port, '/rest/headers/1/'+bb_hash+self.FORMAT_SEPARATOR+"hex", True)
|
||||
|
@ -255,7 +249,7 @@ class RESTTest (BitcoinTestFramework):
|
|||
assert_greater_than(int(response_header_hex.getheader('content-length')), 354)
|
||||
response_header_hex_str = response_header_hex.read()
|
||||
assert_equal(response_hex_str[0:354], response_header_hex_str[0:354])
|
||||
assert_equal(response_header_str.encode("hex")[0:354], response_header_hex_str[0:354])
|
||||
assert_equal(encode(response_header_str, "hex-codec")[0:354], response_header_hex_str[0:354])
|
||||
|
||||
# check json format
|
||||
block_json_string = http_get_call(url.hostname, url.port, '/rest/block/'+bb_hash+self.FORMAT_SEPARATOR+'json')
|
||||
|
@ -265,7 +259,7 @@ class RESTTest (BitcoinTestFramework):
|
|||
# compare with json block header
|
||||
response_header_json = http_get_call(url.hostname, url.port, '/rest/headers/1/'+bb_hash+self.FORMAT_SEPARATOR+"json", True)
|
||||
assert_equal(response_header_json.status, 200)
|
||||
response_header_json_str = response_header_json.read()
|
||||
response_header_json_str = response_header_json.read().decode('utf-8')
|
||||
json_obj = json.loads(response_header_json_str, parse_float=Decimal)
|
||||
assert_equal(len(json_obj), 1) # ensure that there is one header in the json response
|
||||
assert_equal(json_obj[0]['hash'], bb_hash) # request/response hash should be the same
|
||||
|
@ -289,7 +283,7 @@ class RESTTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
response_header_json = http_get_call(url.hostname, url.port, '/rest/headers/5/'+bb_hash+self.FORMAT_SEPARATOR+"json", True)
|
||||
assert_equal(response_header_json.status, 200)
|
||||
response_header_json_str = response_header_json.read()
|
||||
response_header_json_str = response_header_json.read().decode('utf-8')
|
||||
json_obj = json.loads(response_header_json_str)
|
||||
assert_equal(len(json_obj), 5) # now we should have 5 header objects
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_nodes, start_node, connect_nodes_bi, bitcoind_processes
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
|
||||
# Dependency: python-bitcoinrpc
|
||||
|
||||
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.util import assert_equal, check_json_precision, \
|
||||
initialize_chain, start_nodes, stop_nodes, wait_bitcoinds, \
|
||||
bitcoind_processes, rpc_port
|
||||
|
@ -59,7 +57,7 @@ def run_allowip_test(tmpdir, allow_ips, rpchost, rpcport):
|
|||
|
||||
|
||||
def run_test(tmpdir):
|
||||
assert(sys.platform == 'linux2') # due to OS-specific network stats queries, this test works only on Linux
|
||||
assert(sys.platform.startswith('linux')) # due to OS-specific network stats queries, this test works only on Linux
|
||||
# find the first non-loopback interface for testing
|
||||
non_loopback_ip = None
|
||||
for name,ip in all_interfaces():
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# 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.
|
||||
'''
|
||||
|
||||
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.comptool import TestInstance, TestManager
|
||||
from test_framework.mininode import NetworkThread
|
||||
|
@ -83,7 +81,7 @@ def ParseScriptFlags(flag_string):
|
|||
if x in flag_map:
|
||||
flags |= flag_map[x]
|
||||
else:
|
||||
print "Error: unrecognized script flag: ", x
|
||||
print("Error: unrecognized script flag: ", x)
|
||||
return flags
|
||||
|
||||
'''
|
||||
|
@ -107,7 +105,7 @@ def ParseScript(json_script):
|
|||
parsed_script += CScriptNum(int(x, 0))
|
||||
elif x.startswith("0x"):
|
||||
# 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))))
|
||||
elif x.startswith("'") and x.endswith("'") and len(x) >= 2:
|
||||
# Single-quoted string, pushed as data.
|
||||
|
@ -118,7 +116,7 @@ def ParseScript(json_script):
|
|||
if tryopname in OPCODES_BY_NAME:
|
||||
parsed_script += CScriptOp(OPCODES_BY_NAME["OP_" + x])
|
||||
else:
|
||||
print "ParseScript: error parsing '%s'" % x
|
||||
print("ParseScript: error parsing '%s'" % x)
|
||||
return ""
|
||||
return parsed_script
|
||||
|
||||
|
@ -177,7 +175,7 @@ class ScriptTest(ComparisonTestFramework):
|
|||
self.tip = block.sha256
|
||||
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)
|
||||
self.block_time += 1
|
||||
block.solve()
|
||||
|
@ -211,7 +209,7 @@ class ScriptTest(ComparisonTestFramework):
|
|||
Build out to 100 blocks total, maturing the coinbase.
|
||||
'''
|
||||
test = TestInstance(objects=[], sync_every_block=False, sync_every_tx=False)
|
||||
for i in xrange(100):
|
||||
for i in range(100):
|
||||
b = create_block(self.tip, create_coinbase(), self.block_time)
|
||||
b.solve()
|
||||
test.blocks_and_transactions.append([b, True])
|
||||
|
@ -243,7 +241,7 @@ class ScriptTest(ComparisonTestFramework):
|
|||
else:
|
||||
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)
|
||||
counter += 1
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from decimal import Decimal
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
|
@ -27,7 +25,7 @@ class ShorterBlockTimes(BitcoinTestFramework):
|
|||
initialize_chain_clean(self.options.tmpdir, 4)
|
||||
|
||||
def run_test(self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
self.nodes[0].generate(101)
|
||||
self.sync_all()
|
||||
|
||||
|
@ -36,8 +34,8 @@ class ShorterBlockTimes(BitcoinTestFramework):
|
|||
|
||||
node0_taddr = get_coinbase_address(self.nodes[0])
|
||||
node0_zaddr = self.nodes[0].z_getnewaddress('sapling')
|
||||
recipients = [{'address': node0_zaddr, 'amount': Decimal('10')}]
|
||||
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients, 1, Decimal('0'))
|
||||
recipients = [{'address': node0_zaddr, 'amount': Decimal('10.0')}]
|
||||
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients, 1, 0)
|
||||
txid = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
assert_equal(105, self.nodes[0].getrawtransaction(txid, 1)['expiryheight']) # Blossom activation - 1
|
||||
self.sync_all()
|
||||
|
@ -47,7 +45,7 @@ class ShorterBlockTimes(BitcoinTestFramework):
|
|||
|
||||
self.nodes[0].generate(2)
|
||||
self.sync_all()
|
||||
print "Mining last pre-Blossom blocks"
|
||||
print("Mining last pre-Blossom blocks")
|
||||
# Activate blossom
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
|
@ -55,14 +53,14 @@ class ShorterBlockTimes(BitcoinTestFramework):
|
|||
assert_equal(10, Decimal(self.nodes[1].getwalletinfo()['immature_balance']))
|
||||
|
||||
# After blossom activation the block reward will be halved
|
||||
print "Mining first Blossom block"
|
||||
print("Mining first Blossom block")
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
# Check that we received an additional Blossom mining reward
|
||||
assert_equal(15, self.nodes[1].getwalletinfo()['immature_balance'])
|
||||
|
||||
# Send and mine a transaction after activation
|
||||
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients, 1, Decimal('0'))
|
||||
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients, 1, 0)
|
||||
txid = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
assert_equal(147, self.nodes[0].getrawtransaction(txid, 1)['expiryheight']) # height + 1 + 40
|
||||
self.nodes[1].generate(1)
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
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):
|
||||
# Setup Methods
|
||||
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)
|
||||
|
||||
def setup_network(self):
|
||||
|
@ -19,7 +17,7 @@ class SignOfflineTest (BitcoinTestFramework):
|
|||
|
||||
# Tests
|
||||
def run_test(self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
self.nodes[0].generate(101)
|
||||
|
||||
offline_node = start_node(1, self.options.tmpdir, ["-maxconnections=0", "-nuparams=2bb40e60:10"])
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2015 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_nodes
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# Test fee estimation code
|
||||
#
|
||||
|
||||
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.util import start_node, connect_nodes, \
|
||||
sync_blocks, sync_mempools
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
#
|
||||
# Test spentindex generation and fetching for insightexplorer
|
||||
|
||||
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.authproxy import JSONRPCException
|
||||
|
||||
|
@ -81,7 +79,7 @@ class SpentIndexTest(BitcoinTestFramework):
|
|||
assert_equal(tx1['vin'][0]['value'], 10) # coinbase
|
||||
assert_equal(tx1['vin'][0]['valueSat'], 10*COIN)
|
||||
# we want the non-change (payment) output
|
||||
vout = filter(lambda o: o['value'] == 2, tx1['vout'])
|
||||
vout = list(filter(lambda o: o['value'] == 2, tx1['vout']))
|
||||
n = vout[0]['n']
|
||||
assert_equal(vout[0]['spentTxId'], txid2)
|
||||
assert_equal(vout[0]['spentIndex'], 0)
|
||||
|
@ -111,7 +109,7 @@ class SpentIndexTest(BitcoinTestFramework):
|
|||
try:
|
||||
self.nodes[1].getspentinfo({'txid': txid2, 'index': 0})
|
||||
fail('getspentinfo should have thrown an exception')
|
||||
except JSONRPCException, e:
|
||||
except JSONRPCException as e:
|
||||
assert_equal(e.error['message'], "Unable to get spent info")
|
||||
|
||||
block_hash_next = self.nodes[0].generate(1)
|
||||
|
@ -146,7 +144,7 @@ class SpentIndexTest(BitcoinTestFramework):
|
|||
|
||||
assert_equal(len(to_a_tx['outputs']), 2)
|
||||
# find the nonchange output, which is the payment to addr1
|
||||
out = filter(lambda o: o['satoshis'] == 2*COIN, to_a_tx['outputs'])
|
||||
out = list(filter(lambda o: o['satoshis'] == 2*COIN, to_a_tx['outputs']))
|
||||
assert_equal(len(out), 1)
|
||||
assert_equal(out[0]['address'], addr1)
|
||||
|
||||
|
@ -178,7 +176,7 @@ class SpentIndexTest(BitcoinTestFramework):
|
|||
|
||||
assert_equal(len(to_b_tx['outputs']), 2)
|
||||
# find the nonchange output, which is the payment to addr2
|
||||
out = filter(lambda o: o['satoshis'] == 1*COIN, to_b_tx['outputs'])
|
||||
out = list(filter(lambda o: o['satoshis'] == 1*COIN, to_b_tx['outputs']))
|
||||
assert_equal(len(out), 1)
|
||||
assert_equal(out[0]['address'], addr2)
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from decimal import Decimal
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, get_coinbase_address, \
|
||||
|
@ -101,7 +99,7 @@ class SproutSaplingMigration(BitcoinTestFramework):
|
|||
assert_equal(target_height, result['target_height'])
|
||||
assert_equal(1, result['result']['num_tx_created'])
|
||||
assert_equal(1, len(result['result']['migration_txids']))
|
||||
assert_true(result['result']['amount_migrated'] > Decimal('0'))
|
||||
assert_true(Decimal(result['result']['amount_migrated']) > Decimal('0'))
|
||||
|
||||
assert_equal(0, len(node.getrawmempool()), "mempool size at 495 % 500")
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
"""
|
||||
Copyright 2011 Jeff Garzik
|
||||
|
||||
|
@ -34,18 +33,12 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
|
||||
try:
|
||||
import http.client as httplib
|
||||
except ImportError:
|
||||
import httplib
|
||||
import base64
|
||||
import decimal
|
||||
import json
|
||||
import simplejson as json
|
||||
import logging
|
||||
try:
|
||||
import urllib.parse as urlparse
|
||||
except ImportError:
|
||||
import urlparse
|
||||
from http.client import HTTPConnection, HTTPSConnection, BadStatusLine
|
||||
from urllib.parse import urlparse
|
||||
|
||||
USER_AGENT = "AuthServiceProxy/0.1"
|
||||
|
||||
|
@ -58,23 +51,19 @@ class JSONRPCException(Exception):
|
|||
Exception.__init__(self)
|
||||
self.error = rpc_error
|
||||
|
||||
|
||||
def EncodeDecimal(o):
|
||||
if isinstance(o, decimal.Decimal):
|
||||
return round(o, 8)
|
||||
return str(o)
|
||||
raise TypeError(repr(o) + " is not JSON serializable")
|
||||
|
||||
class AuthServiceProxy(object):
|
||||
|
||||
class AuthServiceProxy():
|
||||
__id_count = 0
|
||||
|
||||
def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connection=None):
|
||||
self.__service_url = service_url
|
||||
self.__service_name = service_name
|
||||
self.__url = urlparse.urlparse(service_url)
|
||||
if self.__url.port is None:
|
||||
port = 80
|
||||
else:
|
||||
port = self.__url.port
|
||||
self.__url = urlparse(service_url)
|
||||
(user, passwd) = (self.__url.username, self.__url.password)
|
||||
try:
|
||||
user = user.encode('utf8')
|
||||
|
@ -87,17 +76,19 @@ class AuthServiceProxy(object):
|
|||
authpair = user + b':' + passwd
|
||||
self.__auth_header = b'Basic ' + base64.b64encode(authpair)
|
||||
|
||||
if connection:
|
||||
# Callables re-use the connection of the original proxy
|
||||
self.__conn = connection
|
||||
elif self.__url.scheme == 'https':
|
||||
self.__conn = httplib.HTTPSConnection(self.__url.hostname, port,
|
||||
None, None, False,
|
||||
timeout)
|
||||
else:
|
||||
self.__conn = httplib.HTTPConnection(self.__url.hostname, port,
|
||||
False, timeout)
|
||||
self.timeout = timeout
|
||||
self._set_conn(connection)
|
||||
|
||||
def _set_conn(self, connection=None):
|
||||
port = 80 if self.__url.port is None else self.__url.port
|
||||
if connection:
|
||||
self.__conn = connection
|
||||
self.timeout = connection.timeout
|
||||
elif self.__url.scheme == 'https':
|
||||
self.__conn = HTTPSConnection(self.__url.hostname, port, timeout=self.timeout)
|
||||
else:
|
||||
self.__conn = HTTPConnection(self.__url.hostname, port, timeout=self.timeout)
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name.startswith('__') and name.endswith('__'):
|
||||
# Python internal stuff
|
||||
|
@ -120,12 +111,11 @@ class AuthServiceProxy(object):
|
|||
return self._get_response()
|
||||
except Exception as e:
|
||||
# If connection was closed, try again.
|
||||
# Python 2.7 error message was changed in https://github.com/python/cpython/pull/2825
|
||||
# Python 3.5+ raises BrokenPipeError instead of BadStatusLine when the connection was reset.
|
||||
# ConnectionResetError happens on FreeBSD with Python 3.4.
|
||||
# These classes don't exist in Python 2.x, so we can't refer to them directly.
|
||||
if ((isinstance(e, httplib.BadStatusLine)
|
||||
and e.line in ("''", "No status line received - the server has closed the connection"))
|
||||
# This can be simplified now that we depend on Python 3 (previously, we could not
|
||||
# refer to BrokenPipeError or ConnectionResetError which did not exist on Python 2)
|
||||
if ((isinstance(e, BadStatusLine) and e.line == "''")
|
||||
or e.__class__.__name__ in ('BrokenPipeError', 'ConnectionResetError')):
|
||||
self.__conn.close()
|
||||
self.__conn.request(method, path, postdata, headers)
|
||||
|
@ -161,6 +151,11 @@ class AuthServiceProxy(object):
|
|||
if http_response is None:
|
||||
raise JSONRPCException({
|
||||
'code': -342, 'message': 'missing HTTP response from server'})
|
||||
|
||||
content_type = http_response.getheader('Content-Type')
|
||||
if content_type != 'application/json':
|
||||
raise JSONRPCException({
|
||||
'code': -342, 'message': 'non-JSON HTTP response with \'%i %s\' from server' % (http_response.status, http_response.reason)})
|
||||
|
||||
responsedata = http_response.read().decode('utf8')
|
||||
response = json.loads(responsedata, parse_float=decimal.Decimal)
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
"""Bignum routines"""
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import struct
|
||||
|
||||
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
# and for constructing a getheaders message
|
||||
#
|
||||
|
||||
from mininode import CBlock, CBlockHeader, CBlockLocator, CTransaction, msg_block, msg_headers, msg_tx
|
||||
from .mininode import CBlock, CBlockHeader, CBlockLocator, CTransaction, msg_block, msg_headers, msg_tx
|
||||
|
||||
import sys
|
||||
import cStringIO
|
||||
import io
|
||||
import dbm
|
||||
|
||||
class BlockStore(object):
|
||||
class BlockStore():
|
||||
def __init__(self, datadir):
|
||||
self.blockDB = dbm.open(datadir + "/blocks", 'c')
|
||||
self.currentBlock = 0L
|
||||
self.currentBlock = 0
|
||||
|
||||
def close(self):
|
||||
self.blockDB.close()
|
||||
|
@ -23,7 +23,7 @@ class BlockStore(object):
|
|||
serialized_block = self.blockDB[repr(blockhash)]
|
||||
except KeyError:
|
||||
return None
|
||||
f = cStringIO.StringIO(serialized_block)
|
||||
f = io.BytesIO(serialized_block)
|
||||
ret = CBlock()
|
||||
ret.deserialize(f)
|
||||
ret.calc_sha256()
|
||||
|
@ -62,7 +62,7 @@ class BlockStore(object):
|
|||
try:
|
||||
self.blockDB[repr(block.sha256)] = bytes(block.serialize())
|
||||
except TypeError as e:
|
||||
print "Unexpected error: ", sys.exc_info()[0], e.args
|
||||
print("Unexpected error: ", sys.exc_info()[0], e.args)
|
||||
self.currentBlock = block.sha256
|
||||
|
||||
def get_blocks(self, inv):
|
||||
|
@ -107,7 +107,7 @@ class TxStore(object):
|
|||
serialized_tx = self.txDB[repr(txhash)]
|
||||
except KeyError:
|
||||
return None
|
||||
f = cStringIO.StringIO(serialized_tx)
|
||||
f = io.BytesIO(serialized_tx)
|
||||
ret = CTransaction()
|
||||
ret.deserialize(f)
|
||||
ret.calc_sha256()
|
||||
|
@ -118,7 +118,7 @@ class TxStore(object):
|
|||
try:
|
||||
self.txDB[repr(tx.sha256)] = bytes(tx.serialize())
|
||||
except TypeError as e:
|
||||
print "Unexpected error: ", sys.exc_info()[0], e.args
|
||||
print("Unexpected error: ", sys.exc_info()[0], e.args)
|
||||
|
||||
def get_transactions(self, inv):
|
||||
responses = []
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
#
|
||||
|
||||
from mininode import CBlock, CTransaction, CTxIn, CTxOut, COutPoint
|
||||
from script import CScript, OP_0, OP_EQUAL, OP_HASH160
|
||||
from .mininode import CBlock, CTransaction, CTxIn, CTxOut, COutPoint
|
||||
from .script import CScript, OP_0, OP_EQUAL, OP_HASH160
|
||||
|
||||
# Create a block (with regtest difficulty)
|
||||
def create_block(hashprev, coinbase, nTime=None, nBits=None, hashFinalSaplingRoot=None):
|
||||
|
@ -34,7 +34,7 @@ def serialize_script_num(value):
|
|||
neg = value < 0
|
||||
absvalue = -value if neg else value
|
||||
while (absvalue):
|
||||
r.append(chr(absvalue & 0xff))
|
||||
r.append(int(absvalue & 0xff))
|
||||
absvalue >>= 8
|
||||
if r[-1] & 0x80:
|
||||
r.append(0x80 if neg else 0)
|
||||
|
@ -54,11 +54,11 @@ def create_coinbase(heightAdjust = 0):
|
|||
coinbaseoutput.nValue = int(12.5*100000000)
|
||||
halvings = int((counter+heightAdjust)/150) # regtest
|
||||
coinbaseoutput.nValue >>= halvings
|
||||
coinbaseoutput.scriptPubKey = ""
|
||||
coinbaseoutput.scriptPubKey = b""
|
||||
coinbase.vout = [ coinbaseoutput ]
|
||||
if halvings == 0: # regtest
|
||||
froutput = CTxOut()
|
||||
froutput.nValue = coinbaseoutput.nValue / 5
|
||||
froutput.nValue = coinbaseoutput.nValue // 5
|
||||
# regtest
|
||||
fraddr = bytearray([0x67, 0x08, 0xe6, 0x67, 0x0d, 0xb0, 0xb9, 0x50,
|
||||
0xda, 0xc6, 0x80, 0x31, 0x02, 0x5c, 0xc5, 0xb6,
|
||||
|
@ -75,6 +75,6 @@ def create_transaction(prevtx, n, sig, value):
|
|||
tx = CTransaction()
|
||||
assert(n < len(prevtx.vout))
|
||||
tx.vin.append(CTxIn(COutPoint(prevtx.sha256, n), sig, 0xffffffff))
|
||||
tx.vout.append(CTxOut(value, ""))
|
||||
tx.vout.append(CTxOut(value, b""))
|
||||
tx.calc_sha256()
|
||||
return tx
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
#
|
||||
|
||||
from mininode import CBlock, CTransaction, CInv, NodeConn, NodeConnCB, \
|
||||
from .mininode import CBlock, CTransaction, CInv, NodeConn, NodeConnCB, \
|
||||
msg_inv, msg_getheaders, msg_ping, msg_mempool, mininode_lock, MAX_INV_SZ
|
||||
from blockstore import BlockStore, TxStore
|
||||
from util import p2p_port
|
||||
from .blockstore import BlockStore, TxStore
|
||||
from .util import p2p_port
|
||||
|
||||
import time
|
||||
|
||||
|
@ -241,7 +241,6 @@ class TestManager(object):
|
|||
if c.cb.bestblockhash != self.connections[0].cb.bestblockhash:
|
||||
return False
|
||||
elif ((c.cb.bestblockhash == blockhash) != outcome):
|
||||
# print c.cb.bestblockhash, blockhash, outcome
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -335,7 +334,7 @@ class TestManager(object):
|
|||
if (not self.check_mempool(tx.sha256, tx_outcome)):
|
||||
raise AssertionError("Mempool test failed at test %d" % test_number)
|
||||
|
||||
print "Test %d: PASS" % test_number, [ c.rpc.getblockcount() for c in self.connections ]
|
||||
print("Test %d: PASS" % test_number, [ c.rpc.getblockcount() for c in self.connections ])
|
||||
test_number += 1
|
||||
|
||||
[ c.disconnect_node() for c in self.connections ]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from operator import itemgetter
|
||||
import struct
|
||||
from functools import reduce
|
||||
|
||||
DEBUG = False
|
||||
VERBOSE = False
|
||||
|
@ -12,8 +13,8 @@ def expand_array(inp, out_len, bit_len, byte_pad=0):
|
|||
assert bit_len >= 8 and word_size >= 7+bit_len
|
||||
bit_len_mask = (1<<bit_len)-1
|
||||
|
||||
out_width = (bit_len+7)/8 + byte_pad
|
||||
assert out_len == 8*out_width*len(inp)/bit_len
|
||||
out_width = (bit_len+7)//8 + byte_pad
|
||||
assert out_len == 8*out_width*len(inp)//bit_len
|
||||
out = bytearray(out_len)
|
||||
|
||||
bit_len_mask = (1 << bit_len) - 1
|
||||
|
@ -24,7 +25,7 @@ def expand_array(inp, out_len, bit_len, byte_pad=0):
|
|||
acc_value = 0;
|
||||
|
||||
j = 0
|
||||
for i in xrange(len(inp)):
|
||||
for i in range(len(inp)):
|
||||
acc_value = ((acc_value << 8) & word_mask) | inp[i]
|
||||
acc_bits += 8
|
||||
|
||||
|
@ -32,7 +33,7 @@ def expand_array(inp, out_len, bit_len, byte_pad=0):
|
|||
# output element.
|
||||
if acc_bits >= bit_len:
|
||||
acc_bits -= bit_len
|
||||
for x in xrange(byte_pad, out_width):
|
||||
for x in range(byte_pad, out_width):
|
||||
out[j+x] = (
|
||||
# Big-endian
|
||||
acc_value >> (acc_bits+(8*(out_width-x-1)))
|
||||
|
@ -47,8 +48,8 @@ def expand_array(inp, out_len, bit_len, byte_pad=0):
|
|||
def compress_array(inp, out_len, bit_len, byte_pad=0):
|
||||
assert bit_len >= 8 and word_size >= 7+bit_len
|
||||
|
||||
in_width = (bit_len+7)/8 + byte_pad
|
||||
assert out_len == bit_len*len(inp)/(8*in_width)
|
||||
in_width = (bit_len+7)//8 + byte_pad
|
||||
assert out_len == bit_len*len(inp)//(8*in_width)
|
||||
out = bytearray(out_len)
|
||||
|
||||
bit_len_mask = (1 << bit_len) - 1
|
||||
|
@ -59,12 +60,12 @@ def compress_array(inp, out_len, bit_len, byte_pad=0):
|
|||
acc_value = 0;
|
||||
|
||||
j = 0
|
||||
for i in xrange(out_len):
|
||||
for i in range(out_len):
|
||||
# When we have fewer than 8 bits left in the accumulator, read the next
|
||||
# input element.
|
||||
if acc_bits < 8:
|
||||
acc_value = ((acc_value << bit_len) & word_mask) | inp[j]
|
||||
for x in xrange(byte_pad, in_width):
|
||||
for x in range(byte_pad, in_width):
|
||||
acc_value = acc_value | (
|
||||
(
|
||||
# Apply bit_len_mask across byte boundaries
|
||||
|
@ -80,19 +81,19 @@ def compress_array(inp, out_len, bit_len, byte_pad=0):
|
|||
|
||||
def get_indices_from_minimal(minimal, bit_len):
|
||||
eh_index_size = 4
|
||||
assert (bit_len+7)/8 <= eh_index_size
|
||||
len_indices = 8*eh_index_size*len(minimal)/bit_len
|
||||
byte_pad = eh_index_size - (bit_len+7)/8
|
||||
assert (bit_len+7)//8 <= eh_index_size
|
||||
len_indices = 8*eh_index_size*len(minimal)//bit_len
|
||||
byte_pad = eh_index_size - (bit_len+7)//8
|
||||
expanded = expand_array(minimal, len_indices, bit_len, byte_pad)
|
||||
return [struct.unpack('>I', expanded[i:i+4])[0] for i in range(0, len_indices, eh_index_size)]
|
||||
|
||||
def get_minimal_from_indices(indices, bit_len):
|
||||
eh_index_size = 4
|
||||
assert (bit_len+7)/8 <= eh_index_size
|
||||
assert (bit_len+7)//8 <= eh_index_size
|
||||
len_indices = len(indices)*eh_index_size
|
||||
min_len = bit_len*len_indices/(8*eh_index_size)
|
||||
byte_pad = eh_index_size - (bit_len+7)/8
|
||||
byte_indices = bytearray(''.join([struct.pack('>I', i) for i in indices]))
|
||||
min_len = bit_len*len_indices//(8*eh_index_size)
|
||||
byte_pad = eh_index_size - (bit_len+7)//8
|
||||
byte_indices = bytearray(b''.join([struct.pack('>I', i) for i in indices]))
|
||||
return compress_array(byte_indices, min_len, bit_len, byte_pad)
|
||||
|
||||
|
||||
|
@ -114,7 +115,7 @@ def count_zeroes(h):
|
|||
return (h+'1').index('1')
|
||||
|
||||
def has_collision(ha, hb, i, l):
|
||||
res = [ha[j] == hb[j] for j in range((i-1)*l/8, i*l/8)]
|
||||
res = [ha[j] == hb[j] for j in range((i-1)*l//8, i*l//8)]
|
||||
return reduce(lambda x, y: x and y, res)
|
||||
|
||||
def distinct_indices(a, b):
|
||||
|
@ -130,39 +131,39 @@ def xor(ha, hb):
|
|||
def gbp_basic(digest, n, k):
|
||||
'''Implementation of Basic Wagner's algorithm for the GBP.'''
|
||||
validate_params(n, k)
|
||||
collision_length = n/(k+1)
|
||||
collision_length = n//(k+1)
|
||||
hash_length = (k+1)*((collision_length+7)//8)
|
||||
indices_per_hash_output = 512/n
|
||||
indices_per_hash_output = 512//n
|
||||
|
||||
# 1) Generate first list
|
||||
if DEBUG: print 'Generating first list'
|
||||
if DEBUG: print('Generating first list')
|
||||
X = []
|
||||
tmp_hash = ''
|
||||
tmp_hash = b''
|
||||
for i in range(0, 2**(collision_length+1)):
|
||||
r = i % indices_per_hash_output
|
||||
if r == 0:
|
||||
# X_i = H(I||V||x_i)
|
||||
curr_digest = digest.copy()
|
||||
hash_xi(curr_digest, i/indices_per_hash_output)
|
||||
hash_xi(curr_digest, i//indices_per_hash_output)
|
||||
tmp_hash = curr_digest.digest()
|
||||
X.append((
|
||||
expand_array(bytearray(tmp_hash[r*n/8:(r+1)*n/8]),
|
||||
expand_array(bytearray(tmp_hash[r*n//8:(r+1)*n//8]),
|
||||
hash_length, collision_length),
|
||||
(i,)
|
||||
))
|
||||
|
||||
# 3) Repeat step 2 until 2n/(k+1) bits remain
|
||||
for i in range(1, k):
|
||||
if DEBUG: print 'Round %d:' % i
|
||||
if DEBUG: print('Round %d:' % i)
|
||||
|
||||
# 2a) Sort the list
|
||||
if DEBUG: print '- Sorting list'
|
||||
if DEBUG: print('- Sorting list')
|
||||
X.sort(key=itemgetter(0))
|
||||
if DEBUG and VERBOSE:
|
||||
for Xi in X[-32:]:
|
||||
print '%s %s' % (print_hash(Xi[0]), Xi[1])
|
||||
print('%s %s' % (print_hash(Xi[0]), Xi[1]))
|
||||
|
||||
if DEBUG: print '- Finding collisions'
|
||||
if DEBUG: print('- Finding collisions')
|
||||
Xc = []
|
||||
while len(X) > 0:
|
||||
# 2b) Find next set of unordered pairs with collisions on first n/(k+1) bits
|
||||
|
@ -192,13 +193,13 @@ def gbp_basic(digest, n, k):
|
|||
|
||||
# k+1) Find a collision on last 2n(k+1) bits
|
||||
if DEBUG:
|
||||
print 'Final round:'
|
||||
print '- Sorting list'
|
||||
print('Final round:')
|
||||
print('- Sorting list')
|
||||
X.sort(key=itemgetter(0))
|
||||
if DEBUG and VERBOSE:
|
||||
for Xi in X[-32:]:
|
||||
print '%s %s' % (print_hash(Xi[0]), Xi[1])
|
||||
if DEBUG: print '- Finding collisions'
|
||||
print('%s %s' % (print_hash(Xi[0]), Xi[1]))
|
||||
if DEBUG: print('- Finding collisions')
|
||||
solns = []
|
||||
while len(X) > 0:
|
||||
j = 1
|
||||
|
@ -213,9 +214,9 @@ def gbp_basic(digest, n, k):
|
|||
res = xor(X[-1-l][0], X[-1-m][0])
|
||||
if count_zeroes(res) == 8*hash_length and distinct_indices(X[-1-l][1], X[-1-m][1]):
|
||||
if DEBUG and VERBOSE:
|
||||
print 'Found solution:'
|
||||
print '- %s %s' % (print_hash(X[-1-l][0]), X[-1-l][1])
|
||||
print '- %s %s' % (print_hash(X[-1-m][0]), X[-1-m][1])
|
||||
print('Found solution:')
|
||||
print('- %s %s' % (print_hash(X[-1-l][0]), X[-1-l][1]))
|
||||
print('- %s %s' % (print_hash(X[-1-m][0]), X[-1-m][1]))
|
||||
if X[-1-l][1][0] < X[-1-m][1][0]:
|
||||
solns.append(list(X[-1-l][1] + X[-1-m][1]))
|
||||
else:
|
||||
|
@ -229,14 +230,14 @@ def gbp_basic(digest, n, k):
|
|||
|
||||
def gbp_validate(digest, minimal, n, k):
|
||||
validate_params(n, k)
|
||||
collision_length = n/(k+1)
|
||||
collision_length = n//(k+1)
|
||||
hash_length = (k+1)*((collision_length+7)//8)
|
||||
indices_per_hash_output = 512/n
|
||||
indices_per_hash_output = 512//n
|
||||
solution_width = (1 << k)*(collision_length+1)//8
|
||||
|
||||
if len(minimal) != solution_width:
|
||||
print 'Invalid solution length: %d (expected %d)' % \
|
||||
(len(minimal), solution_width)
|
||||
print('Invalid solution length: %d (expected %d)' % \
|
||||
(len(minimal), solution_width))
|
||||
return False
|
||||
|
||||
X = []
|
||||
|
@ -244,10 +245,10 @@ def gbp_validate(digest, minimal, n, k):
|
|||
r = i % indices_per_hash_output
|
||||
# X_i = H(I||V||x_i)
|
||||
curr_digest = digest.copy()
|
||||
hash_xi(curr_digest, i/indices_per_hash_output)
|
||||
hash_xi(curr_digest, i//indices_per_hash_output)
|
||||
tmp_hash = curr_digest.digest()
|
||||
X.append((
|
||||
expand_array(bytearray(tmp_hash[r*n/8:(r+1)*n/8]),
|
||||
expand_array(bytearray(tmp_hash[r*n//8:(r+1)*n//8]),
|
||||
hash_length, collision_length),
|
||||
(i,)
|
||||
))
|
||||
|
@ -256,23 +257,23 @@ def gbp_validate(digest, minimal, n, k):
|
|||
Xc = []
|
||||
for i in range(0, len(X), 2):
|
||||
if not has_collision(X[i][0], X[i+1][0], r, collision_length):
|
||||
print 'Invalid solution: invalid collision length between StepRows'
|
||||
print('Invalid solution: invalid collision length between StepRows')
|
||||
return False
|
||||
if X[i+1][1][0] < X[i][1][0]:
|
||||
print 'Invalid solution: Index tree incorrectly ordered'
|
||||
print('Invalid solution: Index tree incorrectly ordered')
|
||||
return False
|
||||
if not distinct_indices(X[i][1], X[i+1][1]):
|
||||
print 'Invalid solution: duplicate indices'
|
||||
print('Invalid solution: duplicate indices')
|
||||
return False
|
||||
Xc.append((xor(X[i][0], X[i+1][0]), X[i][1] + X[i+1][1]))
|
||||
X = Xc
|
||||
|
||||
if len(X) != 1:
|
||||
print 'Invalid solution: incorrect length after end of rounds: %d' % len(X)
|
||||
print('Invalid solution: incorrect length after end of rounds: %d' % len(X))
|
||||
return False
|
||||
|
||||
if count_zeroes(X[0][0]) != 8*hash_length:
|
||||
print 'Invalid solution: incorrect number of zeroes: %d' % count_zeroes(X[0][0])
|
||||
print('Invalid solution: incorrect number of zeroes: %d' % count_zeroes(X[0][0]))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -289,5 +290,5 @@ def print_hash(h):
|
|||
def validate_params(n, k):
|
||||
if (k >= n):
|
||||
raise ValueError('n must be larger than k')
|
||||
if (((n/(k+1))+1) >= 32):
|
||||
if (((n//(k+1))+1) >= 32):
|
||||
raise ValueError('Parameters must satisfy n/(k+1)+1 < 32')
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -10,7 +10,7 @@ import fcntl
|
|||
import struct
|
||||
import array
|
||||
import os
|
||||
import binascii
|
||||
from binascii import unhexlify, hexlify
|
||||
|
||||
# Roughly based on http://voorloopnul.com/blog/a-python-netstat-in-less-than-100-lines-of-code/ by Ricardo Pascal
|
||||
STATE_ESTABLISHED = '01'
|
||||
|
@ -43,9 +43,9 @@ def _remove_empty(array):
|
|||
def _convert_ip_port(array):
|
||||
host,port = array.split(':')
|
||||
# convert host from mangled-per-four-bytes form as used by kernel
|
||||
host = binascii.unhexlify(host)
|
||||
host = unhexlify(host)
|
||||
host_out = ''
|
||||
for x in range(0, len(host)/4):
|
||||
for x in range(0, len(host) // 4):
|
||||
(val,) = struct.unpack('=I', host[x*4:(x+1)*4])
|
||||
host_out += '%08x' % val
|
||||
|
||||
|
@ -94,7 +94,7 @@ def all_interfaces():
|
|||
max_possible = 8 # initial value
|
||||
while True:
|
||||
bytes = max_possible * struct_size
|
||||
names = array.array('B', '\0' * bytes)
|
||||
names = array.array('B', b'\0' * bytes)
|
||||
outbytes = struct.unpack('iL', fcntl.ioctl(
|
||||
s.fileno(),
|
||||
0x8912, # SIOCGIFCONF
|
||||
|
@ -105,7 +105,7 @@ def all_interfaces():
|
|||
else:
|
||||
break
|
||||
namestr = names.tostring()
|
||||
return [(namestr[i:i+16].split('\0', 1)[0],
|
||||
return [(namestr[i:i+16].split(b'\0', 1)[0],
|
||||
socket.inet_ntoa(namestr[i+20:i+24]))
|
||||
for i in range(0, outbytes, struct_size)]
|
||||
|
||||
|
@ -136,7 +136,7 @@ def addr_to_hex(addr):
|
|||
addr = sub[0] + ([0] * nullbytes) + sub[1]
|
||||
else:
|
||||
raise ValueError('Could not parse address %s' % addr)
|
||||
return binascii.hexlify(bytearray(addr))
|
||||
return hexlify(bytearray(addr)).decode('ascii')
|
||||
|
||||
def test_ipv6_local():
|
||||
'''
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#
|
||||
# script.py
|
||||
#
|
||||
# This file is modified from python-bitcoinlib.
|
||||
|
@ -12,8 +11,6 @@
|
|||
Functionality to build scripts, as well as SignatureHash().
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
from test_framework.mininode import CTransaction, CTxOut, hash256
|
||||
|
||||
import sys
|
||||
|
@ -25,7 +22,6 @@ if sys.version > '3':
|
|||
bord = lambda x: x
|
||||
|
||||
import struct
|
||||
import binascii
|
||||
|
||||
from test_framework import bignum
|
||||
|
||||
|
@ -44,9 +40,9 @@ class CScriptOp(int):
|
|||
def encode_op_pushdata(d):
|
||||
"""Encode a PUSHDATA op, returning bytes"""
|
||||
if len(d) < 0x4c:
|
||||
return b'' + bchr(len(d)) + d # OP_PUSHDATA
|
||||
return b'' + struct.pack('B', len(d)) + d # OP_PUSHDATA
|
||||
elif len(d) <= 0xff:
|
||||
return b'\x4c' + bchr(len(d)) + d # OP_PUSHDATA1
|
||||
return b'\x4c' + struct.pack('B', len(d)) + d # OP_PUSHDATA1
|
||||
elif len(d) <= 0xffff:
|
||||
return b'\x4d' + struct.pack(b'<H', len(d)) + d # OP_PUSHDATA2
|
||||
elif len(d) <= 0xffffffff:
|
||||
|
@ -635,7 +631,7 @@ class CScriptNum(object):
|
|||
r.append(0x80 if neg else 0)
|
||||
elif neg:
|
||||
r[-1] |= 0x80
|
||||
return bytes(bchr(len(r)) + r)
|
||||
return struct.pack("B", len(r)) + r
|
||||
|
||||
|
||||
class CScript(bytes):
|
||||
|
@ -652,17 +648,17 @@ class CScript(bytes):
|
|||
def __coerce_instance(cls, other):
|
||||
# Coerce other into bytes
|
||||
if isinstance(other, CScriptOp):
|
||||
other = bchr(other)
|
||||
other = bytes([other])
|
||||
elif isinstance(other, CScriptNum):
|
||||
if (other.value == 0):
|
||||
other = bchr(CScriptOp(OP_0))
|
||||
other = bytes([CScriptOp(OP_0)])
|
||||
else:
|
||||
other = CScriptNum.encode(other)
|
||||
elif isinstance(other, (int, long)):
|
||||
elif isinstance(other, int):
|
||||
if 0 <= other <= 16:
|
||||
other = bytes(bchr(CScriptOp.encode_op_n(other)))
|
||||
other = bytes([CScriptOp.encode_op_n(other)])
|
||||
elif other == -1:
|
||||
other = bytes(bchr(OP_1NEGATE))
|
||||
other = bytes([OP_1NEGATE])
|
||||
else:
|
||||
other = CScriptOp.encode_op_pushdata(bignum.bn2vch(other))
|
||||
elif isinstance(other, (bytes, bytearray)):
|
||||
|
@ -777,7 +773,7 @@ class CScript(bytes):
|
|||
# need to change
|
||||
def _repr(o):
|
||||
if isinstance(o, bytes):
|
||||
return "x('%s')" % binascii.hexlify(o).decode('utf8')
|
||||
return "x('%s')" % o.hex().decode('ascii')
|
||||
else:
|
||||
return repr(o)
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2015 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
'''
|
||||
Dummy Socks5 server for testing.
|
||||
'''
|
||||
from __future__ import print_function, division, unicode_literals
|
||||
import socket, threading, Queue
|
||||
|
||||
import socket, threading, queue
|
||||
import traceback, sys
|
||||
|
||||
### Protocol constants
|
||||
|
@ -102,7 +103,7 @@ class Socks5Connection(object):
|
|||
addr = recvall(self.conn, 4)
|
||||
elif atyp == AddressType.DOMAINNAME:
|
||||
n = recvall(self.conn, 1)[0]
|
||||
addr = str(recvall(self.conn, n))
|
||||
addr = recvall(self.conn, n)
|
||||
elif atyp == AddressType.IPV6:
|
||||
addr = recvall(self.conn, 16)
|
||||
else:
|
||||
|
@ -117,7 +118,7 @@ class Socks5Connection(object):
|
|||
self.serv.queue.put(cmdin)
|
||||
print('Proxy: ', cmdin)
|
||||
# Fall through to disconnect
|
||||
except Exception,e:
|
||||
except Exception as e:
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
self.serv.queue.put(e)
|
||||
finally:
|
||||
|
@ -132,7 +133,7 @@ class Socks5Server(object):
|
|||
self.s.listen(5)
|
||||
self.running = False
|
||||
self.thread = None
|
||||
self.queue = Queue.Queue() # report connections and exceptions to client
|
||||
self.queue = queue.Queue() # report connections and exceptions to client
|
||||
|
||||
def run(self):
|
||||
while self.running:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -13,8 +13,8 @@ import shutil
|
|||
import tempfile
|
||||
import traceback
|
||||
|
||||
from authproxy import JSONRPCException
|
||||
from util import assert_equal, check_json_precision, \
|
||||
from .authproxy import JSONRPCException
|
||||
from .util import assert_equal, check_json_precision, \
|
||||
initialize_chain, initialize_chain_clean, \
|
||||
start_nodes, connect_nodes_bi, stop_nodes, \
|
||||
sync_blocks, sync_mempools, wait_bitcoinds
|
||||
|
@ -126,7 +126,10 @@ class BitcoinTestFramework(object):
|
|||
print("JSONRPC error: "+e.error['message'])
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
except AssertionError as e:
|
||||
print("Assertion failed: "+e.message)
|
||||
print("Assertion failed: "+ str(e))
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
except KeyError as e:
|
||||
print("key not found: "+ str(e))
|
||||
traceback.print_tb(sys.exc_info()[2])
|
||||
except Exception as e:
|
||||
print("Unexpected exception caught during testing: "+str(e))
|
||||
|
@ -172,7 +175,7 @@ class ComparisonTestFramework(BitcoinTestFramework):
|
|||
help="bitcoind binary to use for reference nodes (if any)")
|
||||
|
||||
def setup_chain(self):
|
||||
print "Initializing test directory "+self.options.tmpdir
|
||||
print("Initializing test directory "+self.options.tmpdir)
|
||||
initialize_chain_clean(self.options.tmpdir, self.num_nodes)
|
||||
|
||||
def setup_network(self):
|
||||
|
|
|
@ -21,7 +21,7 @@ import subprocess
|
|||
import time
|
||||
import re
|
||||
|
||||
from authproxy import AuthServiceProxy
|
||||
from .authproxy import AuthServiceProxy
|
||||
|
||||
PRE_BLOSSOM_BLOCK_TARGET_SPACING = 150
|
||||
POST_BLOSSOM_BLOCK_TARGET_SPACING = 75
|
||||
|
@ -105,6 +105,9 @@ def initialize_datadir(dirname, n):
|
|||
f.write("listenonion=0\n")
|
||||
return datadir
|
||||
|
||||
def rpc_url(i, rpchost=None):
|
||||
return "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', rpc_port(i))
|
||||
|
||||
def initialize_chain(test_dir):
|
||||
"""
|
||||
Create (or copy from cache) a 200-block-long chain and
|
||||
|
@ -147,11 +150,11 @@ def initialize_chain(test_dir):
|
|||
args.append("-connect=127.0.0.1:"+str(p2p_port(0)))
|
||||
bitcoind_processes[i] = subprocess.Popen(args)
|
||||
if os.getenv("PYTHON_DEBUG", ""):
|
||||
print "initialize_chain: bitcoind started, calling bitcoin-cli -rpcwait getblockcount"
|
||||
print("initialize_chain: bitcoind started, calling bitcoin-cli -rpcwait getblockcount")
|
||||
subprocess.check_call([ os.getenv("BITCOINCLI", "bitcoin-cli"), "-datadir="+datadir,
|
||||
"-rpcwait", "getblockcount"], stdout=devnull)
|
||||
if os.getenv("PYTHON_DEBUG", ""):
|
||||
print "initialize_chain: bitcoin-cli -rpcwait getblockcount completed"
|
||||
print("initialize_chain: bitcoin-cli -rpcwait getblockcount completed")
|
||||
devnull.close()
|
||||
rpcs = []
|
||||
for i in range(4):
|
||||
|
@ -239,12 +242,12 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
|
|||
bitcoind_processes[i] = subprocess.Popen(args)
|
||||
devnull = open("/dev/null", "w+")
|
||||
if os.getenv("PYTHON_DEBUG", ""):
|
||||
print "start_node: bitcoind started, calling bitcoin-cli -rpcwait getblockcount"
|
||||
print("start_node: bitcoind started, calling bitcoin-cli -rpcwait getblockcount")
|
||||
subprocess.check_call([ os.getenv("BITCOINCLI", "bitcoin-cli"), "-datadir="+datadir] +
|
||||
_rpchost_to_args(rpchost) +
|
||||
["-rpcwait", "getblockcount"], stdout=devnull)
|
||||
if os.getenv("PYTHON_DEBUG", ""):
|
||||
print "start_node: calling bitcoin-cli -rpcwait getblockcount returned"
|
||||
print("start_node: calling bitcoin-cli -rpcwait getblockcount returned")
|
||||
devnull.close()
|
||||
url = "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', rpc_port(i))
|
||||
if timewait is not None:
|
||||
|
@ -285,7 +288,7 @@ def set_node_times(nodes, t):
|
|||
|
||||
def wait_bitcoinds():
|
||||
# Wait for all bitcoinds to cleanly exit
|
||||
for bitcoind in bitcoind_processes.values():
|
||||
for bitcoind in list(bitcoind_processes.values()):
|
||||
bitcoind.wait()
|
||||
bitcoind_processes.clear()
|
||||
|
||||
|
@ -442,7 +445,7 @@ def fail(message=""):
|
|||
def wait_and_assert_operationid_status_result(node, myopid, in_status='success', in_errormsg=None, timeout=300):
|
||||
print('waiting for async operation {}'.format(myopid))
|
||||
result = None
|
||||
for _ in xrange(1, timeout):
|
||||
for _ in range(1, timeout):
|
||||
results = node.z_getoperationresult([myopid])
|
||||
if len(results) > 0:
|
||||
result = results[0]
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
#
|
||||
# Test timestampindex generation and fetching for insightexplorer
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
import time
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
@ -41,7 +39,7 @@ class TimestampIndexTest(BitcoinTestFramework):
|
|||
|
||||
def run_test(self):
|
||||
blockhashes = []
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
for _ in range(8):
|
||||
blockhashes.extend(self.nodes[0].generate(1))
|
||||
time.sleep(1)
|
||||
|
@ -79,7 +77,7 @@ class TimestampIndexTest(BitcoinTestFramework):
|
|||
firsttime+10+1, firsttime,
|
||||
{'logicalTimes': True})
|
||||
ltimes = [r['logicalts'] for r in results]
|
||||
assert_equal(ltimes, range(firsttime, firsttime+10))
|
||||
assert_equal(ltimes, list(range(firsttime, firsttime+10)))
|
||||
|
||||
# there's also a flag to exclude orphaned blocks; results should
|
||||
# be the same in this test
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -26,8 +26,6 @@
|
|||
# 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.util import (
|
||||
assert_equal,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -9,10 +10,10 @@ from test_framework.mininode import CTransaction, NodeConnCB, mininode_lock, msg
|
|||
msg_pong
|
||||
from test_framework.util import fail
|
||||
|
||||
import cStringIO
|
||||
import io
|
||||
import time
|
||||
|
||||
from binascii import hexlify, unhexlify
|
||||
from binascii import unhexlify
|
||||
|
||||
|
||||
class TestNode(NodeConnCB):
|
||||
|
@ -86,13 +87,13 @@ def create_transaction(node, coinbase, to_address, amount, expiry_height):
|
|||
tx = CTransaction()
|
||||
|
||||
# Set the expiry height
|
||||
f = cStringIO.StringIO(unhexlify(rawtx))
|
||||
f = io.BytesIO(unhexlify(rawtx))
|
||||
tx.deserialize(f)
|
||||
tx.nExpiryHeight = expiry_height
|
||||
rawtx = hexlify(tx.serialize())
|
||||
rawtx = tx.serialize().hex()
|
||||
|
||||
signresult = node.signrawtransaction(rawtx)
|
||||
f = cStringIO.StringIO(unhexlify(signresult['hex']))
|
||||
f = io.BytesIO(unhexlify(signresult['hex']))
|
||||
tx.deserialize(f)
|
||||
tx.rehash()
|
||||
return tx
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# 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.util import assert_equal, connect_nodes, \
|
||||
sync_blocks, gather_inputs
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, assert_greater_than, \
|
||||
|
@ -29,7 +27,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test (self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
|
||||
self.nodes[0].generate(4)
|
||||
self.sync_all()
|
||||
|
@ -106,7 +104,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
signed_tx = self.nodes[2].signrawtransaction(raw_tx)
|
||||
try:
|
||||
self.nodes[2].sendrawtransaction(signed_tx["hex"])
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert("absurdly high fees" in errorString)
|
||||
assert("900000000 > 10000000" in errorString)
|
||||
|
@ -291,10 +289,10 @@ class WalletTest (BitcoinTestFramework):
|
|||
num_z_recipients = 2100
|
||||
amount_per_recipient = Decimal('0.00000001')
|
||||
errorString = ''
|
||||
for i in xrange(0,num_t_recipients):
|
||||
for i in range(0,num_t_recipients):
|
||||
newtaddr = self.nodes[2].getnewaddress()
|
||||
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')
|
||||
recipients.append({"address":newzaddr, "amount":amount_per_recipient})
|
||||
|
||||
|
@ -309,7 +307,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
|
||||
try:
|
||||
self.nodes[0].z_sendmany(myzaddr, recipients)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert("size of raw transaction would be larger than limit" in errorString)
|
||||
|
||||
|
@ -395,7 +393,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
errorString = ""
|
||||
try:
|
||||
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "1f-4")
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
|
||||
assert_equal("Invalid amount" in errorString, True)
|
||||
|
@ -403,7 +401,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
errorString = ""
|
||||
try:
|
||||
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']
|
||||
|
||||
assert_equal("not an integer" in errorString, True)
|
||||
|
@ -417,9 +415,9 @@ class WalletTest (BitcoinTestFramework):
|
|||
try:
|
||||
myopid = self.nodes[0].z_sendmany(myzaddr, recipients)
|
||||
assert(myopid)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
print errorString
|
||||
print(errorString)
|
||||
assert(False)
|
||||
|
||||
# This fee is larger than the default fee and since amount=0
|
||||
|
@ -431,7 +429,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
|
||||
try:
|
||||
myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, fee)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert('Small transaction amount' in errorString)
|
||||
|
||||
|
@ -444,9 +442,9 @@ class WalletTest (BitcoinTestFramework):
|
|||
try:
|
||||
myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, fee)
|
||||
assert(myopid)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
print errorString
|
||||
print(errorString)
|
||||
assert(False)
|
||||
|
||||
# Make sure amount=0, fee=0 transaction are valid to add to mempool
|
||||
|
@ -459,9 +457,9 @@ class WalletTest (BitcoinTestFramework):
|
|||
try:
|
||||
myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, fee)
|
||||
assert(myopid)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
print errorString
|
||||
print(errorString)
|
||||
assert(False)
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2016 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
# 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.util import assert_equal, initialize_chain_clean, \
|
||||
initialize_datadir, start_nodes, start_node, connect_nodes_bi, \
|
||||
|
@ -44,7 +42,7 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test (self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
|
||||
self.nodes[0].setmocktime(starttime)
|
||||
self.nodes[0].generate(101)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal
|
||||
|
||||
|
@ -34,7 +32,7 @@ class WalletAddressesTest(BitcoinTestFramework):
|
|||
|
||||
# Current height = 200 -> Sapling
|
||||
# Default address type is Sapling
|
||||
print "Testing height 200 (Sapling)"
|
||||
print("Testing height 200 (Sapling)")
|
||||
addr_checks('sapling')
|
||||
|
||||
self.nodes[0].generate(1)
|
||||
|
@ -42,7 +40,7 @@ class WalletAddressesTest(BitcoinTestFramework):
|
|||
|
||||
# Current height = 201 -> Sapling
|
||||
# Default address type is Sapling
|
||||
print "Testing height 201 (Sapling)"
|
||||
print("Testing height 201 (Sapling)")
|
||||
addr_checks('sapling')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_nodes, stop_nodes, connect_nodes_bi, \
|
||||
|
@ -27,7 +25,7 @@ class WalletAnchorForkTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test (self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
self.nodes[0].generate(4)
|
||||
self.sync_all()
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or 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.util import (
|
||||
connect_nodes_bi,
|
||||
|
@ -43,12 +41,14 @@ class WalletChangeAddressesTest(BitcoinTestFramework):
|
|||
midAddr = self.nodes[0].z_getnewaddress('sapling')
|
||||
myopid = self.nodes[0].z_shieldcoinbase(get_coinbase_address(self.nodes[0]), midAddr, 0)['opid']
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
taddrSource = self.nodes[0].getnewaddress()
|
||||
for _ in range(6):
|
||||
recipients = [{"address": taddrSource, "amount": Decimal('2')}]
|
||||
myopid = self.nodes[0].z_sendmany(midAddr, recipients, 1, Decimal('0'))
|
||||
myopid = self.nodes[0].z_sendmany(midAddr, recipients, 1, 0)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(1)
|
||||
|
@ -58,11 +58,11 @@ class WalletChangeAddressesTest(BitcoinTestFramework):
|
|||
recipients = [{"address": target, "amount": Decimal('1')}]
|
||||
|
||||
# Send funds to recipient address twice
|
||||
myopid = self.nodes[0].z_sendmany(taddrSource, recipients, 1, Decimal('0'))
|
||||
myopid = self.nodes[0].z_sendmany(taddrSource, recipients, 1, 0)
|
||||
txid1 = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
myopid = self.nodes[0].z_sendmany(taddrSource, recipients, 1, Decimal('0'))
|
||||
myopid = self.nodes[0].z_sendmany(taddrSource, recipients, 1, 0)
|
||||
txid2 = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
|
@ -83,13 +83,13 @@ class WalletChangeAddressesTest(BitcoinTestFramework):
|
|||
saplingAddr = self.nodes[0].z_getnewaddress('sapling')
|
||||
sproutAddr = self.nodes[0].z_getnewaddress('sprout')
|
||||
|
||||
print
|
||||
print()
|
||||
print('Checking z_sendmany(taddr->Sapling)')
|
||||
check_change_taddr_reuse(saplingAddr)
|
||||
print
|
||||
print()
|
||||
print('Checking z_sendmany(taddr->Sprout)')
|
||||
check_change_taddr_reuse(sproutAddr)
|
||||
print
|
||||
print()
|
||||
print('Checking z_sendmany(taddr->taddr)')
|
||||
check_change_taddr_reuse(taddr)
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, assert_false, wait_and_assert_operationid_status
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, start_nodes
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, assert_false
|
||||
from test_framework.util import wait_and_assert_operationid_status
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2016 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, bitcoind_processes, \
|
||||
connect_nodes_bi, start_node, start_nodes, wait_and_assert_operationid_status, \
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
|
@ -112,22 +110,22 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
errorString = ""
|
||||
try:
|
||||
self.nodes[0].createrawtransaction([], {}, 0, 499999999)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("", errorString)
|
||||
try:
|
||||
self.nodes[0].createrawtransaction([], {}, 0, -1)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Invalid parameter, expiryheight must be nonnegative and less than 500000000" in errorString, True)
|
||||
try:
|
||||
self.nodes[0].createrawtransaction([], {}, 0, 500000000)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Invalid parameter, expiryheight must be nonnegative and less than 500000000" in errorString, True)
|
||||
try:
|
||||
self.nodes[0].createrawtransaction([], {}, 0, 200)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Invalid parameter, expiryheight should be at least 203 to avoid transaction expiring soon" in errorString, True)
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal, assert_true,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2018 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import (
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
|
@ -35,7 +33,7 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test (self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
|
||||
self.nodes[0].generate(1)
|
||||
self.nodes[0].generate(4)
|
||||
|
@ -64,42 +62,42 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
|
|||
self.nodes[2].importaddress(mytaddr)
|
||||
try:
|
||||
self.nodes[2].z_shieldcoinbase(mytaddr, myzaddr)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Could not find any coinbase funds to shield" in errorString, True)
|
||||
|
||||
# Shielding will fail because fee is negative
|
||||
try:
|
||||
self.nodes[0].z_shieldcoinbase("*", myzaddr, -1)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Amount out of range" in errorString, True)
|
||||
|
||||
# Shielding will fail because fee is larger than MAX_MONEY
|
||||
try:
|
||||
self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('21000000.00000001'))
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Amount out of range" in errorString, True)
|
||||
|
||||
# Shielding will fail because fee is larger than sum of utxos
|
||||
try:
|
||||
self.nodes[0].z_shieldcoinbase("*", myzaddr, 999)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Insufficient coinbase funds" in errorString, True)
|
||||
|
||||
# Shielding will fail because limit parameter must be at least 0
|
||||
try:
|
||||
self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('0.001'), -1)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Limit on maximum number of utxos cannot be negative" in errorString, True)
|
||||
|
||||
# Shielding will fail because limit parameter is absurdly large
|
||||
try:
|
||||
self.nodes[0].z_shieldcoinbase("*", myzaddr, Decimal('0.001'), 99999999999999)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("JSON integer out of range" in errorString, True)
|
||||
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import inspect
|
||||
import os
|
||||
|
||||
# To keep pyflakes happy
|
||||
WalletShieldCoinbaseTest = object
|
||||
|
||||
cwd = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
execfile(os.path.join(cwd, 'wallet_shieldcoinbase.py'))
|
||||
from wallet_shieldcoinbase import WalletShieldCoinbaseTest
|
||||
|
||||
class WalletShieldCoinbaseSapling(WalletShieldCoinbaseTest):
|
||||
def __init__(self):
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import inspect
|
||||
import os
|
||||
|
||||
# To keep pyflakes happy
|
||||
WalletShieldCoinbaseTest = object
|
||||
|
||||
cwd = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
execfile(os.path.join(cwd, 'wallet_shieldcoinbase.py'))
|
||||
from wallet_shieldcoinbase import WalletShieldCoinbaseTest
|
||||
|
||||
class WalletShieldCoinbaseSprout(WalletShieldCoinbaseTest):
|
||||
def __init__(self):
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2016 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.mininode import COIN
|
||||
|
@ -44,7 +42,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test (self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
|
||||
self.nodes[0].generate(4)
|
||||
self.sync_all()
|
||||
|
@ -72,7 +70,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
errorString = ""
|
||||
try:
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Coinbase funds can only be sent to a zaddr" in errorString, True)
|
||||
|
||||
|
@ -231,7 +229,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
errorString = ""
|
||||
try:
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 99999)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
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
|
||||
try:
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 21)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
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)
|
||||
|
||||
|
@ -261,7 +259,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
# 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.
|
||||
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()
|
||||
recipients.append({"address":newtaddr, "amount":amount_per_recipient})
|
||||
elapsed = timeit.default_timer() - start_time
|
||||
|
@ -283,7 +281,7 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
print("JSONRPC error: "+e.error['message'])
|
||||
assert(False)
|
||||
except Exception as e:
|
||||
print("Unexpected exception caught during testing: "+str(sys.exc_info()[0]))
|
||||
print("Unexpected exception caught during testing: ", e.error['message'], str(sys.exc_info()[0]))
|
||||
assert(False)
|
||||
|
||||
self.sync_all()
|
||||
|
@ -299,21 +297,21 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework):
|
|||
# Send will fail because fee is negative
|
||||
try:
|
||||
self.nodes[0].z_sendmany(myzaddr, recipients, 1, -1)
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Amount out of range" in errorString, True)
|
||||
|
||||
# Send will fail because fee is larger than MAX_MONEY
|
||||
try:
|
||||
self.nodes[0].z_sendmany(myzaddr, recipients, 1, Decimal('21000000.00000001'))
|
||||
except JSONRPCException,e:
|
||||
except JSONRPCException as e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Amount out of range" in errorString, True)
|
||||
|
||||
# Send will fail because fee is larger than sum of outputs
|
||||
try:
|
||||
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']
|
||||
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
|
||||
custom_fee = Decimal('0.00012345')
|
||||
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')
|
||||
recipients.append({"address":newzaddr, "amount":amount_per_recipient})
|
||||
myopid = self.nodes[0].z_sendmany(myzaddr, recipients, minconf, custom_fee)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2016 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_nodes, connect_nodes_bi, wait_and_assert_operationid_status, \
|
||||
|
@ -29,7 +27,7 @@ class WalletTreeStateTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test (self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
|
||||
self.nodes[0].generate(100)
|
||||
self.sync_all()
|
||||
|
@ -80,7 +78,7 @@ class WalletTreeStateTest (BitcoinTestFramework):
|
|||
myopid = self.nodes[0].z_sendmany(myzaddr, recipients)
|
||||
|
||||
# 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])
|
||||
status = results[0]["status"]
|
||||
if status == "executing":
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# 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.
|
||||
"""
|
||||
|
||||
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.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
|
@ -26,7 +24,7 @@ class ZapWalletTXesTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test (self):
|
||||
print "Mining blocks..."
|
||||
print("Mining blocks...")
|
||||
self.nodes[0].generate(4)
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(101)
|
||||
|
@ -72,8 +70,8 @@ class ZapWalletTXesTest (BitcoinTestFramework):
|
|||
aException = False
|
||||
try:
|
||||
tx3 = self.nodes[0].gettransaction(txid3)
|
||||
except JSONRPCException,e:
|
||||
print e
|
||||
except JSONRPCException as e:
|
||||
print(e)
|
||||
aException = True
|
||||
|
||||
assert_equal(aException, True) # there must be a expection because the unconfirmed wallettx0 must be gone by now
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
#
|
||||
# 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.util import assert_equal, start_node, \
|
||||
gather_inputs
|
||||
|
@ -53,7 +51,7 @@ class JoinSplitTest(BitcoinTestFramework):
|
|||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
print "Done!"
|
||||
print("Done!")
|
||||
receive_result = self.nodes[0].zcrawreceive(zcsecretkey, joinsplit_result["encryptednote1"])
|
||||
assert_equal(receive_result["exists"], True)
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
#
|
||||
# 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.authproxy import JSONRPCException
|
||||
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
|
||||
# with BC.
|
||||
print "Waiting for AB_txid...\n"
|
||||
print("Waiting for AB_txid...\n")
|
||||
while True:
|
||||
if self.txid_in_mempool(self.nodes[1], AB_txid):
|
||||
break
|
||||
time.sleep(0.2)
|
||||
print "Done!\n"
|
||||
print("Done!\n")
|
||||
|
||||
self.expect_cannot_joinsplit(self.nodes[1], joinsplit_BC["rawtxn"])
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2017 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from decimal import Decimal
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_greater_than, start_nodes,\
|
||||
initialize_chain_clean, connect_nodes_bi, wait_and_assert_operationid_status
|
||||
|
||||
from functools import reduce
|
||||
import logging
|
||||
|
||||
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
|
||||
|
@ -38,8 +36,9 @@ class ZkeyImportExportTest (BitcoinTestFramework):
|
|||
# the sender loses 'amount' plus fee; to_addr receives exactly 'amount'
|
||||
def z_send(from_node, from_addr, to_addr, amount):
|
||||
global fee
|
||||
|
||||
opid = from_node.z_sendmany(from_addr,
|
||||
[{"address": to_addr, "amount": Decimal(amount)}], 1, fee)
|
||||
[{"address": to_addr, "amount": Decimal(amount)}], 1, int(fee))
|
||||
wait_and_assert_operationid_status(from_node, opid)
|
||||
self.sync_all()
|
||||
miner.generate(1)
|
||||
|
@ -48,11 +47,7 @@ class ZkeyImportExportTest (BitcoinTestFramework):
|
|||
def verify_utxos(node, amts, zaddr):
|
||||
amts.sort(reverse=True)
|
||||
txs = node.z_listreceivedbyaddress(zaddr)
|
||||
|
||||
def cmp_confirmations_high_to_low(a, b):
|
||||
return cmp(b["amount"], a["amount"])
|
||||
|
||||
txs.sort(cmp_confirmations_high_to_low)
|
||||
txs.sort(key=lambda x: x["amount"], reverse=True)
|
||||
print("Sorted txs", txs)
|
||||
print("amts", amts)
|
||||
|
||||
|
@ -94,11 +89,11 @@ class ZkeyImportExportTest (BitcoinTestFramework):
|
|||
# verify_utxos(charlie, [])
|
||||
|
||||
# the amounts of each txn embodied which generates a single UTXO:
|
||||
amounts = map(Decimal, ['2.3', '3.7', '0.1', '0.5', '1.0', '0.19'])
|
||||
amounts = list(map(Decimal, ['2.3', '3.7', '0.1', '0.5', '1.0', '0.19']))
|
||||
|
||||
# Internal test consistency assertion:
|
||||
assert_greater_than(
|
||||
get_private_balance(alice),
|
||||
Decimal(get_private_balance(alice)),
|
||||
reduce(Decimal.__add__, amounts))
|
||||
|
||||
logging.info("Sending pre-export txns...")
|
||||
|
@ -141,7 +136,7 @@ class ZkeyImportExportTest (BitcoinTestFramework):
|
|||
verify_utxos(charlie, amounts, ipk_zaddr2["address"])
|
||||
|
||||
# keep track of the fees incurred by bob (his sends)
|
||||
bob_fee = Decimal(0)
|
||||
bob_fee = Decimal("0")
|
||||
|
||||
# Try to reproduce zombie balance reported in #1936
|
||||
# At generated zaddr, receive ZEC, and send ZEC back out. bob -> alice
|
||||
|
@ -150,7 +145,8 @@ class ZkeyImportExportTest (BitcoinTestFramework):
|
|||
z_send(bob, bob_zaddr, alice_zaddr, amount)
|
||||
bob_fee += fee
|
||||
|
||||
bob_balance = sum(amounts[2:]) - bob_fee
|
||||
bob_balance = sum(amounts[2:]) - int(bob_fee)
|
||||
|
||||
assert_equal(bob.z_getbalance(bob_zaddr), bob_balance)
|
||||
|
||||
# z_import onto new node "david" (blockchain rescan, default or True?)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2015 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
@ -7,8 +7,6 @@
|
|||
# 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.util import assert_equal, bytes_to_hex_str, start_nodes
|
||||
|
||||
|
@ -38,7 +36,7 @@ class ZMQTest(BitcoinTestFramework):
|
|||
genhashes = self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
print "listen..."
|
||||
print("listen...")
|
||||
msg = self.zmqSubSocket.recv_multipart()
|
||||
topic = msg[0]
|
||||
body = msg[1]
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue