Browse Source

[qa] Switch to py3

pull/1/head
MarcoFalke 7 years ago
parent
commit
fa389d4edc
  1. 10
      .travis.yml
  2. 2
      doc/zmq.md
  3. 4
      qa/README.md
  4. 10
      qa/pull-tester/rpc-tests.py
  5. 6
      qa/pull-tester/tests_config.py.in
  6. 17
      qa/rpc-tests/abandonconflict.py
  7. 15
      qa/rpc-tests/bip65-cltv-p2p.py
  8. 8
      qa/rpc-tests/bip65-cltv.py
  9. 109
      qa/rpc-tests/bip68-112-113-p2p.py
  10. 30
      qa/rpc-tests/bip68-sequence.py
  11. 9
      qa/rpc-tests/bip9-softforks.py
  12. 15
      qa/rpc-tests/bipdersig-p2p.py
  13. 8
      qa/rpc-tests/bipdersig.py
  14. 18
      qa/rpc-tests/blockchain.py
  15. 4
      qa/rpc-tests/decodescript.py
  16. 4
      qa/rpc-tests/disablewallet.py
  17. 4
      qa/rpc-tests/forknotify.py
  18. 12
      qa/rpc-tests/fundrawtransaction.py
  19. 6
      qa/rpc-tests/getblocktemplate_longpoll.py
  20. 12
      qa/rpc-tests/getblocktemplate_proposals.py
  21. 4
      qa/rpc-tests/getchaintips.py
  22. 38
      qa/rpc-tests/httpbasics.py
  23. 4
      qa/rpc-tests/importprunedfunds.py
  24. 30
      qa/rpc-tests/invalidateblock.py
  25. 11
      qa/rpc-tests/invalidblockrequest.py
  26. 11
      qa/rpc-tests/invalidtxrequest.py
  27. 4
      qa/rpc-tests/keypool.py
  28. 4
      qa/rpc-tests/listtransactions.py
  29. 11
      qa/rpc-tests/maxblocksinflight.py
  30. 35
      qa/rpc-tests/maxuploadtarget.py
  31. 6
      qa/rpc-tests/mempool_limit.py
  32. 24
      qa/rpc-tests/mempool_packages.py
  33. 4
      qa/rpc-tests/mempool_reorg.py
  34. 4
      qa/rpc-tests/mempool_resurrect_test.py
  35. 4
      qa/rpc-tests/mempool_spendcoinbase.py
  36. 6
      qa/rpc-tests/merkle_blocks.py
  37. 29
      qa/rpc-tests/multi_rpc.py
  38. 16
      qa/rpc-tests/nodehandling.py
  39. 37
      qa/rpc-tests/p2p-acceptblock.py
  40. 14
      qa/rpc-tests/p2p-feefilter.py
  41. 7
      qa/rpc-tests/p2p-fullblocktest.py
  42. 7
      qa/rpc-tests/p2p-versionbits-warning.py
  43. 14
      qa/rpc-tests/prioritise_transaction.py
  44. 7
      qa/rpc-tests/proxy_test.py
  45. 68
      qa/rpc-tests/pruning.py
  46. 4
      qa/rpc-tests/rawtransactions.py
  47. 4
      qa/rpc-tests/receivedby.py
  48. 6
      qa/rpc-tests/reindex.py
  49. 26
      qa/rpc-tests/replace-by-fee.py
  50. 25
      qa/rpc-tests/rest.py
  51. 6
      qa/rpc-tests/rpcbind_test.py
  52. 45
      qa/rpc-tests/sendheaders.py
  53. 2
      qa/rpc-tests/signmessages.py
  54. 4
      qa/rpc-tests/signrawtransactions.py
  55. 6
      qa/rpc-tests/smartfees.py
  56. 5
      qa/rpc-tests/test_framework/bignum.py
  57. 13
      qa/rpc-tests/test_framework/blockstore.py
  58. 6
      qa/rpc-tests/test_framework/blocktools.py
  59. 17
      qa/rpc-tests/test_framework/comptool.py
  60. 7
      qa/rpc-tests/test_framework/coverage.py
  61. 77
      qa/rpc-tests/test_framework/mininode.py
  62. 4
      qa/rpc-tests/test_framework/netutil.py
  63. 11
      qa/rpc-tests/test_framework/script.py
  64. 9
      qa/rpc-tests/test_framework/socks5.py
  65. 8
      qa/rpc-tests/test_framework/test_framework.py
  66. 21
      qa/rpc-tests/test_framework/util.py
  67. 4
      qa/rpc-tests/txn_clone.py
  68. 4
      qa/rpc-tests/txn_doublespend.py
  69. 8
      qa/rpc-tests/wallet.py
  70. 4
      qa/rpc-tests/walletbackup.py
  71. 6
      qa/rpc-tests/zapwallettxes.py
  72. 17
      qa/rpc-tests/zmq_test.py

10
.travis.yml

@ -37,15 +37,15 @@ matrix: @@ -37,15 +37,15 @@ matrix:
- compiler: ": ARM"
env: HOST=arm-linux-gnueabihf PACKAGES="g++-arm-linux-gnueabihf" DEP_OPTS="NO_QT=1" CHECK_DOC=1 GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
- compiler: ": Win32"
env: HOST=i686-w64-mingw32 DPKG_ADD_ARCH="i386" DEP_OPTS="NO_QT=1" PACKAGES="nsis g++-mingw-w64-i686 wine1.6 bc" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-reduce-exports"
env: HOST=i686-w64-mingw32 DPKG_ADD_ARCH="i386" DEP_OPTS="NO_QT=1" PACKAGES="python3 nsis g++-mingw-w64-i686 wine1.6 bc" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-reduce-exports"
- compiler: ": 32-bit + dash"
env: HOST=i686-pc-linux-gnu PACKAGES="g++-multilib bc python-zmq" DEP_OPTS="NO_QT=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++" USE_SHELL="/bin/dash"
env: HOST=i686-pc-linux-gnu PACKAGES="g++-multilib bc python3-zmq" DEP_OPTS="NO_QT=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++" USE_SHELL="/bin/dash"
- compiler: ": Win64"
env: HOST=x86_64-w64-mingw32 DPKG_ADD_ARCH="i386" DEP_OPTS="NO_QT=1" PACKAGES="nsis g++-mingw-w64-x86-64 wine1.6 bc" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-reduce-exports"
env: HOST=x86_64-w64-mingw32 DPKG_ADD_ARCH="i386" DEP_OPTS="NO_QT=1" PACKAGES="python3 nsis g++-mingw-w64-x86-64 wine1.6 bc" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-reduce-exports"
- compiler: ": bitcoind"
env: HOST=x86_64-unknown-linux-gnu PACKAGES="bc python-zmq" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER"
env: HOST=x86_64-unknown-linux-gnu PACKAGES="bc python3-zmq" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER"
- compiler: ": No wallet"
env: HOST=x86_64-unknown-linux-gnu DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
env: HOST=x86_64-unknown-linux-gnu PACKAGES="python3" DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
- compiler: ": Cross-Mac"
env: HOST=x86_64-apple-darwin11 PACKAGES="cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev" BITCOIN_CONFIG="--enable-reduce-exports" OSX_SDK=10.9 GOAL="deploy"
exclude:

2
doc/zmq.md

@ -38,7 +38,7 @@ newer. Typically, it is packaged by distributions as something like @@ -38,7 +38,7 @@ newer. Typically, it is packaged by distributions as something like
*libzmq3-dev*. The C++ wrapper for ZeroMQ is *not* needed.
In order to run the example Python client scripts in contrib/ one must
also install *python-zmq*, though this is not necessary for daemon
also install *python3-zmq*, though this is not necessary for daemon
operation.
## Enabling

4
qa/README.md

@ -11,9 +11,9 @@ Before running the tests, the following must be installed. @@ -11,9 +11,9 @@ Before running the tests, the following must be installed.
Unix
----
The python-zmq library is required. On Ubuntu or Debian it can be installed via:
The python3-zmq library is required. On Ubuntu or Debian it can be installed via:
```
sudo apt-get install python-zmq
sudo apt-get install python3-zmq
```
Running tests

10
qa/pull-tester/rpc-tests.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -70,14 +70,14 @@ if "BITCOINCLI" not in os.environ: @@ -70,14 +70,14 @@ if "BITCOINCLI" not in os.environ:
if EXEEXT == ".exe" and "-win" not in opts:
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
# https://github.com/bitcoin/bitcoin/pull/5677#issuecomment-136646964
print "Win tests currently disabled by default. Use -win option to enable"
print("Win tests currently disabled by default. Use -win option to enable")
sys.exit(0)
if not (ENABLE_WALLET == 1 and ENABLE_UTILS == 1 and ENABLE_BITCOIND == 1):
print "No rpc tests to run. Wallet, utils, and bitcoind must all be enabled"
print("No rpc tests to run. Wallet, utils, and bitcoind must all be enabled")
sys.exit(0)
# python-zmq may not be installed. Handle this gracefully and with some helpful info
# python3-zmq may not be installed. Handle this gracefully and with some helpful info
if ENABLE_ZMQ:
try:
import zmq

6
qa/pull-tester/tests_config.py.in

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2013-2014 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2013-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -11,5 +11,3 @@ EXEEXT="@EXEEXT@" @@ -11,5 +11,3 @@ EXEEXT="@EXEEXT@"
@BUILD_BITCOIN_UTILS_TRUE@ENABLE_UTILS=1
@BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=1
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=1

17
qa/rpc-tests/abandonconflict.py

@ -1,15 +1,12 @@ @@ -1,15 +1,12 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
try:
import urllib.parse as urlparse
except ImportError:
import urlparse
import urllib.parse
class AbandonConflictTest(BitcoinTestFramework):
@ -34,7 +31,7 @@ class AbandonConflictTest(BitcoinTestFramework): @@ -34,7 +31,7 @@ class AbandonConflictTest(BitcoinTestFramework):
assert(balance - newbalance < Decimal("0.001")) #no more than fees lost
balance = newbalance
url = urlparse.urlparse(self.nodes[1].url)
url = urllib.parse.urlparse(self.nodes[1].url)
self.nodes[0].disconnectnode(url.hostname+":"+str(p2p_port(1)))
# Identify the 10btc outputs
@ -151,9 +148,9 @@ class AbandonConflictTest(BitcoinTestFramework): @@ -151,9 +148,9 @@ class AbandonConflictTest(BitcoinTestFramework):
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
newbalance = self.nodes[0].getbalance()
#assert(newbalance == balance - Decimal("10"))
print "If balance has not declined after invalidateblock then out of mempool wallet tx which is no longer"
print "conflicted has not resumed causing its inputs to be seen as spent. See Issue #7315"
print balance , " -> " , newbalance , " ?"
print("If balance has not declined after invalidateblock then out of mempool wallet tx which is no longer")
print("conflicted has not resumed causing its inputs to be seen as spent. See Issue #7315")
print(str(balance) + " -> " + str(newbalance) + " ?")
if __name__ == '__main__':
AbandonConflictTest().main()

15
qa/rpc-tests/bip65-cltv-p2p.py

@ -1,8 +1,7 @@ @@ -1,8 +1,7 @@
#!/usr/bin/env python2
# Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT/X11 software license, see the accompanying
#!/usr/bin/env python3
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
@ -67,13 +66,13 @@ class BIP65Test(ComparisonTestFramework): @@ -67,13 +66,13 @@ class BIP65Test(ComparisonTestFramework):
self.coinbase_blocks = self.nodes[0].generate(2)
height = 3 # height of the next block to build
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.tip = int("0x" + self.nodes[0].getbestblockhash(), 0)
self.nodeaddress = self.nodes[0].getnewaddress()
self.last_block_time = int(time.time())
''' 98 more version 3 blocks '''
test_blocks = []
for i in xrange(98):
for i in range(98):
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
block.nVersion = 3
block.rehash()
@ -86,7 +85,7 @@ class BIP65Test(ComparisonTestFramework): @@ -86,7 +85,7 @@ class BIP65Test(ComparisonTestFramework):
''' Mine 749 version 4 blocks '''
test_blocks = []
for i in xrange(749):
for i in range(749):
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
block.nVersion = 4
block.rehash()
@ -138,7 +137,7 @@ class BIP65Test(ComparisonTestFramework): @@ -138,7 +137,7 @@ class BIP65Test(ComparisonTestFramework):
''' Mine 199 new version blocks on last valid tip '''
test_blocks = []
for i in xrange(199):
for i in range(199):
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
block.nVersion = 4
block.rehash()

8
qa/rpc-tests/bip65-cltv.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -32,7 +32,7 @@ class BIP65Test(BitcoinTestFramework): @@ -32,7 +32,7 @@ class BIP65Test(BitcoinTestFramework):
raise AssertionError("Failed to mine 100 version=3 blocks")
# Mine 750 new-version blocks
for i in xrange(15):
for i in range(15):
self.nodes[2].generate(50)
self.sync_all()
if (self.nodes[0].getblockcount() != cnt + 850):
@ -49,7 +49,7 @@ class BIP65Test(BitcoinTestFramework): @@ -49,7 +49,7 @@ class BIP65Test(BitcoinTestFramework):
# TODO: check that new CHECKLOCKTIMEVERIFY rules are enforced
# Mine 198 new-version blocks
for i in xrange(2):
for i in range(2):
self.nodes[2].generate(99)
self.sync_all()
if (self.nodes[0].getblockcount() != cnt + 1049):

109
qa/rpc-tests/bip68-112-113-p2p.py

@ -1,8 +1,7 @@ @@ -1,8 +1,7 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT/X11 software license, see the accompanying
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
@ -63,13 +62,13 @@ seq_random_low_bit = 1<<18 @@ -63,13 +62,13 @@ seq_random_low_bit = 1<<18
# b31,b25,b22,b18 represent the 31st, 25th, 22nd and 18th bits respectively in the nSequence field
# relative_locktimes[b31][b25][b22][b18] is a base_relative_locktime with the indicated bits set if their indices are 1
relative_locktimes = []
for b31 in xrange(2):
for b31 in range(2):
b25times = []
for b25 in xrange(2):
for b25 in range(2):
b22times = []
for b22 in xrange(2):
for b22 in range(2):
b18times = []
for b18 in xrange(2):
for b18 in range(2):
rlt = base_relative_locktime
if (b31):
rlt = rlt | seq_disable_flag
@ -86,10 +85,10 @@ for b31 in xrange(2): @@ -86,10 +85,10 @@ for b31 in xrange(2):
def all_rlt_txs(txarray):
txs = []
for b31 in xrange(2):
for b25 in xrange(2):
for b22 in xrange(2):
for b18 in xrange(2):
for b31 in range(2):
for b25 in range(2):
for b22 in range(2):
for b18 in range(2):
txs.append(txarray[b31][b25][b22][b18])
return txs
@ -131,7 +130,7 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -131,7 +130,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
return tx
def generate_blocks(self, number, version, test_blocks = []):
for i in xrange(number):
for i in range(number):
block = self.create_test_block([], version)
test_blocks.append([block, True])
self.last_block_time += 600
@ -152,13 +151,13 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -152,13 +151,13 @@ class BIP68_112_113Test(ComparisonTestFramework):
txs = []
assert(len(bip68inputs) >= 16)
i = 0
for b31 in xrange(2):
for b31 in range(2):
b25txs = []
for b25 in xrange(2):
for b25 in range(2):
b22txs = []
for b22 in xrange(2):
for b22 in range(2):
b18txs = []
for b18 in xrange(2):
for b18 in range(2):
tx = self.create_transaction(self.nodes[0], bip68inputs[i], self.nodeaddress, Decimal("49.98"))
i += 1
tx.nVersion = txversion
@ -180,13 +179,13 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -180,13 +179,13 @@ class BIP68_112_113Test(ComparisonTestFramework):
txs = []
assert(len(bip112inputs) >= 16)
i = 0
for b31 in xrange(2):
for b31 in range(2):
b25txs = []
for b25 in xrange(2):
for b25 in range(2):
b22txs = []
for b22 in xrange(2):
for b22 in range(2):
b18txs = []
for b18 in xrange(2):
for b18 in range(2):
tx = self.create_transaction(self.nodes[0], bip112inputs[i], self.nodeaddress, Decimal("49.98"))
i += 1
if (varyOP_CSV): # if varying OP_CSV, nSequence is fixed
@ -212,7 +211,7 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -212,7 +211,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
self.nodes[0].setmocktime(0) # set time back to present so yielded blocks aren't in the future as we advance last_block_time
self.tipheight = 82 # height of the next block to build
self.last_block_time = long_past_time
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.tip = int("0x" + self.nodes[0].getbestblockhash(), 0)
self.nodeaddress = self.nodes[0].getnewaddress()
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'defined')
@ -250,20 +249,20 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -250,20 +249,20 @@ class BIP68_112_113Test(ComparisonTestFramework):
# Note we reuse inputs for v1 and v2 txs so must test these separately
# 16 normal inputs
bip68inputs = []
for i in xrange(16):
for i in range(16):
bip68inputs.append(self.send_generic_input_tx(self.nodes[0], self.coinbase_blocks))
# 2 sets of 16 inputs with 10 OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
bip112basicinputs = []
for j in xrange(2):
for j in range(2):
inputs = []
for i in xrange(16):
for i in range(16):
inputs.append(self.send_generic_input_tx(self.nodes[0], self.coinbase_blocks))
bip112basicinputs.append(inputs)
# 2 sets of 16 varied inputs with (relative_lock_time) OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
bip112diverseinputs = []
for j in xrange(2):
for j in range(2):
inputs = []
for i in xrange(16):
for i in range(16):
inputs.append(self.send_generic_input_tx(self.nodes[0], self.coinbase_blocks))
bip112diverseinputs.append(inputs)
# 1 special input with -1 OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
@ -274,7 +273,7 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -274,7 +273,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
self.nodes[0].setmocktime(self.last_block_time + 600)
inputblockhash = self.nodes[0].generate(1)[0] # 1 block generated for inputs to be in chain at height 572
self.nodes[0].setmocktime(0)
self.tip = int("0x" + inputblockhash + "L", 0)
self.tip = int("0x" + inputblockhash, 0)
self.tipheight += 1
self.last_block_time += 600
assert_equal(len(self.nodes[0].getblock(inputblockhash,True)["tx"]), 82+1)
@ -398,22 +397,22 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -398,22 +397,22 @@ class BIP68_112_113Test(ComparisonTestFramework):
### Version 2 txs ###
bip68success_txs = []
# All txs with SEQUENCE_LOCKTIME_DISABLE_FLAG set pass
for b25 in xrange(2):
for b22 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b22 in range(2):
for b18 in range(2):
bip68success_txs.append(bip68txs_v2[1][b25][b22][b18])
yield TestInstance([[self.create_test_block(bip68success_txs), True]]) # 15
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
# All txs without flag fail as we are at delta height = 8 < 10 and delta time = 8 * 600 < 10 * 512
bip68timetxs = []
for b25 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b18 in range(2):
bip68timetxs.append(bip68txs_v2[0][b25][1][b18])
for tx in bip68timetxs:
yield TestInstance([[self.create_test_block([tx]), False]]) # 16 - 19
bip68heighttxs = []
for b25 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b18 in range(2):
bip68heighttxs.append(bip68txs_v2[0][b25][0][b18])
for tx in bip68heighttxs:
yield TestInstance([[self.create_test_block([tx]), False]]) # 20 - 23
@ -445,9 +444,9 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -445,9 +444,9 @@ class BIP68_112_113Test(ComparisonTestFramework):
yield TestInstance([[self.create_test_block([bip112tx_special_v1]), False]]) #32
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 1 txs should still pass
success_txs = []
for b25 in xrange(2):
for b22 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b22 in range(2):
for b18 in range(2):
success_txs.append(bip112txs_vary_OP_CSV_v1[1][b25][b22][b18])
success_txs.append(bip112txs_vary_OP_CSV_9_v1[1][b25][b22][b18])
yield TestInstance([[self.create_test_block(success_txs), True]]) # 33
@ -457,9 +456,9 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -457,9 +456,9 @@ class BIP68_112_113Test(ComparisonTestFramework):
fail_txs = []
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_v1))
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v1))
for b25 in xrange(2):
for b22 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b22 in range(2):
for b18 in range(2):
fail_txs.append(bip112txs_vary_OP_CSV_v1[0][b25][b22][b18])
fail_txs.append(bip112txs_vary_OP_CSV_9_v1[0][b25][b22][b18])
@ -472,9 +471,9 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -472,9 +471,9 @@ class BIP68_112_113Test(ComparisonTestFramework):
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 2 txs should pass (all sequence locks are met)
success_txs = []
for b25 in xrange(2):
for b22 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b22 in range(2):
for b18 in range(2):
success_txs.append(bip112txs_vary_OP_CSV_v2[1][b25][b22][b18]) # 8/16 of vary_OP_CSV
success_txs.append(bip112txs_vary_OP_CSV_9_v2[1][b25][b22][b18]) # 8/16 of vary_OP_CSV_9
@ -485,9 +484,9 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -485,9 +484,9 @@ class BIP68_112_113Test(ComparisonTestFramework):
# All txs with nSequence 9 should fail either due to earlier mismatch or failing the CSV check
fail_txs = []
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v2)) # 16/16 of vary_nSequence_9
for b25 in xrange(2):
for b22 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b22 in range(2):
for b18 in range(2):
fail_txs.append(bip112txs_vary_OP_CSV_9_v2[0][b25][b22][b18]) # 16/16 of vary_OP_CSV_9
for tx in fail_txs:
@ -495,17 +494,17 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -495,17 +494,17 @@ class BIP68_112_113Test(ComparisonTestFramework):
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in nSequence, tx should fail
fail_txs = []
for b25 in xrange(2):
for b22 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b22 in range(2):
for b18 in range(2):
fail_txs.append(bip112txs_vary_nSequence_v2[1][b25][b22][b18]) # 8/16 of vary_nSequence
for tx in fail_txs:
yield TestInstance([[self.create_test_block([tx]), False]]) # 108-115
# If sequencelock types mismatch, tx should fail
fail_txs = []
for b25 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b18 in range(2):
fail_txs.append(bip112txs_vary_nSequence_v2[0][b25][1][b18]) # 12/16 of vary_nSequence
fail_txs.append(bip112txs_vary_OP_CSV_v2[0][b25][1][b18]) # 12/16 of vary_OP_CSV
for tx in fail_txs:
@ -513,8 +512,8 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -513,8 +512,8 @@ class BIP68_112_113Test(ComparisonTestFramework):
# Remaining txs should pass, just test masking works properly
success_txs = []
for b25 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b18 in range(2):
success_txs.append(bip112txs_vary_nSequence_v2[0][b25][0][b18]) # 16/16 of vary_nSequence
success_txs.append(bip112txs_vary_OP_CSV_v2[0][b25][0][b18]) # 16/16 of vary_OP_CSV
yield TestInstance([[self.create_test_block(success_txs), True]]) # 124
@ -522,8 +521,8 @@ class BIP68_112_113Test(ComparisonTestFramework): @@ -522,8 +521,8 @@ class BIP68_112_113Test(ComparisonTestFramework):
# Additional test, of checking that comparison of two time types works properly
time_txs = []
for b25 in xrange(2):
for b18 in xrange(2):
for b25 in range(2):
for b18 in range(2):
tx = bip112txs_vary_OP_CSV_v2[0][b25][1][b18]
tx.vin[0].nSequence = base_relative_locktime | seq_type_flag
signtx = self.sign_transaction(self.nodes[0], tx)

30
qa/rpc-tests/bip68-sequence.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -35,28 +35,28 @@ class BIP68Test(BitcoinTestFramework): @@ -35,28 +35,28 @@ class BIP68Test(BitcoinTestFramework):
# Generate some coins
self.nodes[0].generate(110)
print "Running test disable flag"
print("Running test disable flag")
self.test_disable_flag()
print "Running test sequence-lock-confirmed-inputs"
print("Running test sequence-lock-confirmed-inputs")
self.test_sequence_lock_confirmed_inputs()
print "Running test sequence-lock-unconfirmed-inputs"
print("Running test sequence-lock-unconfirmed-inputs")
self.test_sequence_lock_unconfirmed_inputs()
print "Running test BIP68 not consensus before versionbits activation"
print("Running test BIP68 not consensus before versionbits activation")
self.test_bip68_not_consensus()
print "Verifying nVersion=2 transactions aren't standard"
print("Verifying nVersion=2 transactions aren't standard")
self.test_version2_relay(before_activation=True)
print "Activating BIP68 (and 112/113)"
print("Activating BIP68 (and 112/113)")
self.activateCSV()
print "Verifying nVersion=2 transactions are now standard"
print("Verifying nVersion=2 transactions are now standard")
self.test_version2_relay(before_activation=False)
print "Passed\n"
print("Passed\n")
# Test that BIP68 is not in effect if tx version is 1, or if
# the first sequence bit is set.
@ -125,7 +125,7 @@ class BIP68Test(BitcoinTestFramework): @@ -125,7 +125,7 @@ class BIP68Test(BitcoinTestFramework):
random.shuffle(addresses)
num_outputs = random.randint(1, max_outputs)
outputs = {}
for i in xrange(num_outputs):
for i in range(num_outputs):
outputs[addresses[i]] = random.randint(1, 20)*0.01
self.nodes[0].sendmany("", outputs)
self.nodes[0].generate(1)
@ -137,7 +137,7 @@ class BIP68Test(BitcoinTestFramework): @@ -137,7 +137,7 @@ class BIP68Test(BitcoinTestFramework):
# some of those inputs to be sequence locked (and randomly choose
# between height/time locking). Small random chance of making the locks
# all pass.
for i in xrange(400):
for i in range(400):
# Randomly choose up to 10 inputs
num_inputs = random.randint(1, 10)
random.shuffle(utxos)
@ -151,7 +151,7 @@ class BIP68Test(BitcoinTestFramework): @@ -151,7 +151,7 @@ class BIP68Test(BitcoinTestFramework):
tx = CTransaction()
tx.nVersion = 2
value = 0
for j in xrange(num_inputs):
for j in range(num_inputs):
sequence_value = 0xfffffffe # this disables sequence locks
# 50% chance we enable sequence locks
@ -259,7 +259,7 @@ class BIP68Test(BitcoinTestFramework): @@ -259,7 +259,7 @@ class BIP68Test(BitcoinTestFramework):
# Use prioritisetransaction to lower the effective feerate to 0
self.nodes[0].prioritisetransaction(tx2.hash, -1e15, int(-self.relayfee*COIN))
cur_time = int(time.time())
for i in xrange(10):
for i in range(10):
self.nodes[0].setmocktime(cur_time + 600)
self.nodes[0].generate(1)
cur_time += 600
@ -324,7 +324,7 @@ class BIP68Test(BitcoinTestFramework): @@ -324,7 +324,7 @@ class BIP68Test(BitcoinTestFramework):
# tx3 to be removed.
tip = int(self.nodes[0].getblockhash(self.nodes[0].getblockcount()-1), 16)
height = self.nodes[0].getblockcount()
for i in xrange(2):
for i in range(2):
block = create_block(tip, create_coinbase(height), cur_time)
block.nVersion = 3
block.rehash()

9
qa/rpc-tests/bip9-softforks.py

@ -1,8 +1,7 @@ @@ -1,8 +1,7 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT/X11 software license, see the accompanying
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
@ -64,7 +63,7 @@ class BIP9SoftForksTest(ComparisonTestFramework): @@ -64,7 +63,7 @@ class BIP9SoftForksTest(ComparisonTestFramework):
return tx
def generate_blocks(self, number, version, test_blocks = []):
for i in xrange(number):
for i in range(number):
block = create_block(self.tip, create_coinbase(self.height), self.last_block_time + 1)
block.nVersion = version
block.rehash()
@ -83,7 +82,7 @@ class BIP9SoftForksTest(ComparisonTestFramework): @@ -83,7 +82,7 @@ class BIP9SoftForksTest(ComparisonTestFramework):
# generate some coins for later
self.coinbase_blocks = self.nodes[0].generate(2)
self.height = 3 # height of the next block to build
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.tip = int("0x" + self.nodes[0].getbestblockhash(), 0)
self.nodeaddress = self.nodes[0].getnewaddress()
self.last_block_time = int(time.time())

15
qa/rpc-tests/bipdersig-p2p.py

@ -1,8 +1,7 @@ @@ -1,8 +1,7 @@
#!/usr/bin/env python2
# Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT/X11 software license, see the accompanying
#!/usr/bin/env python3
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
@ -75,13 +74,13 @@ class BIP66Test(ComparisonTestFramework): @@ -75,13 +74,13 @@ class BIP66Test(ComparisonTestFramework):
self.coinbase_blocks = self.nodes[0].generate(2)
height = 3 # height of the next block to build
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.tip = int("0x" + self.nodes[0].getbestblockhash(), 0)
self.nodeaddress = self.nodes[0].getnewaddress()
self.last_block_time = int(time.time())
''' 98 more version 2 blocks '''
test_blocks = []
for i in xrange(98):
for i in range(98):
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
block.nVersion = 2
block.rehash()
@ -94,7 +93,7 @@ class BIP66Test(ComparisonTestFramework): @@ -94,7 +93,7 @@ class BIP66Test(ComparisonTestFramework):
''' Mine 749 version 3 blocks '''
test_blocks = []
for i in xrange(749):
for i in range(749):
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
block.nVersion = 3
block.rehash()
@ -146,7 +145,7 @@ class BIP66Test(ComparisonTestFramework): @@ -146,7 +145,7 @@ class BIP66Test(ComparisonTestFramework):
''' Mine 199 new version blocks on last valid tip '''
test_blocks = []
for i in xrange(199):
for i in range(199):
block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
block.nVersion = 3
block.rehash()

8
qa/rpc-tests/bipdersig.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -32,7 +32,7 @@ class BIP66Test(BitcoinTestFramework): @@ -32,7 +32,7 @@ class BIP66Test(BitcoinTestFramework):
raise AssertionError("Failed to mine 100 version=2 blocks")
# Mine 750 new-version blocks
for i in xrange(15):
for i in range(15):
self.nodes[2].generate(50)
self.sync_all()
if (self.nodes[0].getblockcount() != cnt + 850):
@ -49,7 +49,7 @@ class BIP66Test(BitcoinTestFramework): @@ -49,7 +49,7 @@ class BIP66Test(BitcoinTestFramework):
# TODO: check that new DERSIG rules are enforced
# Mine 198 new-version blocks
for i in xrange(2):
for i in range(2):
self.nodes[2].generate(99)
self.sync_all()
if (self.nodes[0].getblockcount() != cnt + 1049):

18
qa/rpc-tests/blockchain.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -51,13 +51,13 @@ class BlockchainTest(BitcoinTestFramework): @@ -51,13 +51,13 @@ class BlockchainTest(BitcoinTestFramework):
node = self.nodes[0]
res = node.gettxoutsetinfo()
assert_equal(res[u'total_amount'], Decimal('8725.00000000'))
assert_equal(res[u'transactions'], 200)
assert_equal(res[u'height'], 200)
assert_equal(res[u'txouts'], 200)
assert_equal(res[u'bytes_serialized'], 13924),
assert_equal(len(res[u'bestblock']), 64)
assert_equal(len(res[u'hash_serialized']), 64)
assert_equal(res['total_amount'], Decimal('8725.00000000'))
assert_equal(res['transactions'], 200)
assert_equal(res['height'], 200)
assert_equal(res['txouts'], 200)
assert_equal(res['bytes_serialized'], 13924),
assert_equal(len(res['bestblock']), 64)
assert_equal(len(res['hash_serialized']), 64)
def _test_getblockheader(self):
node = self.nodes[0]

4
qa/rpc-tests/decodescript.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

4
qa/rpc-tests/disablewallet.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

4
qa/rpc-tests/forknotify.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 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
qa/rpc-tests/fundrawtransaction.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -10,7 +10,7 @@ from test_framework.util import * @@ -10,7 +10,7 @@ from test_framework.util import *
class RawTransactionsTest(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, 4)
def setup_network(self, split=False):
@ -25,7 +25,7 @@ class RawTransactionsTest(BitcoinTestFramework): @@ -25,7 +25,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.sync_all()
def run_test(self):
print "Mining blocks..."
print("Mining blocks...")
min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee']
# This test is not meant to test fee estimation and we'd like
@ -198,7 +198,7 @@ class RawTransactionsTest(BitcoinTestFramework): @@ -198,7 +198,7 @@ class RawTransactionsTest(BitcoinTestFramework):
try:
self.nodes[2].fundrawtransaction(rawtx, {'foo': 'bar'})
raise AssertionError("Accepted invalid option foo")
except JSONRPCException,e:
except JSONRPCException as e:
assert("Unexpected key foo" in e.error['message'])
@ -223,7 +223,7 @@ class RawTransactionsTest(BitcoinTestFramework): @@ -223,7 +223,7 @@ class RawTransactionsTest(BitcoinTestFramework):
try:
self.nodes[2].fundrawtransaction(rawtx, {'changeAddress': 'foobar'})
raise AssertionError("Accepted invalid bitcoin address")
except JSONRPCException,e:
except JSONRPCException as e:
assert("changeAddress must be a valid bitcoin address" in e.error['message'])

6
qa/rpc-tests/getblocktemplate_longpoll.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -27,7 +27,7 @@ class GetBlockTemplateLPTest(BitcoinTestFramework): @@ -27,7 +27,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']

12
qa/rpc-tests/getblocktemplate_proposals.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -46,7 +46,7 @@ def genmrklroot(leaflist): @@ -46,7 +46,7 @@ def genmrklroot(leaflist):
cur = n
return cur[0]
def template_to_bytes(tmpl, txlist):
def template_to_bytearray(tmpl, txlist):
blkver = pack('<L', tmpl['version'])
mrklroot = genmrklroot(list(dblsha(a) for a in txlist))
timestamp = pack('<L', tmpl['curtime'])
@ -55,10 +55,10 @@ def template_to_bytes(tmpl, txlist): @@ -55,10 +55,10 @@ def template_to_bytes(tmpl, txlist):
blk += varlenEncode(len(txlist))
for tx in txlist:
blk += tx
return blk
return bytearray(blk)
def template_to_hex(tmpl, txlist):
return b2x(template_to_bytes(tmpl, txlist))
return b2x(template_to_bytearray(tmpl, txlist))
def assert_template(node, tmpl, txlist, expect):
rsp = node.getblocktemplate({'data':template_to_hex(tmpl, txlist),'mode':'proposal'})
@ -129,7 +129,7 @@ class GetBlockTemplateProposalTest(BitcoinTestFramework): @@ -129,7 +129,7 @@ class GetBlockTemplateProposalTest(BitcoinTestFramework):
tmpl['bits'] = realbits
# Test 9: Bad merkle root
rawtmpl = template_to_bytes(tmpl, txlist)
rawtmpl = template_to_bytearray(tmpl, txlist)
rawtmpl[4+32] = (rawtmpl[4+32] + 1) % 0x100
rsp = node.getblocktemplate({'data':b2x(rawtmpl),'mode':'proposal'})
if rsp != 'bad-txnmrklroot':

4
qa/rpc-tests/getchaintips.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

38
qa/rpc-tests/httpbasics.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -10,14 +10,8 @@ @@ -10,14 +10,8 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
try:
import http.client as httplib
except ImportError:
import httplib
try:
import urllib.parse as urlparse
except ImportError:
import urlparse
import http.client
import urllib.parse
class HTTPBasicsTest (BitcoinTestFramework):
def setup_nodes(self):
@ -28,11 +22,11 @@ class HTTPBasicsTest (BitcoinTestFramework): @@ -28,11 +22,11 @@ class HTTPBasicsTest (BitcoinTestFramework):
#################################################
# lowlevel check for http persistent connection #
#################################################
url = urlparse.urlparse(self.nodes[0].url)
url = urllib.parse.urlparse(self.nodes[0].url)
authpair = url.username + ':' + url.password
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
conn = httplib.HTTPConnection(url.hostname, url.port)
conn = http.client.HTTPConnection(url.hostname, url.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read()
@ -49,7 +43,7 @@ class HTTPBasicsTest (BitcoinTestFramework): @@ -49,7 +43,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
#same should be if we add keep-alive because this should be the std. behaviour
headers = {"Authorization": "Basic " + str_to_b64str(authpair), "Connection": "keep-alive"}
conn = httplib.HTTPConnection(url.hostname, url.port)
conn = http.client.HTTPConnection(url.hostname, url.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read()
@ -66,7 +60,7 @@ class HTTPBasicsTest (BitcoinTestFramework): @@ -66,7 +60,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
#now do the same with "Connection: close"
headers = {"Authorization": "Basic " + str_to_b64str(authpair), "Connection":"close"}
conn = httplib.HTTPConnection(url.hostname, url.port)
conn = http.client.HTTPConnection(url.hostname, url.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read()
@ -74,22 +68,22 @@ class HTTPBasicsTest (BitcoinTestFramework): @@ -74,22 +68,22 @@ class HTTPBasicsTest (BitcoinTestFramework):
assert(conn.sock==None) #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 = urllib.parse.urlparse(self.nodes[1].url)
authpair = urlNode1.username + ':' + urlNode1.password
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
conn = httplib.HTTPConnection(urlNode1.hostname, urlNode1.port)
conn = http.client.HTTPConnection(urlNode1.hostname, urlNode1.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read()
assert(b'"error":null' in out1)
#node2 (third node) is running with standard keep-alive parameters which means keep-alive is on
urlNode2 = urlparse.urlparse(self.nodes[2].url)
urlNode2 = urllib.parse.urlparse(self.nodes[2].url)
authpair = urlNode2.username + ':' + urlNode2.password
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port)
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read()
@ -97,17 +91,17 @@ class HTTPBasicsTest (BitcoinTestFramework): @@ -97,17 +91,17 @@ class HTTPBasicsTest (BitcoinTestFramework):
assert(conn.sock!=None) #connection must be closed because bitcoind should use keep-alive by default
# Check excessive request size
conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port)
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
conn.connect()
conn.request('GET', '/' + ('x'*1000), '', headers)
out1 = conn.getresponse()
assert_equal(out1.status, httplib.NOT_FOUND)
assert_equal(out1.status, http.client.NOT_FOUND)
conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port)
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
conn.connect()
conn.request('GET', '/' + ('x'*10000), '', headers)
out1 = conn.getresponse()
assert_equal(out1.status, httplib.BAD_REQUEST)
assert_equal(out1.status, http.client.BAD_REQUEST)
if __name__ == '__main__':

4
qa/rpc-tests/importprunedfunds.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -23,7 +23,7 @@ class ImportPrunedFundsTest(BitcoinTestFramework): @@ -23,7 +23,7 @@ class ImportPrunedFundsTest(BitcoinTestFramework):
import time
begintime = int(time.time())
print "Mining blocks..."
print("Mining blocks...")
self.nodes[0].generate(101)
# sync

30
qa/rpc-tests/invalidateblock.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -25,46 +25,46 @@ class InvalidateTest(BitcoinTestFramework): @@ -25,46 +25,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()

11
qa/rpc-tests/invalidblockrequest.py

@ -1,8 +1,7 @@ @@ -1,8 +1,7 @@
#!/usr/bin/env python2
# Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT/X11 software license, see the accompanying
#!/usr/bin/env python3
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
@ -38,7 +37,7 @@ class InvalidBlockRequestTest(ComparisonTestFramework): @@ -38,7 +37,7 @@ class InvalidBlockRequestTest(ComparisonTestFramework):
def get_tests(self):
if self.tip is None:
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.tip = int("0x" + self.nodes[0].getbestblockhash(), 0)
self.block_time = int(time.time())+1
'''
@ -58,7 +57,7 @@ class InvalidBlockRequestTest(ComparisonTestFramework): @@ -58,7 +57,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(height), self.block_time)
block.solve()
self.tip = block.sha256

11
qa/rpc-tests/invalidtxrequest.py

@ -1,8 +1,7 @@ @@ -1,8 +1,7 @@
#!/usr/bin/env python2
# Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT/X11 software license, see the accompanying
#!/usr/bin/env python3
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
from test_framework.test_framework import ComparisonTestFramework
from test_framework.comptool import TestManager, TestInstance, RejectResult
@ -32,7 +31,7 @@ class InvalidTxRequestTest(ComparisonTestFramework): @@ -32,7 +31,7 @@ class InvalidTxRequestTest(ComparisonTestFramework):
def get_tests(self):
if self.tip is None:
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
self.tip = int("0x" + self.nodes[0].getbestblockhash(), 0)
self.block_time = int(time.time())+1
'''
@ -52,7 +51,7 @@ class InvalidTxRequestTest(ComparisonTestFramework): @@ -52,7 +51,7 @@ class InvalidTxRequestTest(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(height), self.block_time)
block.solve()
self.tip = block.sha256

4
qa/rpc-tests/keypool.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

4
qa/rpc-tests/listtransactions.py

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/usr/bin/env python2
# Copyright (c) 2014-2015 The Bitcoin Core developers
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

11
qa/rpc-tests/maxblocksinflight.py

@ -1,8 +1,7 @@ @@ -1,8 +1,7 @@
#!/usr/bin/env python2
# Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT/X11 software license, see the accompanying
#!/usr/bin/env python3
# Copyright (c) 2015-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
@ -65,7 +64,7 @@ class TestManager(NodeConnCB): @@ -65,7 +64,7 @@ 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))
self.disconnectOkay = True
self.connection.disconnect_node()
@ -78,7 +77,7 @@ class MaxBlocksInFlightTest(BitcoinTestFramework): @@ -78,7 +77,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 d