[qa] Switch to py3
This commit is contained in:
parent
3b9a0bf41f
commit
fa389d4edc
72 changed files with 504 additions and 547 deletions
10
.travis.yml
10
.travis.yml
|
@ -37,15 +37,15 @@ matrix:
|
||||||
- compiler: ": ARM"
|
- 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"
|
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"
|
- 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"
|
- 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"
|
- 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"
|
- 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"
|
- 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"
|
- 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"
|
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:
|
exclude:
|
||||||
|
|
|
@ -38,7 +38,7 @@ newer. Typically, it is packaged by distributions as something like
|
||||||
*libzmq3-dev*. The C++ wrapper for ZeroMQ is *not* needed.
|
*libzmq3-dev*. The C++ wrapper for ZeroMQ is *not* needed.
|
||||||
|
|
||||||
In order to run the example Python client scripts in contrib/ one must
|
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.
|
operation.
|
||||||
|
|
||||||
## Enabling
|
## Enabling
|
||||||
|
|
|
@ -11,9 +11,9 @@ Before running the tests, the following must be installed.
|
||||||
|
|
||||||
Unix
|
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
|
Running tests
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -70,14 +70,14 @@ if "BITCOINCLI" not in os.environ:
|
||||||
if EXEEXT == ".exe" and "-win" not in opts:
|
if EXEEXT == ".exe" and "-win" not in opts:
|
||||||
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
|
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
|
||||||
# https://github.com/bitcoin/bitcoin/pull/5677#issuecomment-136646964
|
# 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)
|
sys.exit(0)
|
||||||
|
|
||||||
if not (ENABLE_WALLET == 1 and ENABLE_UTILS == 1 and ENABLE_BITCOIND == 1):
|
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)
|
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:
|
if ENABLE_ZMQ:
|
||||||
try:
|
try:
|
||||||
import zmq
|
import zmq
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2013-2014 The Bitcoin Core developers
|
# Copyright (c) 2013-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -11,5 +11,3 @@ EXEEXT="@EXEEXT@"
|
||||||
@BUILD_BITCOIN_UTILS_TRUE@ENABLE_UTILS=1
|
@BUILD_BITCOIN_UTILS_TRUE@ENABLE_UTILS=1
|
||||||
@BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=1
|
@BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=1
|
||||||
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=1
|
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
try:
|
import urllib.parse
|
||||||
import urllib.parse as urlparse
|
|
||||||
except ImportError:
|
|
||||||
import urlparse
|
|
||||||
|
|
||||||
class AbandonConflictTest(BitcoinTestFramework):
|
class AbandonConflictTest(BitcoinTestFramework):
|
||||||
|
|
||||||
|
@ -34,7 +31,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
||||||
assert(balance - newbalance < Decimal("0.001")) #no more than fees lost
|
assert(balance - newbalance < Decimal("0.001")) #no more than fees lost
|
||||||
balance = newbalance
|
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)))
|
self.nodes[0].disconnectnode(url.hostname+":"+str(p2p_port(1)))
|
||||||
|
|
||||||
# Identify the 10btc outputs
|
# Identify the 10btc outputs
|
||||||
|
@ -151,9 +148,9 @@ class AbandonConflictTest(BitcoinTestFramework):
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
newbalance = self.nodes[0].getbalance()
|
newbalance = self.nodes[0].getbalance()
|
||||||
#assert(newbalance == balance - Decimal("10"))
|
#assert(newbalance == balance - Decimal("10"))
|
||||||
print "If balance has not declined after invalidateblock then out of mempool wallet tx which is no longer"
|
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("conflicted has not resumed causing its inputs to be seen as spent. See Issue #7315")
|
||||||
print balance , " -> " , newbalance , " ?"
|
print(str(balance) + " -> " + str(newbalance) + " ?")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
AbandonConflictTest().main()
|
AbandonConflictTest().main()
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.test_framework import ComparisonTestFramework
|
from test_framework.test_framework import ComparisonTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
|
@ -67,13 +66,13 @@ class BIP65Test(ComparisonTestFramework):
|
||||||
|
|
||||||
self.coinbase_blocks = self.nodes[0].generate(2)
|
self.coinbase_blocks = self.nodes[0].generate(2)
|
||||||
height = 3 # height of the next block to build
|
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.nodeaddress = self.nodes[0].getnewaddress()
|
||||||
self.last_block_time = int(time.time())
|
self.last_block_time = int(time.time())
|
||||||
|
|
||||||
''' 98 more version 3 blocks '''
|
''' 98 more version 3 blocks '''
|
||||||
test_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 = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 3
|
block.nVersion = 3
|
||||||
block.rehash()
|
block.rehash()
|
||||||
|
@ -86,7 +85,7 @@ class BIP65Test(ComparisonTestFramework):
|
||||||
|
|
||||||
''' Mine 749 version 4 blocks '''
|
''' Mine 749 version 4 blocks '''
|
||||||
test_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 = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 4
|
block.nVersion = 4
|
||||||
block.rehash()
|
block.rehash()
|
||||||
|
@ -138,7 +137,7 @@ class BIP65Test(ComparisonTestFramework):
|
||||||
|
|
||||||
''' Mine 199 new version blocks on last valid tip '''
|
''' Mine 199 new version blocks on last valid tip '''
|
||||||
test_blocks = []
|
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 = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 4
|
block.nVersion = 4
|
||||||
block.rehash()
|
block.rehash()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class BIP65Test(BitcoinTestFramework):
|
||||||
raise AssertionError("Failed to mine 100 version=3 blocks")
|
raise AssertionError("Failed to mine 100 version=3 blocks")
|
||||||
|
|
||||||
# Mine 750 new-version blocks
|
# Mine 750 new-version blocks
|
||||||
for i in xrange(15):
|
for i in range(15):
|
||||||
self.nodes[2].generate(50)
|
self.nodes[2].generate(50)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
if (self.nodes[0].getblockcount() != cnt + 850):
|
if (self.nodes[0].getblockcount() != cnt + 850):
|
||||||
|
@ -49,7 +49,7 @@ class BIP65Test(BitcoinTestFramework):
|
||||||
# TODO: check that new CHECKLOCKTIMEVERIFY rules are enforced
|
# TODO: check that new CHECKLOCKTIMEVERIFY rules are enforced
|
||||||
|
|
||||||
# Mine 198 new-version blocks
|
# Mine 198 new-version blocks
|
||||||
for i in xrange(2):
|
for i in range(2):
|
||||||
self.nodes[2].generate(99)
|
self.nodes[2].generate(99)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
if (self.nodes[0].getblockcount() != cnt + 1049):
|
if (self.nodes[0].getblockcount() != cnt + 1049):
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.test_framework import ComparisonTestFramework
|
from test_framework.test_framework import ComparisonTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
|
@ -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
|
# 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[b31][b25][b22][b18] is a base_relative_locktime with the indicated bits set if their indices are 1
|
||||||
relative_locktimes = []
|
relative_locktimes = []
|
||||||
for b31 in xrange(2):
|
for b31 in range(2):
|
||||||
b25times = []
|
b25times = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
b22times = []
|
b22times = []
|
||||||
for b22 in xrange(2):
|
for b22 in range(2):
|
||||||
b18times = []
|
b18times = []
|
||||||
for b18 in xrange(2):
|
for b18 in range(2):
|
||||||
rlt = base_relative_locktime
|
rlt = base_relative_locktime
|
||||||
if (b31):
|
if (b31):
|
||||||
rlt = rlt | seq_disable_flag
|
rlt = rlt | seq_disable_flag
|
||||||
|
@ -86,10 +85,10 @@ for b31 in xrange(2):
|
||||||
|
|
||||||
def all_rlt_txs(txarray):
|
def all_rlt_txs(txarray):
|
||||||
txs = []
|
txs = []
|
||||||
for b31 in xrange(2):
|
for b31 in range(2):
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b22 in xrange(2):
|
for b22 in range(2):
|
||||||
for b18 in xrange(2):
|
for b18 in range(2):
|
||||||
txs.append(txarray[b31][b25][b22][b18])
|
txs.append(txarray[b31][b25][b22][b18])
|
||||||
return txs
|
return txs
|
||||||
|
|
||||||
|
@ -131,7 +130,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
def generate_blocks(self, number, version, test_blocks = []):
|
def generate_blocks(self, number, version, test_blocks = []):
|
||||||
for i in xrange(number):
|
for i in range(number):
|
||||||
block = self.create_test_block([], version)
|
block = self.create_test_block([], version)
|
||||||
test_blocks.append([block, True])
|
test_blocks.append([block, True])
|
||||||
self.last_block_time += 600
|
self.last_block_time += 600
|
||||||
|
@ -152,13 +151,13 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
||||||
txs = []
|
txs = []
|
||||||
assert(len(bip68inputs) >= 16)
|
assert(len(bip68inputs) >= 16)
|
||||||
i = 0
|
i = 0
|
||||||
for b31 in xrange(2):
|
for b31 in range(2):
|
||||||
b25txs = []
|
b25txs = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
b22txs = []
|
b22txs = []
|
||||||
for b22 in xrange(2):
|
for b22 in range(2):
|
||||||
b18txs = []
|
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"))
|
tx = self.create_transaction(self.nodes[0], bip68inputs[i], self.nodeaddress, Decimal("49.98"))
|
||||||
i += 1
|
i += 1
|
||||||
tx.nVersion = txversion
|
tx.nVersion = txversion
|
||||||
|
@ -180,13 +179,13 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
||||||
txs = []
|
txs = []
|
||||||
assert(len(bip112inputs) >= 16)
|
assert(len(bip112inputs) >= 16)
|
||||||
i = 0
|
i = 0
|
||||||
for b31 in xrange(2):
|
for b31 in range(2):
|
||||||
b25txs = []
|
b25txs = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
b22txs = []
|
b22txs = []
|
||||||
for b22 in xrange(2):
|
for b22 in range(2):
|
||||||
b18txs = []
|
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"))
|
tx = self.create_transaction(self.nodes[0], bip112inputs[i], self.nodeaddress, Decimal("49.98"))
|
||||||
i += 1
|
i += 1
|
||||||
if (varyOP_CSV): # if varying OP_CSV, nSequence is fixed
|
if (varyOP_CSV): # if varying OP_CSV, nSequence is fixed
|
||||||
|
@ -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.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.tipheight = 82 # height of the next block to build
|
||||||
self.last_block_time = long_past_time
|
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()
|
self.nodeaddress = self.nodes[0].getnewaddress()
|
||||||
|
|
||||||
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'defined')
|
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'defined')
|
||||||
|
@ -250,20 +249,20 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
||||||
# Note we reuse inputs for v1 and v2 txs so must test these separately
|
# Note we reuse inputs for v1 and v2 txs so must test these separately
|
||||||
# 16 normal inputs
|
# 16 normal inputs
|
||||||
bip68inputs = []
|
bip68inputs = []
|
||||||
for i in xrange(16):
|
for i in range(16):
|
||||||
bip68inputs.append(self.send_generic_input_tx(self.nodes[0], self.coinbase_blocks))
|
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)
|
# 2 sets of 16 inputs with 10 OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
|
||||||
bip112basicinputs = []
|
bip112basicinputs = []
|
||||||
for j in xrange(2):
|
for j in range(2):
|
||||||
inputs = []
|
inputs = []
|
||||||
for i in xrange(16):
|
for i in range(16):
|
||||||
inputs.append(self.send_generic_input_tx(self.nodes[0], self.coinbase_blocks))
|
inputs.append(self.send_generic_input_tx(self.nodes[0], self.coinbase_blocks))
|
||||||
bip112basicinputs.append(inputs)
|
bip112basicinputs.append(inputs)
|
||||||
# 2 sets of 16 varied inputs with (relative_lock_time) OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
|
# 2 sets of 16 varied inputs with (relative_lock_time) OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
|
||||||
bip112diverseinputs = []
|
bip112diverseinputs = []
|
||||||
for j in xrange(2):
|
for j in range(2):
|
||||||
inputs = []
|
inputs = []
|
||||||
for i in xrange(16):
|
for i in range(16):
|
||||||
inputs.append(self.send_generic_input_tx(self.nodes[0], self.coinbase_blocks))
|
inputs.append(self.send_generic_input_tx(self.nodes[0], self.coinbase_blocks))
|
||||||
bip112diverseinputs.append(inputs)
|
bip112diverseinputs.append(inputs)
|
||||||
# 1 special input with -1 OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
|
# 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):
|
||||||
self.nodes[0].setmocktime(self.last_block_time + 600)
|
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
|
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.nodes[0].setmocktime(0)
|
||||||
self.tip = int("0x" + inputblockhash + "L", 0)
|
self.tip = int("0x" + inputblockhash, 0)
|
||||||
self.tipheight += 1
|
self.tipheight += 1
|
||||||
self.last_block_time += 600
|
self.last_block_time += 600
|
||||||
assert_equal(len(self.nodes[0].getblock(inputblockhash,True)["tx"]), 82+1)
|
assert_equal(len(self.nodes[0].getblock(inputblockhash,True)["tx"]), 82+1)
|
||||||
|
@ -398,22 +397,22 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
||||||
### Version 2 txs ###
|
### Version 2 txs ###
|
||||||
bip68success_txs = []
|
bip68success_txs = []
|
||||||
# All txs with SEQUENCE_LOCKTIME_DISABLE_FLAG set pass
|
# All txs with SEQUENCE_LOCKTIME_DISABLE_FLAG set pass
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b22 in xrange(2):
|
for b22 in range(2):
|
||||||
for b18 in xrange(2):
|
for b18 in range(2):
|
||||||
bip68success_txs.append(bip68txs_v2[1][b25][b22][b18])
|
bip68success_txs.append(bip68txs_v2[1][b25][b22][b18])
|
||||||
yield TestInstance([[self.create_test_block(bip68success_txs), True]]) # 15
|
yield TestInstance([[self.create_test_block(bip68success_txs), True]]) # 15
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
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
|
# All txs without flag fail as we are at delta height = 8 < 10 and delta time = 8 * 600 < 10 * 512
|
||||||
bip68timetxs = []
|
bip68timetxs = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b18 in xrange(2):
|
for b18 in range(2):
|
||||||
bip68timetxs.append(bip68txs_v2[0][b25][1][b18])
|
bip68timetxs.append(bip68txs_v2[0][b25][1][b18])
|
||||||
for tx in bip68timetxs:
|
for tx in bip68timetxs:
|
||||||
yield TestInstance([[self.create_test_block([tx]), False]]) # 16 - 19
|
yield TestInstance([[self.create_test_block([tx]), False]]) # 16 - 19
|
||||||
bip68heighttxs = []
|
bip68heighttxs = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b18 in xrange(2):
|
for b18 in range(2):
|
||||||
bip68heighttxs.append(bip68txs_v2[0][b25][0][b18])
|
bip68heighttxs.append(bip68txs_v2[0][b25][0][b18])
|
||||||
for tx in bip68heighttxs:
|
for tx in bip68heighttxs:
|
||||||
yield TestInstance([[self.create_test_block([tx]), False]]) # 20 - 23
|
yield TestInstance([[self.create_test_block([tx]), False]]) # 20 - 23
|
||||||
|
@ -445,9 +444,9 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
||||||
yield TestInstance([[self.create_test_block([bip112tx_special_v1]), False]]) #32
|
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
|
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 1 txs should still pass
|
||||||
success_txs = []
|
success_txs = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b22 in xrange(2):
|
for b22 in range(2):
|
||||||
for b18 in xrange(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_v1[1][b25][b22][b18])
|
||||||
success_txs.append(bip112txs_vary_OP_CSV_9_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
|
yield TestInstance([[self.create_test_block(success_txs), True]]) # 33
|
||||||
|
@ -457,9 +456,9 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
||||||
fail_txs = []
|
fail_txs = []
|
||||||
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_v1))
|
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_v1))
|
||||||
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v1))
|
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v1))
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b22 in xrange(2):
|
for b22 in range(2):
|
||||||
for b18 in xrange(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_v1[0][b25][b22][b18])
|
||||||
fail_txs.append(bip112txs_vary_OP_CSV_9_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):
|
||||||
|
|
||||||
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 2 txs should pass (all sequence locks are met)
|
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 2 txs should pass (all sequence locks are met)
|
||||||
success_txs = []
|
success_txs = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b22 in xrange(2):
|
for b22 in range(2):
|
||||||
for b18 in xrange(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_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
|
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):
|
||||||
# All txs with nSequence 9 should fail either due to earlier mismatch or failing the CSV check
|
# All txs with nSequence 9 should fail either due to earlier mismatch or failing the CSV check
|
||||||
fail_txs = []
|
fail_txs = []
|
||||||
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v2)) # 16/16 of vary_nSequence_9
|
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v2)) # 16/16 of vary_nSequence_9
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b22 in xrange(2):
|
for b22 in range(2):
|
||||||
for b18 in xrange(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
|
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:
|
for tx in fail_txs:
|
||||||
|
@ -495,17 +494,17 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
||||||
|
|
||||||
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in nSequence, tx should fail
|
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in nSequence, tx should fail
|
||||||
fail_txs = []
|
fail_txs = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b22 in xrange(2):
|
for b22 in range(2):
|
||||||
for b18 in xrange(2):
|
for b18 in range(2):
|
||||||
fail_txs.append(bip112txs_vary_nSequence_v2[1][b25][b22][b18]) # 8/16 of vary_nSequence
|
fail_txs.append(bip112txs_vary_nSequence_v2[1][b25][b22][b18]) # 8/16 of vary_nSequence
|
||||||
for tx in fail_txs:
|
for tx in fail_txs:
|
||||||
yield TestInstance([[self.create_test_block([tx]), False]]) # 108-115
|
yield TestInstance([[self.create_test_block([tx]), False]]) # 108-115
|
||||||
|
|
||||||
# If sequencelock types mismatch, tx should fail
|
# If sequencelock types mismatch, tx should fail
|
||||||
fail_txs = []
|
fail_txs = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b18 in xrange(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_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
|
fail_txs.append(bip112txs_vary_OP_CSV_v2[0][b25][1][b18]) # 12/16 of vary_OP_CSV
|
||||||
for tx in fail_txs:
|
for tx in fail_txs:
|
||||||
|
@ -513,8 +512,8 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
||||||
|
|
||||||
# Remaining txs should pass, just test masking works properly
|
# Remaining txs should pass, just test masking works properly
|
||||||
success_txs = []
|
success_txs = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b18 in xrange(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_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
|
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
|
yield TestInstance([[self.create_test_block(success_txs), True]]) # 124
|
||||||
|
@ -522,8 +521,8 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
||||||
|
|
||||||
# Additional test, of checking that comparison of two time types works properly
|
# Additional test, of checking that comparison of two time types works properly
|
||||||
time_txs = []
|
time_txs = []
|
||||||
for b25 in xrange(2):
|
for b25 in range(2):
|
||||||
for b18 in xrange(2):
|
for b18 in range(2):
|
||||||
tx = bip112txs_vary_OP_CSV_v2[0][b25][1][b18]
|
tx = bip112txs_vary_OP_CSV_v2[0][b25][1][b18]
|
||||||
tx.vin[0].nSequence = base_relative_locktime | seq_type_flag
|
tx.vin[0].nSequence = base_relative_locktime | seq_type_flag
|
||||||
signtx = self.sign_transaction(self.nodes[0], tx)
|
signtx = self.sign_transaction(self.nodes[0], tx)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -35,28 +35,28 @@ class BIP68Test(BitcoinTestFramework):
|
||||||
# Generate some coins
|
# Generate some coins
|
||||||
self.nodes[0].generate(110)
|
self.nodes[0].generate(110)
|
||||||
|
|
||||||
print "Running test disable flag"
|
print("Running test disable flag")
|
||||||
self.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()
|
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()
|
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()
|
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)
|
self.test_version2_relay(before_activation=True)
|
||||||
|
|
||||||
print "Activating BIP68 (and 112/113)"
|
print("Activating BIP68 (and 112/113)")
|
||||||
self.activateCSV()
|
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)
|
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
|
# Test that BIP68 is not in effect if tx version is 1, or if
|
||||||
# the first sequence bit is set.
|
# the first sequence bit is set.
|
||||||
|
@ -125,7 +125,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||||
random.shuffle(addresses)
|
random.shuffle(addresses)
|
||||||
num_outputs = random.randint(1, max_outputs)
|
num_outputs = random.randint(1, max_outputs)
|
||||||
outputs = {}
|
outputs = {}
|
||||||
for i in xrange(num_outputs):
|
for i in range(num_outputs):
|
||||||
outputs[addresses[i]] = random.randint(1, 20)*0.01
|
outputs[addresses[i]] = random.randint(1, 20)*0.01
|
||||||
self.nodes[0].sendmany("", outputs)
|
self.nodes[0].sendmany("", outputs)
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
|
@ -137,7 +137,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||||
# some of those inputs to be sequence locked (and randomly choose
|
# some of those inputs to be sequence locked (and randomly choose
|
||||||
# between height/time locking). Small random chance of making the locks
|
# between height/time locking). Small random chance of making the locks
|
||||||
# all pass.
|
# all pass.
|
||||||
for i in xrange(400):
|
for i in range(400):
|
||||||
# Randomly choose up to 10 inputs
|
# Randomly choose up to 10 inputs
|
||||||
num_inputs = random.randint(1, 10)
|
num_inputs = random.randint(1, 10)
|
||||||
random.shuffle(utxos)
|
random.shuffle(utxos)
|
||||||
|
@ -151,7 +151,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||||
tx = CTransaction()
|
tx = CTransaction()
|
||||||
tx.nVersion = 2
|
tx.nVersion = 2
|
||||||
value = 0
|
value = 0
|
||||||
for j in xrange(num_inputs):
|
for j in range(num_inputs):
|
||||||
sequence_value = 0xfffffffe # this disables sequence locks
|
sequence_value = 0xfffffffe # this disables sequence locks
|
||||||
|
|
||||||
# 50% chance we enable sequence locks
|
# 50% chance we enable sequence locks
|
||||||
|
@ -259,7 +259,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||||
# Use prioritisetransaction to lower the effective feerate to 0
|
# Use prioritisetransaction to lower the effective feerate to 0
|
||||||
self.nodes[0].prioritisetransaction(tx2.hash, -1e15, int(-self.relayfee*COIN))
|
self.nodes[0].prioritisetransaction(tx2.hash, -1e15, int(-self.relayfee*COIN))
|
||||||
cur_time = int(time.time())
|
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].setmocktime(cur_time + 600)
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
cur_time += 600
|
cur_time += 600
|
||||||
|
@ -324,7 +324,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||||
# tx3 to be removed.
|
# tx3 to be removed.
|
||||||
tip = int(self.nodes[0].getblockhash(self.nodes[0].getblockcount()-1), 16)
|
tip = int(self.nodes[0].getblockhash(self.nodes[0].getblockcount()-1), 16)
|
||||||
height = self.nodes[0].getblockcount()
|
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 = create_block(tip, create_coinbase(height), cur_time)
|
||||||
block.nVersion = 3
|
block.nVersion = 3
|
||||||
block.rehash()
|
block.rehash()
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.test_framework import ComparisonTestFramework
|
from test_framework.test_framework import ComparisonTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
|
@ -64,7 +63,7 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
def generate_blocks(self, number, version, test_blocks = []):
|
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 = create_block(self.tip, create_coinbase(self.height), self.last_block_time + 1)
|
||||||
block.nVersion = version
|
block.nVersion = version
|
||||||
block.rehash()
|
block.rehash()
|
||||||
|
@ -83,7 +82,7 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
||||||
# generate some coins for later
|
# generate some coins for later
|
||||||
self.coinbase_blocks = self.nodes[0].generate(2)
|
self.coinbase_blocks = self.nodes[0].generate(2)
|
||||||
self.height = 3 # height of the next block to build
|
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.nodeaddress = self.nodes[0].getnewaddress()
|
||||||
self.last_block_time = int(time.time())
|
self.last_block_time = int(time.time())
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.test_framework import ComparisonTestFramework
|
from test_framework.test_framework import ComparisonTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
|
@ -75,13 +74,13 @@ class BIP66Test(ComparisonTestFramework):
|
||||||
|
|
||||||
self.coinbase_blocks = self.nodes[0].generate(2)
|
self.coinbase_blocks = self.nodes[0].generate(2)
|
||||||
height = 3 # height of the next block to build
|
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.nodeaddress = self.nodes[0].getnewaddress()
|
||||||
self.last_block_time = int(time.time())
|
self.last_block_time = int(time.time())
|
||||||
|
|
||||||
''' 98 more version 2 blocks '''
|
''' 98 more version 2 blocks '''
|
||||||
test_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 = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 2
|
block.nVersion = 2
|
||||||
block.rehash()
|
block.rehash()
|
||||||
|
@ -94,7 +93,7 @@ class BIP66Test(ComparisonTestFramework):
|
||||||
|
|
||||||
''' Mine 749 version 3 blocks '''
|
''' Mine 749 version 3 blocks '''
|
||||||
test_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 = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 3
|
block.nVersion = 3
|
||||||
block.rehash()
|
block.rehash()
|
||||||
|
@ -146,7 +145,7 @@ class BIP66Test(ComparisonTestFramework):
|
||||||
|
|
||||||
''' Mine 199 new version blocks on last valid tip '''
|
''' Mine 199 new version blocks on last valid tip '''
|
||||||
test_blocks = []
|
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 = create_block(self.tip, create_coinbase(height), self.last_block_time + 1)
|
||||||
block.nVersion = 3
|
block.nVersion = 3
|
||||||
block.rehash()
|
block.rehash()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class BIP66Test(BitcoinTestFramework):
|
||||||
raise AssertionError("Failed to mine 100 version=2 blocks")
|
raise AssertionError("Failed to mine 100 version=2 blocks")
|
||||||
|
|
||||||
# Mine 750 new-version blocks
|
# Mine 750 new-version blocks
|
||||||
for i in xrange(15):
|
for i in range(15):
|
||||||
self.nodes[2].generate(50)
|
self.nodes[2].generate(50)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
if (self.nodes[0].getblockcount() != cnt + 850):
|
if (self.nodes[0].getblockcount() != cnt + 850):
|
||||||
|
@ -49,7 +49,7 @@ class BIP66Test(BitcoinTestFramework):
|
||||||
# TODO: check that new DERSIG rules are enforced
|
# TODO: check that new DERSIG rules are enforced
|
||||||
|
|
||||||
# Mine 198 new-version blocks
|
# Mine 198 new-version blocks
|
||||||
for i in xrange(2):
|
for i in range(2):
|
||||||
self.nodes[2].generate(99)
|
self.nodes[2].generate(99)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
if (self.nodes[0].getblockcount() != cnt + 1049):
|
if (self.nodes[0].getblockcount() != cnt + 1049):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -51,13 +51,13 @@ class BlockchainTest(BitcoinTestFramework):
|
||||||
node = self.nodes[0]
|
node = self.nodes[0]
|
||||||
res = node.gettxoutsetinfo()
|
res = node.gettxoutsetinfo()
|
||||||
|
|
||||||
assert_equal(res[u'total_amount'], Decimal('8725.00000000'))
|
assert_equal(res['total_amount'], Decimal('8725.00000000'))
|
||||||
assert_equal(res[u'transactions'], 200)
|
assert_equal(res['transactions'], 200)
|
||||||
assert_equal(res[u'height'], 200)
|
assert_equal(res['height'], 200)
|
||||||
assert_equal(res[u'txouts'], 200)
|
assert_equal(res['txouts'], 200)
|
||||||
assert_equal(res[u'bytes_serialized'], 13924),
|
assert_equal(res['bytes_serialized'], 13924),
|
||||||
assert_equal(len(res[u'bestblock']), 64)
|
assert_equal(len(res['bestblock']), 64)
|
||||||
assert_equal(len(res[u'hash_serialized']), 64)
|
assert_equal(len(res['hash_serialized']), 64)
|
||||||
|
|
||||||
def _test_getblockheader(self):
|
def _test_getblockheader(self):
|
||||||
node = self.nodes[0]
|
node = self.nodes[0]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ from test_framework.util import *
|
||||||
class RawTransactionsTest(BitcoinTestFramework):
|
class RawTransactionsTest(BitcoinTestFramework):
|
||||||
|
|
||||||
def setup_chain(self):
|
def setup_chain(self):
|
||||||
print("Initializing test directory "+self.options.tmpdir)
|
print(("Initializing test directory "+self.options.tmpdir))
|
||||||
initialize_chain_clean(self.options.tmpdir, 4)
|
initialize_chain_clean(self.options.tmpdir, 4)
|
||||||
|
|
||||||
def setup_network(self, split=False):
|
def setup_network(self, split=False):
|
||||||
|
@ -25,7 +25,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
print "Mining blocks..."
|
print("Mining blocks...")
|
||||||
|
|
||||||
min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee']
|
min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee']
|
||||||
# This test is not meant to test fee estimation and we'd like
|
# This test is not meant to test fee estimation and we'd like
|
||||||
|
@ -198,7 +198,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||||
try:
|
try:
|
||||||
self.nodes[2].fundrawtransaction(rawtx, {'foo': 'bar'})
|
self.nodes[2].fundrawtransaction(rawtx, {'foo': 'bar'})
|
||||||
raise AssertionError("Accepted invalid option foo")
|
raise AssertionError("Accepted invalid option foo")
|
||||||
except JSONRPCException,e:
|
except JSONRPCException as e:
|
||||||
assert("Unexpected key foo" in e.error['message'])
|
assert("Unexpected key foo" in e.error['message'])
|
||||||
|
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||||
try:
|
try:
|
||||||
self.nodes[2].fundrawtransaction(rawtx, {'changeAddress': 'foobar'})
|
self.nodes[2].fundrawtransaction(rawtx, {'changeAddress': 'foobar'})
|
||||||
raise AssertionError("Accepted invalid bitcoin address")
|
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'])
|
assert("changeAddress must be a valid bitcoin address" in e.error['message'])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class GetBlockTemplateLPTest(BitcoinTestFramework):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def run_test(self):
|
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)
|
self.nodes[0].generate(10)
|
||||||
templat = self.nodes[0].getblocktemplate()
|
templat = self.nodes[0].getblocktemplate()
|
||||||
longpollid = templat['longpollid']
|
longpollid = templat['longpollid']
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ def genmrklroot(leaflist):
|
||||||
cur = n
|
cur = n
|
||||||
return cur[0]
|
return cur[0]
|
||||||
|
|
||||||
def template_to_bytes(tmpl, txlist):
|
def template_to_bytearray(tmpl, txlist):
|
||||||
blkver = pack('<L', tmpl['version'])
|
blkver = pack('<L', tmpl['version'])
|
||||||
mrklroot = genmrklroot(list(dblsha(a) for a in txlist))
|
mrklroot = genmrklroot(list(dblsha(a) for a in txlist))
|
||||||
timestamp = pack('<L', tmpl['curtime'])
|
timestamp = pack('<L', tmpl['curtime'])
|
||||||
|
@ -55,10 +55,10 @@ def template_to_bytes(tmpl, txlist):
|
||||||
blk += varlenEncode(len(txlist))
|
blk += varlenEncode(len(txlist))
|
||||||
for tx in txlist:
|
for tx in txlist:
|
||||||
blk += tx
|
blk += tx
|
||||||
return blk
|
return bytearray(blk)
|
||||||
|
|
||||||
def template_to_hex(tmpl, txlist):
|
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):
|
def assert_template(node, tmpl, txlist, expect):
|
||||||
rsp = node.getblocktemplate({'data':template_to_hex(tmpl, txlist),'mode':'proposal'})
|
rsp = node.getblocktemplate({'data':template_to_hex(tmpl, txlist),'mode':'proposal'})
|
||||||
|
@ -129,7 +129,7 @@ class GetBlockTemplateProposalTest(BitcoinTestFramework):
|
||||||
tmpl['bits'] = realbits
|
tmpl['bits'] = realbits
|
||||||
|
|
||||||
# Test 9: Bad merkle root
|
# 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
|
rawtmpl[4+32] = (rawtmpl[4+32] + 1) % 0x100
|
||||||
rsp = node.getblocktemplate({'data':b2x(rawtmpl),'mode':'proposal'})
|
rsp = node.getblocktemplate({'data':b2x(rawtmpl),'mode':'proposal'})
|
||||||
if rsp != 'bad-txnmrklroot':
|
if rsp != 'bad-txnmrklroot':
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -10,14 +10,8 @@
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
|
|
||||||
try:
|
import http.client
|
||||||
import http.client as httplib
|
import urllib.parse
|
||||||
except ImportError:
|
|
||||||
import httplib
|
|
||||||
try:
|
|
||||||
import urllib.parse as urlparse
|
|
||||||
except ImportError:
|
|
||||||
import urlparse
|
|
||||||
|
|
||||||
class HTTPBasicsTest (BitcoinTestFramework):
|
class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
def setup_nodes(self):
|
def setup_nodes(self):
|
||||||
|
@ -28,11 +22,11 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
#################################################
|
#################################################
|
||||||
# lowlevel check for http persistent connection #
|
# 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
|
authpair = url.username + ':' + url.password
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
|
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.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
|
@ -49,7 +43,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
#same should be if we add keep-alive because this should be the std. behaviour
|
#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"}
|
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.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
|
@ -66,7 +60,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
#now do the same with "Connection: close"
|
#now do the same with "Connection: close"
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair), "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.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
|
@ -74,22 +68,22 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
assert(conn.sock==None) #now the connection must be closed after the response
|
assert(conn.sock==None) #now the connection must be closed after the response
|
||||||
|
|
||||||
#node1 (2nd node) is running with disabled keep-alive option
|
#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
|
authpair = urlNode1.username + ':' + urlNode1.password
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
|
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.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
assert(b'"error":null' in out1)
|
assert(b'"error":null' in out1)
|
||||||
|
|
||||||
#node2 (third node) is running with standard keep-alive parameters which means keep-alive is on
|
#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
|
authpair = urlNode2.username + ':' + urlNode2.password
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
|
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.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
out1 = conn.getresponse().read()
|
out1 = conn.getresponse().read()
|
||||||
|
@ -97,17 +91,17 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
assert(conn.sock!=None) #connection must be closed because bitcoind should use keep-alive by default
|
assert(conn.sock!=None) #connection must be closed because bitcoind should use keep-alive by default
|
||||||
|
|
||||||
# Check excessive request size
|
# Check excessive request size
|
||||||
conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port)
|
conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
|
||||||
conn.connect()
|
conn.connect()
|
||||||
conn.request('GET', '/' + ('x'*1000), '', headers)
|
conn.request('GET', '/' + ('x'*1000), '', headers)
|
||||||
out1 = conn.getresponse()
|
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.connect()
|
||||||
conn.request('GET', '/' + ('x'*10000), '', headers)
|
conn.request('GET', '/' + ('x'*10000), '', headers)
|
||||||
out1 = conn.getresponse()
|
out1 = conn.getresponse()
|
||||||
assert_equal(out1.status, httplib.BAD_REQUEST)
|
assert_equal(out1.status, http.client.BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
@ -23,7 +23,7 @@ class ImportPrunedFundsTest(BitcoinTestFramework):
|
||||||
import time
|
import time
|
||||||
begintime = int(time.time())
|
begintime = int(time.time())
|
||||||
|
|
||||||
print "Mining blocks..."
|
print("Mining blocks...")
|
||||||
self.nodes[0].generate(101)
|
self.nodes[0].generate(101)
|
||||||
|
|
||||||
# sync
|
# sync
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -25,46 +25,46 @@ class InvalidateTest(BitcoinTestFramework):
|
||||||
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug"]))
|
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug"]))
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
print "Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:"
|
print("Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:")
|
||||||
print "Mine 4 blocks on Node 0"
|
print("Mine 4 blocks on Node 0")
|
||||||
self.nodes[0].generate(4)
|
self.nodes[0].generate(4)
|
||||||
assert(self.nodes[0].getblockcount() == 4)
|
assert(self.nodes[0].getblockcount() == 4)
|
||||||
besthash = self.nodes[0].getbestblockhash()
|
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)
|
self.nodes[1].generate(6)
|
||||||
assert(self.nodes[1].getblockcount() == 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)
|
connect_nodes_bi(self.nodes,0,1)
|
||||||
sync_blocks(self.nodes[0:2])
|
sync_blocks(self.nodes[0:2])
|
||||||
assert(self.nodes[0].getblockcount() == 6)
|
assert(self.nodes[0].getblockcount() == 6)
|
||||||
badhash = self.nodes[1].getblockhash(2)
|
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)
|
self.nodes[0].invalidateblock(badhash)
|
||||||
newheight = self.nodes[0].getblockcount()
|
newheight = self.nodes[0].getblockcount()
|
||||||
newhash = self.nodes[0].getbestblockhash()
|
newhash = self.nodes[0].getbestblockhash()
|
||||||
if (newheight != 4 or newhash != besthash):
|
if (newheight != 4 or newhash != besthash):
|
||||||
raise AssertionError("Wrong tip for node0, hash %s, height %d"%(newhash,newheight))
|
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)
|
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])
|
sync_blocks(self.nodes[1:3])
|
||||||
assert(self.nodes[2].getblockcount() == 6)
|
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))
|
self.nodes[1].invalidateblock(self.nodes[1].getblockhash(5))
|
||||||
assert(self.nodes[1].getblockcount() == 4)
|
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))
|
self.nodes[2].invalidateblock(self.nodes[2].getblockhash(3))
|
||||||
assert(self.nodes[2].getblockcount() == 2)
|
assert(self.nodes[2].getblockcount() == 2)
|
||||||
print "..and then mine a block"
|
print("..and then mine a block")
|
||||||
self.nodes[2].generate(1)
|
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)
|
time.sleep(5)
|
||||||
for i in xrange(3):
|
for i in range(3):
|
||||||
print i,self.nodes[i].getblockcount()
|
print(i,self.nodes[i].getblockcount())
|
||||||
assert(self.nodes[2].getblockcount() == 3)
|
assert(self.nodes[2].getblockcount() == 3)
|
||||||
assert(self.nodes[0].getblockcount() == 4)
|
assert(self.nodes[0].getblockcount() == 4)
|
||||||
node1height = self.nodes[1].getblockcount()
|
node1height = self.nodes[1].getblockcount()
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.test_framework import ComparisonTestFramework
|
from test_framework.test_framework import ComparisonTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
|
@ -38,7 +37,7 @@ class InvalidBlockRequestTest(ComparisonTestFramework):
|
||||||
|
|
||||||
def get_tests(self):
|
def get_tests(self):
|
||||||
if self.tip is None:
|
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
|
self.block_time = int(time.time())+1
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -58,7 +57,7 @@ class InvalidBlockRequestTest(ComparisonTestFramework):
|
||||||
Now we need that block to mature so we can spend the coinbase.
|
Now we need that block to mature so we can spend the coinbase.
|
||||||
'''
|
'''
|
||||||
test = TestInstance(sync_every_block=False)
|
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 = create_block(self.tip, create_coinbase(height), self.block_time)
|
||||||
block.solve()
|
block.solve()
|
||||||
self.tip = block.sha256
|
self.tip = block.sha256
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.test_framework import ComparisonTestFramework
|
from test_framework.test_framework import ComparisonTestFramework
|
||||||
from test_framework.comptool import TestManager, TestInstance, RejectResult
|
from test_framework.comptool import TestManager, TestInstance, RejectResult
|
||||||
|
@ -32,7 +31,7 @@ class InvalidTxRequestTest(ComparisonTestFramework):
|
||||||
|
|
||||||
def get_tests(self):
|
def get_tests(self):
|
||||||
if self.tip is None:
|
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
|
self.block_time = int(time.time())+1
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -52,7 +51,7 @@ class InvalidTxRequestTest(ComparisonTestFramework):
|
||||||
Now we need that block to mature so we can spend the coinbase.
|
Now we need that block to mature so we can spend the coinbase.
|
||||||
'''
|
'''
|
||||||
test = TestInstance(sync_every_block=False)
|
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 = create_block(self.tip, create_coinbase(height), self.block_time)
|
||||||
block.solve()
|
block.solve()
|
||||||
self.tip = block.sha256
|
self.tip = block.sha256
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.mininode import *
|
from test_framework.mininode import *
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
|
@ -65,7 +64,7 @@ class TestManager(NodeConnCB):
|
||||||
raise AssertionError("Error, test failed: block %064x requested more than once" % key)
|
raise AssertionError("Error, test failed: block %064x requested more than once" % key)
|
||||||
if total_requests > MAX_REQUESTS:
|
if total_requests > MAX_REQUESTS:
|
||||||
raise AssertionError("Error, too many blocks (%d) requested" % total_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.disconnectOkay = True
|
||||||
self.connection.disconnect_node()
|
self.connection.disconnect_node()
|
||||||
|
@ -78,7 +77,7 @@ class MaxBlocksInFlightTest(BitcoinTestFramework):
|
||||||
help="Binary to test max block requests behavior")
|
help="Binary to test max block requests behavior")
|
||||||
|
|
||||||
def setup_chain(self):
|
def setup_chain(self):
|
||||||
print "Initializing test directory "+self.options.tmpdir
|
print("Initializing test directory "+self.options.tmpdir)
|
||||||
initialize_chain_clean(self.options.tmpdir, 1)
|
initialize_chain_clean(self.options.tmpdir, 1)
|
||||||
|
|
||||||
def setup_network(self):
|
def setup_network(self):
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
#
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.mininode import *
|
from test_framework.mininode import *
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
|
@ -101,7 +100,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
def mine_full_block(self, node, address):
|
def mine_full_block(self, node, address):
|
||||||
# Want to create a full block
|
# Want to create a full block
|
||||||
# We'll generate a 66k transaction below, and 14 of them is close to the 1MB block limit
|
# 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:
|
if len(self.utxo) < 14:
|
||||||
self.utxo = node.listunspent()
|
self.utxo = node.listunspent()
|
||||||
inputs=[]
|
inputs=[]
|
||||||
|
@ -139,7 +138,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
test_nodes = []
|
test_nodes = []
|
||||||
connections = []
|
connections = []
|
||||||
|
|
||||||
for i in xrange(3):
|
for i in range(3):
|
||||||
test_nodes.append(TestNode())
|
test_nodes.append(TestNode())
|
||||||
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test_nodes[i]))
|
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test_nodes[i]))
|
||||||
test_nodes[i].add_connection(connections[i])
|
test_nodes[i].add_connection(connections[i])
|
||||||
|
@ -181,7 +180,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# 144MB will be reserved for relaying new blocks, so expect this to
|
# 144MB will be reserved for relaying new blocks, so expect this to
|
||||||
# succeed for ~70 tries.
|
# succeed for ~70 tries.
|
||||||
for i in xrange(success_count):
|
for i in range(success_count):
|
||||||
test_nodes[0].send_message(getdata_request)
|
test_nodes[0].send_message(getdata_request)
|
||||||
test_nodes[0].sync_with_ping()
|
test_nodes[0].sync_with_ping()
|
||||||
assert_equal(test_nodes[0].block_receive_map[big_old_block], i+1)
|
assert_equal(test_nodes[0].block_receive_map[big_old_block], i+1)
|
||||||
|
@ -189,22 +188,22 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
assert_equal(len(self.nodes[0].getpeerinfo()), 3)
|
assert_equal(len(self.nodes[0].getpeerinfo()), 3)
|
||||||
# At most a couple more tries should succeed (depending on how long
|
# At most a couple more tries should succeed (depending on how long
|
||||||
# the test has been running so far).
|
# the test has been running so far).
|
||||||
for i in xrange(3):
|
for i in range(3):
|
||||||
test_nodes[0].send_message(getdata_request)
|
test_nodes[0].send_message(getdata_request)
|
||||||
test_nodes[0].wait_for_disconnect()
|
test_nodes[0].wait_for_disconnect()
|
||||||
assert_equal(len(self.nodes[0].getpeerinfo()), 2)
|
assert_equal(len(self.nodes[0].getpeerinfo()), 2)
|
||||||
print "Peer 0 disconnected after downloading old block too many times"
|
print("Peer 0 disconnected after downloading old block too many times")
|
||||||
|
|
||||||
# Requesting the current block on test_nodes[1] should succeed indefinitely,
|
# Requesting the current block on test_nodes[1] should succeed indefinitely,
|
||||||
# even when over the max upload target.
|
# even when over the max upload target.
|
||||||
# We'll try 200 times
|
# We'll try 200 times
|
||||||
getdata_request.inv = [CInv(2, big_new_block)]
|
getdata_request.inv = [CInv(2, big_new_block)]
|
||||||
for i in xrange(200):
|
for i in range(200):
|
||||||
test_nodes[1].send_message(getdata_request)
|
test_nodes[1].send_message(getdata_request)
|
||||||
test_nodes[1].sync_with_ping()
|
test_nodes[1].sync_with_ping()
|
||||||
assert_equal(test_nodes[1].block_receive_map[big_new_block], i+1)
|
assert_equal(test_nodes[1].block_receive_map[big_new_block], i+1)
|
||||||
|
|
||||||
print "Peer 1 able to repeatedly download new block"
|
print("Peer 1 able to repeatedly download new block")
|
||||||
|
|
||||||
# But if test_nodes[1] tries for an old block, it gets disconnected too.
|
# But if test_nodes[1] tries for an old block, it gets disconnected too.
|
||||||
getdata_request.inv = [CInv(2, big_old_block)]
|
getdata_request.inv = [CInv(2, big_old_block)]
|
||||||
|
@ -212,9 +211,9 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
test_nodes[1].wait_for_disconnect()
|
test_nodes[1].wait_for_disconnect()
|
||||||
assert_equal(len(self.nodes[0].getpeerinfo()), 1)
|
assert_equal(len(self.nodes[0].getpeerinfo()), 1)
|
||||||
|
|
||||||
print "Peer 1 disconnected after trying to download old block"
|
print("Peer 1 disconnected after trying to download old block")
|
||||||
|
|
||||||
print "Advancing system time on node to clear counters..."
|
print("Advancing system time on node to clear counters...")
|
||||||
|
|
||||||
# If we advance the time by 24 hours, then the counters should reset,
|
# If we advance the time by 24 hours, then the counters should reset,
|
||||||
# and test_nodes[2] should be able to retrieve the old block.
|
# and test_nodes[2] should be able to retrieve the old block.
|
||||||
|
@ -224,12 +223,12 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
test_nodes[2].sync_with_ping()
|
test_nodes[2].sync_with_ping()
|
||||||
assert_equal(test_nodes[2].block_receive_map[big_old_block], 1)
|
assert_equal(test_nodes[2].block_receive_map[big_old_block], 1)
|
||||||
|
|
||||||
print "Peer 2 able to download old block"
|
print("Peer 2 able to download old block")
|
||||||
|
|
||||||
[c.disconnect_node() for c in connections]
|
[c.disconnect_node() for c in connections]
|
||||||
|
|
||||||
#stop and start node 0 with 1MB maxuploadtarget, whitelist 127.0.0.1
|
#stop and start node 0 with 1MB maxuploadtarget, whitelist 127.0.0.1
|
||||||
print "Restarting nodes with -whitelist=127.0.0.1"
|
print("Restarting nodes with -whitelist=127.0.0.1")
|
||||||
stop_node(self.nodes[0], 0)
|
stop_node(self.nodes[0], 0)
|
||||||
self.nodes[0] = start_node(0, self.options.tmpdir, ["-debug", "-whitelist=127.0.0.1", "-maxuploadtarget=1", "-blockmaxsize=999000"])
|
self.nodes[0] = start_node(0, self.options.tmpdir, ["-debug", "-whitelist=127.0.0.1", "-maxuploadtarget=1", "-blockmaxsize=999000"])
|
||||||
|
|
||||||
|
@ -237,7 +236,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
test_nodes = []
|
test_nodes = []
|
||||||
connections = []
|
connections = []
|
||||||
|
|
||||||
for i in xrange(3):
|
for i in range(3):
|
||||||
test_nodes.append(TestNode())
|
test_nodes.append(TestNode())
|
||||||
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test_nodes[i]))
|
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test_nodes[i]))
|
||||||
test_nodes[i].add_connection(connections[i])
|
test_nodes[i].add_connection(connections[i])
|
||||||
|
@ -247,7 +246,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
|
|
||||||
#retrieve 20 blocks which should be enough to break the 1MB limit
|
#retrieve 20 blocks which should be enough to break the 1MB limit
|
||||||
getdata_request.inv = [CInv(2, big_new_block)]
|
getdata_request.inv = [CInv(2, big_new_block)]
|
||||||
for i in xrange(20):
|
for i in range(20):
|
||||||
test_nodes[1].send_message(getdata_request)
|
test_nodes[1].send_message(getdata_request)
|
||||||
test_nodes[1].sync_with_ping()
|
test_nodes[1].sync_with_ping()
|
||||||
assert_equal(test_nodes[1].block_receive_map[big_new_block], i+1)
|
assert_equal(test_nodes[1].block_receive_map[big_new_block], i+1)
|
||||||
|
@ -257,7 +256,7 @@ class MaxUploadTest(BitcoinTestFramework):
|
||||||
test_nodes[1].wait_for_disconnect()
|
test_nodes[1].wait_for_disconnect()
|
||||||
assert_equal(len(self.nodes[0].getpeerinfo()), 3) #node is still connected because of the whitelist
|
assert_equal(len(self.nodes[0].getpeerinfo()), 3) #node is still connected because of the whitelist
|
||||||
|
|
||||||
print "Peer 1 still connected after trying to download old block (whitelisted)"
|
print("Peer 1 still connected after trying to download old block (whitelisted)")
|
||||||
|
|
||||||
[c.disconnect_node() for c in connections]
|
[c.disconnect_node() for c in connections]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class MempoolLimitTest(BitcoinTestFramework):
|
||||||
|
|
||||||
relayfee = self.nodes[0].getnetworkinfo()['relayfee']
|
relayfee = self.nodes[0].getnetworkinfo()['relayfee']
|
||||||
base_fee = relayfee*100
|
base_fee = relayfee*100
|
||||||
for i in xrange (4):
|
for i in range (4):
|
||||||
txids.append([])
|
txids.append([])
|
||||||
txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[30*i:30*i+30], (i+1)*base_fee)
|
txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[30*i:30*i+30], (i+1)*base_fee)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||||
send_value = satoshi_round((value - fee)/num_outputs)
|
send_value = satoshi_round((value - fee)/num_outputs)
|
||||||
inputs = [ {'txid' : parent_txid, 'vout' : vout} ]
|
inputs = [ {'txid' : parent_txid, 'vout' : vout} ]
|
||||||
outputs = {}
|
outputs = {}
|
||||||
for i in xrange(num_outputs):
|
for i in range(num_outputs):
|
||||||
outputs[node.getnewaddress()] = send_value
|
outputs[node.getnewaddress()] = send_value
|
||||||
rawtx = node.createrawtransaction(inputs, outputs)
|
rawtx = node.createrawtransaction(inputs, outputs)
|
||||||
signedtx = node.signrawtransaction(rawtx)
|
signedtx = node.signrawtransaction(rawtx)
|
||||||
|
@ -48,7 +48,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||||
fee = Decimal("0.0001")
|
fee = Decimal("0.0001")
|
||||||
# MAX_ANCESTORS transactions off a confirmed tx should be fine
|
# MAX_ANCESTORS transactions off a confirmed tx should be fine
|
||||||
chain = []
|
chain = []
|
||||||
for i in xrange(MAX_ANCESTORS):
|
for i in range(MAX_ANCESTORS):
|
||||||
(txid, sent_value) = self.chain_transaction(self.nodes[0], txid, 0, value, fee, 1)
|
(txid, sent_value) = self.chain_transaction(self.nodes[0], txid, 0, value, fee, 1)
|
||||||
value = sent_value
|
value = sent_value
|
||||||
chain.append(txid)
|
chain.append(txid)
|
||||||
|
@ -84,7 +84,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||||
try:
|
try:
|
||||||
self.chain_transaction(self.nodes[0], txid, vout, value, fee, 1)
|
self.chain_transaction(self.nodes[0], txid, vout, value, fee, 1)
|
||||||
except JSONRPCException as e:
|
except JSONRPCException as e:
|
||||||
print "too-long-ancestor-chain successfully rejected"
|
print("too-long-ancestor-chain successfully rejected")
|
||||||
|
|
||||||
# Check that prioritising a tx before it's added to the mempool works
|
# Check that prioritising a tx before it's added to the mempool works
|
||||||
# First clear the mempool by mining a block.
|
# First clear the mempool by mining a block.
|
||||||
|
@ -121,22 +121,22 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||||
# First create one parent tx with 10 children
|
# First create one parent tx with 10 children
|
||||||
(txid, sent_value) = self.chain_transaction(self.nodes[0], txid, vout, value, fee, 10)
|
(txid, sent_value) = self.chain_transaction(self.nodes[0], txid, vout, value, fee, 10)
|
||||||
parent_transaction = txid
|
parent_transaction = txid
|
||||||
for i in xrange(10):
|
for i in range(10):
|
||||||
transaction_package.append({'txid': txid, 'vout': i, 'amount': sent_value})
|
transaction_package.append({'txid': txid, 'vout': i, 'amount': sent_value})
|
||||||
|
|
||||||
for i in xrange(MAX_DESCENDANTS):
|
for i in range(MAX_DESCENDANTS):
|
||||||
utxo = transaction_package.pop(0)
|
utxo = transaction_package.pop(0)
|
||||||
try:
|
try:
|
||||||
(txid, sent_value) = self.chain_transaction(self.nodes[0], utxo['txid'], utxo['vout'], utxo['amount'], fee, 10)
|
(txid, sent_value) = self.chain_transaction(self.nodes[0], utxo['txid'], utxo['vout'], utxo['amount'], fee, 10)
|
||||||
for j in xrange(10):
|
for j in range(10):
|
||||||
transaction_package.append({'txid': txid, 'vout': j, 'amount': sent_value})
|
transaction_package.append({'txid': txid, 'vout': j, 'amount': sent_value})
|
||||||
if i == MAX_DESCENDANTS - 2:
|
if i == MAX_DESCENDANTS - 2:
|
||||||
mempool = self.nodes[0].getrawmempool(True)
|
mempool = self.nodes[0].getrawmempool(True)
|
||||||
assert_equal(mempool[parent_transaction]['descendantcount'], MAX_DESCENDANTS)
|
assert_equal(mempool[parent_transaction]['descendantcount'], MAX_DESCENDANTS)
|
||||||
except JSONRPCException as e:
|
except JSONRPCException as e:
|
||||||
print e.error['message']
|
print(e.error['message'])
|
||||||
assert_equal(i, MAX_DESCENDANTS - 1)
|
assert_equal(i, MAX_DESCENDANTS - 1)
|
||||||
print "tx that would create too large descendant package successfully rejected"
|
print("tx that would create too large descendant package successfully rejected")
|
||||||
|
|
||||||
# TODO: check that node1's mempool is as expected
|
# TODO: check that node1's mempool is as expected
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||||
send_value = satoshi_round((value - fee)/2)
|
send_value = satoshi_round((value - fee)/2)
|
||||||
inputs = [ {'txid' : txid, 'vout' : vout} ]
|
inputs = [ {'txid' : txid, 'vout' : vout} ]
|
||||||
outputs = {}
|
outputs = {}
|
||||||
for i in xrange(2):
|
for i in range(2):
|
||||||
outputs[self.nodes[0].getnewaddress()] = send_value
|
outputs[self.nodes[0].getnewaddress()] = send_value
|
||||||
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
|
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||||
signedtx = self.nodes[0].signrawtransaction(rawtx)
|
signedtx = self.nodes[0].signrawtransaction(rawtx)
|
||||||
|
@ -185,7 +185,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||||
# Create tx2-7
|
# Create tx2-7
|
||||||
vout = 1
|
vout = 1
|
||||||
txid = tx0_id
|
txid = tx0_id
|
||||||
for i in xrange(6):
|
for i in range(6):
|
||||||
(txid, sent_value) = self.chain_transaction(self.nodes[0], txid, vout, value, fee, 1)
|
(txid, sent_value) = self.chain_transaction(self.nodes[0], txid, vout, value, fee, 1)
|
||||||
vout = 0
|
vout = 0
|
||||||
value = sent_value
|
value = sent_value
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class MerkleBlockTest(BitcoinTestFramework):
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
print "Mining blocks..."
|
print("Mining blocks...")
|
||||||
self.nodes[0].generate(105)
|
self.nodes[0].generate(105)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -9,16 +9,9 @@
|
||||||
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
import base64
|
|
||||||
|
|
||||||
try:
|
import http.client
|
||||||
import http.client as httplib
|
import urllib.parse
|
||||||
except ImportError:
|
|
||||||
import httplib
|
|
||||||
try:
|
|
||||||
import urllib.parse as urlparse
|
|
||||||
except ImportError:
|
|
||||||
import urlparse
|
|
||||||
|
|
||||||
class HTTPBasicsTest (BitcoinTestFramework):
|
class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
def setup_nodes(self):
|
def setup_nodes(self):
|
||||||
|
@ -39,7 +32,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
##################################################
|
##################################################
|
||||||
# Check correctness of the rpcauth config option #
|
# Check correctness of the rpcauth config option #
|
||||||
##################################################
|
##################################################
|
||||||
url = urlparse.urlparse(self.nodes[0].url)
|
url = urllib.parse.urlparse(self.nodes[0].url)
|
||||||
|
|
||||||
#Old authpair
|
#Old authpair
|
||||||
authpair = url.username + ':' + url.password
|
authpair = url.username + ':' + url.password
|
||||||
|
@ -55,7 +48,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
|
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str(authpair)}
|
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.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
|
@ -65,7 +58,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
#Use new authpair to confirm both work
|
#Use new authpair to confirm both work
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
||||||
|
|
||||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
conn = http.client.HTTPConnection(url.hostname, url.port)
|
||||||
conn.connect()
|
conn.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
|
@ -76,7 +69,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
authpairnew = "rtwrong:"+password
|
authpairnew = "rtwrong:"+password
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
||||||
|
|
||||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
conn = http.client.HTTPConnection(url.hostname, url.port)
|
||||||
conn.connect()
|
conn.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
|
@ -87,7 +80,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
authpairnew = "rt:"+password+"wrong"
|
authpairnew = "rt:"+password+"wrong"
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
||||||
|
|
||||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
conn = http.client.HTTPConnection(url.hostname, url.port)
|
||||||
conn.connect()
|
conn.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
|
@ -98,7 +91,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
authpairnew = "rt2:"+password2
|
authpairnew = "rt2:"+password2
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
||||||
|
|
||||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
conn = http.client.HTTPConnection(url.hostname, url.port)
|
||||||
conn.connect()
|
conn.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
|
@ -109,7 +102,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||||
authpairnew = "rt2:"+password2+"wrong"
|
authpairnew = "rt2:"+password2+"wrong"
|
||||||
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
headers = {"Authorization": "Basic " + str_to_b64str(authpairnew)}
|
||||||
|
|
||||||
conn = httplib.HTTPConnection(url.hostname, url.port)
|
conn = http.client.HTTPConnection(url.hostname, url.port)
|
||||||
conn.connect()
|
conn.connect()
|
||||||
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
|
||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -10,14 +10,8 @@
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
|
|
||||||
try:
|
import http.client
|
||||||
import http.client as httplib
|
import urllib.parse
|
||||||
except ImportError:
|
|
||||||
import httplib
|
|
||||||
try:
|
|
||||||
import urllib.parse as urlparse
|
|
||||||
except ImportError:
|
|
||||||
import urlparse
|
|
||||||
|
|
||||||
class NodeHandlingTest (BitcoinTestFramework):
|
class NodeHandlingTest (BitcoinTestFramework):
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
|
@ -69,7 +63,7 @@ class NodeHandlingTest (BitcoinTestFramework):
|
||||||
###########################
|
###########################
|
||||||
# RPC disconnectnode test #
|
# RPC disconnectnode test #
|
||||||
###########################
|
###########################
|
||||||
url = urlparse.urlparse(self.nodes[1].url)
|
url = urllib.parse.urlparse(self.nodes[1].url)
|
||||||
self.nodes[0].disconnectnode(url.hostname+":"+str(p2p_port(1)))
|
self.nodes[0].disconnectnode(url.hostname+":"+str(p2p_port(1)))
|
||||||
time.sleep(2) #disconnecting a node needs a little bit of time
|
time.sleep(2) #disconnecting a node needs a little bit of time
|
||||||
for node in self.nodes[0].getpeerinfo():
|
for node in self.nodes[0].getpeerinfo():
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.mininode import *
|
from test_framework.mininode import *
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
|
@ -145,13 +144,13 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# 1. Have both nodes mine a block (leave IBD)
|
# 1. Have both nodes mine a block (leave IBD)
|
||||||
[ n.generate(1) for n in self.nodes ]
|
[ 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.
|
# 2. Send one block that builds on each tip.
|
||||||
# This should be accepted.
|
# This should be accepted.
|
||||||
blocks_h2 = [] # the height 2 blocks on each node's chain
|
blocks_h2 = [] # the height 2 blocks on each node's chain
|
||||||
block_time = int(time.time()) + 1
|
block_time = int(time.time()) + 1
|
||||||
for i in xrange(2):
|
for i in range(2):
|
||||||
blocks_h2.append(create_block(tips[i], create_coinbase(2), block_time))
|
blocks_h2.append(create_block(tips[i], create_coinbase(2), block_time))
|
||||||
blocks_h2[i].solve()
|
blocks_h2[i].solve()
|
||||||
block_time += 1
|
block_time += 1
|
||||||
|
@ -161,11 +160,11 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||||
[ x.sync_with_ping() for x in [test_node, white_node] ]
|
[ x.sync_with_ping() for x in [test_node, white_node] ]
|
||||||
assert_equal(self.nodes[0].getblockcount(), 2)
|
assert_equal(self.nodes[0].getblockcount(), 2)
|
||||||
assert_equal(self.nodes[1].getblockcount(), 2)
|
assert_equal(self.nodes[1].getblockcount(), 2)
|
||||||
print "First height 2 block accepted by both nodes"
|
print("First height 2 block accepted by both nodes")
|
||||||
|
|
||||||
# 3. Send another block that builds on the original tip.
|
# 3. Send another block that builds on the original tip.
|
||||||
blocks_h2f = [] # Blocks at height 2 that fork off the main chain
|
blocks_h2f = [] # Blocks at height 2 that fork off the main chain
|
||||||
for i in xrange(2):
|
for i in range(2):
|
||||||
blocks_h2f.append(create_block(tips[i], create_coinbase(2), blocks_h2[i].nTime+1))
|
blocks_h2f.append(create_block(tips[i], create_coinbase(2), blocks_h2[i].nTime+1))
|
||||||
blocks_h2f[i].solve()
|
blocks_h2f[i].solve()
|
||||||
test_node.send_message(msg_block(blocks_h2f[0]))
|
test_node.send_message(msg_block(blocks_h2f[0]))
|
||||||
|
@ -180,11 +179,11 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||||
if x['hash'] == blocks_h2f[1].hash:
|
if x['hash'] == blocks_h2f[1].hash:
|
||||||
assert_equal(x['status'], "valid-headers")
|
assert_equal(x['status'], "valid-headers")
|
||||||
|
|
||||||
print "Second height 2 block accepted only from whitelisted peer"
|
print("Second height 2 block accepted only from whitelisted peer")
|
||||||
|
|
||||||
# 4. Now send another block that builds on the forking chain.
|
# 4. Now send another block that builds on the forking chain.
|
||||||
blocks_h3 = []
|
blocks_h3 = []
|
||||||
for i in xrange(2):
|
for i in range(2):
|
||||||
blocks_h3.append(create_block(blocks_h2f[i].sha256, create_coinbase(3), blocks_h2f[i].nTime+1))
|
blocks_h3.append(create_block(blocks_h2f[i].sha256, create_coinbase(3), blocks_h2f[i].nTime+1))
|
||||||
blocks_h3[i].solve()
|
blocks_h3[i].solve()
|
||||||
test_node.send_message(msg_block(blocks_h3[0]))
|
test_node.send_message(msg_block(blocks_h3[0]))
|
||||||
|
@ -200,13 +199,13 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||||
# But this block should be accepted by node0 since it has more work.
|
# But this block should be accepted by node0 since it has more work.
|
||||||
try:
|
try:
|
||||||
self.nodes[0].getblock(blocks_h3[0].hash)
|
self.nodes[0].getblock(blocks_h3[0].hash)
|
||||||
print "Unrequested more-work block accepted from non-whitelisted peer"
|
print("Unrequested more-work block accepted from non-whitelisted peer")
|
||||||
except:
|
except:
|
||||||
raise AssertionError("Unrequested more work block was not processed")
|
raise AssertionError("Unrequested more work block was not processed")
|
||||||
|
|
||||||
# Node1 should have accepted and reorged.
|
# Node1 should have accepted and reorged.
|
||||||
assert_equal(self.nodes[1].getblockcount(), 3)
|
assert_equal(self.nodes[1].getblockcount(), 3)
|
||||||
print "Successfully reorged to length 3 chain from whitelisted peer"
|
print("Successfully reorged to length 3 chain from whitelisted peer")
|
||||||
|
|
||||||
# 4b. Now mine 288 more blocks and deliver; all should be processed but
|
# 4b. Now mine 288 more blocks and deliver; all should be processed but
|
||||||
# the last (height-too-high) on node0. Node1 should process the tip if
|
# the last (height-too-high) on node0. Node1 should process the tip if
|
||||||
|
@ -214,8 +213,8 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||||
tips = blocks_h3
|
tips = blocks_h3
|
||||||
headers_message = msg_headers()
|
headers_message = msg_headers()
|
||||||
all_blocks = [] # node0's blocks
|
all_blocks = [] # node0's blocks
|
||||||
for j in xrange(2):
|
for j in range(2):
|
||||||
for i in xrange(288):
|
for i in range(288):
|
||||||
next_block = create_block(tips[j].sha256, create_coinbase(i + 4), tips[j].nTime+1)
|
next_block = create_block(tips[j].sha256, create_coinbase(i + 4), tips[j].nTime+1)
|
||||||
next_block.solve()
|
next_block.solve()
|
||||||
if j==0:
|
if j==0:
|
||||||
|
@ -233,7 +232,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||||
raise AssertionError("Unrequested block too far-ahead should have been ignored")
|
raise AssertionError("Unrequested block too far-ahead should have been ignored")
|
||||||
except:
|
except:
|
||||||
if x == all_blocks[287]:
|
if x == all_blocks[287]:
|
||||||
print "Unrequested block too far-ahead not processed"
|
print("Unrequested block too far-ahead not processed")
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Unrequested block with more work should have been accepted")
|
raise AssertionError("Unrequested block with more work should have been accepted")
|
||||||
|
|
||||||
|
@ -243,7 +242,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||||
try:
|
try:
|
||||||
white_node.sync_with_ping()
|
white_node.sync_with_ping()
|
||||||
self.nodes[1].getblock(tips[1].hash)
|
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:
|
except:
|
||||||
raise AssertionError("Unrequested block from whitelisted peer not accepted")
|
raise AssertionError("Unrequested block from whitelisted peer not accepted")
|
||||||
|
|
||||||
|
@ -259,7 +258,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||||
# a getdata request for this block.
|
# a getdata request for this block.
|
||||||
test_node.sync_with_ping()
|
test_node.sync_with_ping()
|
||||||
assert_equal(self.nodes[0].getblockcount(), 2)
|
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.
|
# 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
|
# Poke the node with an inv for block at height 3 and see if that
|
||||||
|
@ -275,14 +274,14 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Check that the getdata includes the right block
|
# Check that the getdata includes the right block
|
||||||
assert_equal(getdata.inv[0].hash, blocks_h2f[0].sha256)
|
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)
|
# 7. Send the missing block for the third time (now it is requested)
|
||||||
test_node.send_message(msg_block(blocks_h2f[0]))
|
test_node.send_message(msg_block(blocks_h2f[0]))
|
||||||
|
|
||||||
test_node.sync_with_ping()
|
test_node.sync_with_ping()
|
||||||
assert_equal(self.nodes[0].getblockcount(), 290)
|
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 ]
|
[ c.disconnect_node() for c in connections ]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2016 The Bitcoin Core developers
|
# Copyright (c) 2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ def hashToHex(hash):
|
||||||
|
|
||||||
# Wait up to 60 secs to see if the testnode has received all the expected invs
|
# Wait up to 60 secs to see if the testnode has received all the expected invs
|
||||||
def allInvsMatch(invsExpected, testnode):
|
def allInvsMatch(invsExpected, testnode):
|
||||||
for x in xrange(60):
|
for x in range(60):
|
||||||
with mininode_lock:
|
with mininode_lock:
|
||||||
if (sorted(invsExpected) == sorted(testnode.txinvs)):
|
if (sorted(invsExpected) == sorted(testnode.txinvs)):
|
||||||
return True;
|
return True;
|
||||||
|
@ -69,7 +69,7 @@ class FeeFilterTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Test that invs are received for all txs at feerate of 20 sat/byte
|
# Test that invs are received for all txs at feerate of 20 sat/byte
|
||||||
node1.settxfee(Decimal("0.00020000"))
|
node1.settxfee(Decimal("0.00020000"))
|
||||||
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in xrange(3)]
|
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)]
|
||||||
assert(allInvsMatch(txids, test_node))
|
assert(allInvsMatch(txids, test_node))
|
||||||
test_node.clear_invs()
|
test_node.clear_invs()
|
||||||
|
|
||||||
|
@ -77,13 +77,13 @@ class FeeFilterTest(BitcoinTestFramework):
|
||||||
test_node.send_filter(15000)
|
test_node.send_filter(15000)
|
||||||
|
|
||||||
# Test that txs are still being received (paying 20 sat/byte)
|
# Test that txs are still being received (paying 20 sat/byte)
|
||||||
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in xrange(3)]
|
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)]
|
||||||
assert(allInvsMatch(txids, test_node))
|
assert(allInvsMatch(txids, test_node))
|
||||||
test_node.clear_invs()
|
test_node.clear_invs()
|
||||||
|
|
||||||
# Change tx fee rate to 10 sat/byte and test they are no longer received
|
# Change tx fee rate to 10 sat/byte and test they are no longer received
|
||||||
node1.settxfee(Decimal("0.00010000"))
|
node1.settxfee(Decimal("0.00010000"))
|
||||||
[node1.sendtoaddress(node1.getnewaddress(), 1) for x in xrange(3)]
|
[node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)]
|
||||||
sync_mempools(self.nodes) # must be sure node 0 has received all txs
|
sync_mempools(self.nodes) # must be sure node 0 has received all txs
|
||||||
time.sleep(10) # wait 10 secs to be sure its doesn't relay any
|
time.sleep(10) # wait 10 secs to be sure its doesn't relay any
|
||||||
assert(allInvsMatch([], test_node))
|
assert(allInvsMatch([], test_node))
|
||||||
|
@ -91,7 +91,7 @@ class FeeFilterTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Remove fee filter and check that txs are received again
|
# Remove fee filter and check that txs are received again
|
||||||
test_node.send_filter(0)
|
test_node.send_filter(0)
|
||||||
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in xrange(3)]
|
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)]
|
||||||
assert(allInvsMatch(txids, test_node))
|
assert(allInvsMatch(txids, test_node))
|
||||||
test_node.clear_invs()
|
test_node.clear_invs()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.test_framework import ComparisonTestFramework
|
from test_framework.test_framework import ComparisonTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2016 The Bitcoin Core developers
|
# Copyright (c) 2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.mininode import *
|
from test_framework.mininode import *
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
|
@ -82,7 +81,7 @@ class VersionBitsWarningTest(BitcoinTestFramework):
|
||||||
block_time = self.nodes[0].getblockheader(tip)["time"]+1
|
block_time = self.nodes[0].getblockheader(tip)["time"]+1
|
||||||
tip = int(tip, 16)
|
tip = int(tip, 16)
|
||||||
|
|
||||||
for i in xrange(numblocks):
|
for i in range(numblocks):
|
||||||
block = create_block(tip, create_coinbase(height+1), block_time)
|
block = create_block(tip, create_coinbase(height+1), block_time)
|
||||||
block.nVersion = nVersionToUse
|
block.nVersion = nVersionToUse
|
||||||
block.solve()
|
block.solve()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Create 3 batches of transactions at 3 different fee rate levels
|
# Create 3 batches of transactions at 3 different fee rate levels
|
||||||
range_size = utxo_count // 3
|
range_size = utxo_count // 3
|
||||||
for i in xrange(3):
|
for i in range(3):
|
||||||
txids.append([])
|
txids.append([])
|
||||||
start_range = i * range_size
|
start_range = i * range_size
|
||||||
end_range = start_range + range_size
|
end_range = start_range + range_size
|
||||||
|
@ -46,7 +46,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
||||||
# more transactions.
|
# more transactions.
|
||||||
mempool = self.nodes[0].getrawmempool(True)
|
mempool = self.nodes[0].getrawmempool(True)
|
||||||
sizes = [0, 0, 0]
|
sizes = [0, 0, 0]
|
||||||
for i in xrange(3):
|
for i in range(3):
|
||||||
for j in txids[i]:
|
for j in txids[i]:
|
||||||
assert(j in mempool)
|
assert(j in mempool)
|
||||||
sizes[i] += mempool[j]['size']
|
sizes[i] += mempool[j]['size']
|
||||||
|
@ -61,7 +61,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
|
|
||||||
mempool = self.nodes[0].getrawmempool()
|
mempool = self.nodes[0].getrawmempool()
|
||||||
print "Assert that prioritised transaction was mined"
|
print("Assert that prioritised transaction was mined")
|
||||||
assert(txids[0][0] not in mempool)
|
assert(txids[0][0] not in mempool)
|
||||||
assert(txids[0][1] in mempool)
|
assert(txids[0][1] in mempool)
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
||||||
# High fee transaction should not have been mined, but other high fee rate
|
# High fee transaction should not have been mined, but other high fee rate
|
||||||
# transactions should have been.
|
# transactions should have been.
|
||||||
mempool = self.nodes[0].getrawmempool()
|
mempool = self.nodes[0].getrawmempool()
|
||||||
print "Assert that de-prioritised transaction is still in mempool"
|
print("Assert that de-prioritised transaction is still in mempool")
|
||||||
assert(high_fee_tx in mempool)
|
assert(high_fee_tx in mempool)
|
||||||
for x in txids[2]:
|
for x in txids[2]:
|
||||||
if (x != high_fee_tx):
|
if (x != high_fee_tx):
|
||||||
|
@ -135,7 +135,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
||||||
# accepted.
|
# accepted.
|
||||||
self.nodes[0].prioritisetransaction(tx2_id, 0, int(self.relayfee*COIN))
|
self.nodes[0].prioritisetransaction(tx2_id, 0, int(self.relayfee*COIN))
|
||||||
|
|
||||||
print "Assert that prioritised free transaction is accepted to mempool"
|
print("Assert that prioritised free transaction is accepted to mempool")
|
||||||
assert_equal(self.nodes[0].sendrawtransaction(tx2_hex), tx2_id)
|
assert_equal(self.nodes[0].sendrawtransaction(tx2_hex), tx2_id)
|
||||||
assert(tx2_id in self.nodes[0].getrawmempool())
|
assert(tx2_id in self.nodes[0].getrawmempool())
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType
|
from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType
|
||||||
|
@ -55,7 +56,7 @@ class ProxyTest(BitcoinTestFramework):
|
||||||
self.conf3.unauth = True
|
self.conf3.unauth = True
|
||||||
self.conf3.auth = True
|
self.conf3.auth = True
|
||||||
else:
|
else:
|
||||||
print "Warning: testing without local IPv6 support"
|
print("Warning: testing without local IPv6 support")
|
||||||
|
|
||||||
self.serv1 = Socks5Server(self.conf1)
|
self.serv1 = Socks5Server(self.conf1)
|
||||||
self.serv1.start()
|
self.serv1.start()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class PruneTest(BitcoinTestFramework):
|
||||||
sync_blocks(self.nodes[0:2])
|
sync_blocks(self.nodes[0:2])
|
||||||
self.nodes[0].generate(150)
|
self.nodes[0].generate(150)
|
||||||
# Then mine enough full blocks to create more than 550MiB of data
|
# Then mine enough full blocks to create more than 550MiB of data
|
||||||
for i in xrange(645):
|
for i in range(645):
|
||||||
self.mine_full_block(self.nodes[0], self.address[0])
|
self.mine_full_block(self.nodes[0], self.address[0])
|
||||||
|
|
||||||
sync_blocks(self.nodes[0:3])
|
sync_blocks(self.nodes[0:3])
|
||||||
|
@ -65,11 +65,11 @@ class PruneTest(BitcoinTestFramework):
|
||||||
def test_height_min(self):
|
def test_height_min(self):
|
||||||
if not os.path.isfile(self.prunedir+"blk00000.dat"):
|
if not os.path.isfile(self.prunedir+"blk00000.dat"):
|
||||||
raise AssertionError("blk00000.dat is missing, pruning too early")
|
raise AssertionError("blk00000.dat is missing, pruning too early")
|
||||||
print "Success"
|
print("Success")
|
||||||
print "Though we're already using more than 550MiB, current usage:", calc_usage(self.prunedir)
|
print("Though we're already using more than 550MiB, current usage:", calc_usage(self.prunedir))
|
||||||
print "Mining 25 more blocks should cause the first block file to be pruned"
|
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
|
# 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])
|
self.mine_full_block(self.nodes[0],self.address[0])
|
||||||
|
|
||||||
waitstart = time.time()
|
waitstart = time.time()
|
||||||
|
@ -78,17 +78,17 @@ class PruneTest(BitcoinTestFramework):
|
||||||
if time.time() - waitstart > 10:
|
if time.time() - waitstart > 10:
|
||||||
raise AssertionError("blk00000.dat not pruned when it should be")
|
raise AssertionError("blk00000.dat not pruned when it should be")
|
||||||
|
|
||||||
print "Success"
|
print("Success")
|
||||||
usage = calc_usage(self.prunedir)
|
usage = calc_usage(self.prunedir)
|
||||||
print "Usage should be below target:", usage
|
print("Usage should be below target:", usage)
|
||||||
if (usage > 550):
|
if (usage > 550):
|
||||||
raise AssertionError("Pruning target not being met")
|
raise AssertionError("Pruning target not being met")
|
||||||
|
|
||||||
def create_chain_with_staleblocks(self):
|
def create_chain_with_staleblocks(self):
|
||||||
# Create stale blocks in manageable sized chunks
|
# 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
|
# 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
|
# 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
|
# Stopping node 0 also clears its mempool, so it doesn't have node1's transactions to accidentally mine
|
||||||
|
@ -96,7 +96,7 @@ class PruneTest(BitcoinTestFramework):
|
||||||
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900)
|
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900)
|
||||||
# Mine 24 blocks in node 1
|
# Mine 24 blocks in node 1
|
||||||
self.utxo = self.nodes[1].listunspent()
|
self.utxo = self.nodes[1].listunspent()
|
||||||
for i in xrange(24):
|
for i in range(24):
|
||||||
if j == 0:
|
if j == 0:
|
||||||
self.mine_full_block(self.nodes[1],self.address[1])
|
self.mine_full_block(self.nodes[1],self.address[1])
|
||||||
else:
|
else:
|
||||||
|
@ -104,7 +104,7 @@ class PruneTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Reorg back with 25 block chain from node 0
|
# Reorg back with 25 block chain from node 0
|
||||||
self.utxo = self.nodes[0].listunspent()
|
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])
|
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
|
# Create connections in the order so both nodes can see the reorg at the same time
|
||||||
|
@ -112,7 +112,7 @@ class PruneTest(BitcoinTestFramework):
|
||||||
connect_nodes(self.nodes[2], 0)
|
connect_nodes(self.nodes[2], 0)
|
||||||
sync_blocks(self.nodes[0:3])
|
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):
|
def reorg_test(self):
|
||||||
# Node 1 will mine a 300 block chain starting 287 blocks back from Node 0 and Node 2's tip
|
# Node 1 will mine a 300 block chain starting 287 blocks back from Node 0 and Node 2's tip
|
||||||
|
@ -123,11 +123,11 @@ class PruneTest(BitcoinTestFramework):
|
||||||
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
|
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
|
||||||
|
|
||||||
height = self.nodes[1].getblockcount()
|
height = self.nodes[1].getblockcount()
|
||||||
print "Current block height:", height
|
print("Current block height:", height)
|
||||||
|
|
||||||
invalidheight = height-287
|
invalidheight = height-287
|
||||||
badhash = self.nodes[1].getblockhash(invalidheight)
|
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)
|
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
|
# We've now switched to our previously mined-24 block fork on node 1, but thats not what we want
|
||||||
|
@ -139,29 +139,29 @@ class PruneTest(BitcoinTestFramework):
|
||||||
curhash = self.nodes[1].getblockhash(invalidheight - 1)
|
curhash = self.nodes[1].getblockhash(invalidheight - 1)
|
||||||
|
|
||||||
assert(self.nodes[1].getblockcount() == 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
|
# Reboot node1 to clear those giant tx's from mempool
|
||||||
stop_node(self.nodes[1],1)
|
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)
|
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)
|
self.nodes[1].generate(300)
|
||||||
|
|
||||||
print "Reconnect nodes"
|
print("Reconnect nodes")
|
||||||
connect_nodes(self.nodes[0], 1)
|
connect_nodes(self.nodes[0], 1)
|
||||||
connect_nodes(self.nodes[2], 1)
|
connect_nodes(self.nodes[2], 1)
|
||||||
sync_blocks(self.nodes[0:3])
|
sync_blocks(self.nodes[0:3])
|
||||||
|
|
||||||
print "Verify height on node 2:",self.nodes[2].getblockcount()
|
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("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
|
self.nodes[0].generate(220) #node 0 has many large tx's in its mempool from the disconnects
|
||||||
sync_blocks(self.nodes[0:3])
|
sync_blocks(self.nodes[0:3])
|
||||||
|
|
||||||
usage = calc_usage(self.prunedir)
|
usage = calc_usage(self.prunedir)
|
||||||
print "Usage should be below target:", usage
|
print("Usage should be below target:", usage)
|
||||||
if (usage > 550):
|
if (usage > 550):
|
||||||
raise AssertionError("Pruning target not being met")
|
raise AssertionError("Pruning target not being met")
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ class PruneTest(BitcoinTestFramework):
|
||||||
self.nodes[2].getblock(self.forkhash)
|
self.nodes[2].getblock(self.forkhash)
|
||||||
raise AssertionError("Old block wasn't pruned so can't test redownload")
|
raise AssertionError("Old block wasn't pruned so can't test redownload")
|
||||||
except JSONRPCException as e:
|
except JSONRPCException as e:
|
||||||
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
|
# 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
|
# Although this is more than 288 blocks, because this chain was written more recently
|
||||||
|
@ -197,14 +197,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
|
# 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:
|
if self.nodes[2].getblockcount() < self.mainchainheight:
|
||||||
blocks_to_mine = first_reorg_height + 1 - 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)
|
self.nodes[0].invalidateblock(curchainhash)
|
||||||
assert(self.nodes[0].getblockcount() == self.mainchainheight)
|
assert(self.nodes[0].getblockcount() == self.mainchainheight)
|
||||||
assert(self.nodes[0].getbestblockhash() == self.mainchainhash2)
|
assert(self.nodes[0].getbestblockhash() == self.mainchainhash2)
|
||||||
goalbesthash = self.nodes[0].generate(blocks_to_mine)[-1]
|
goalbesthash = self.nodes[0].generate(blocks_to_mine)[-1]
|
||||||
goalbestheight = first_reorg_height + 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()
|
waitstart = time.time()
|
||||||
while self.nodes[2].getblockcount() < goalbestheight:
|
while self.nodes[2].getblockcount() < goalbestheight:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
@ -217,7 +217,7 @@ class PruneTest(BitcoinTestFramework):
|
||||||
def mine_full_block(self, node, address):
|
def mine_full_block(self, node, address):
|
||||||
# Want to create a full block
|
# Want to create a full block
|
||||||
# We'll generate a 66k transaction below, and 14 of them is close to the 1MB block limit
|
# 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:
|
if len(self.utxo) < 14:
|
||||||
self.utxo = node.listunspent()
|
self.utxo = node.listunspent()
|
||||||
inputs=[]
|
inputs=[]
|
||||||
|
@ -241,8 +241,8 @@ class PruneTest(BitcoinTestFramework):
|
||||||
|
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
print "Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)"
|
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("Mining a big blockchain of 995 blocks")
|
||||||
self.create_big_chain()
|
self.create_big_chain()
|
||||||
# Chain diagram key:
|
# Chain diagram key:
|
||||||
# * blocks on main chain
|
# * blocks on main chain
|
||||||
|
@ -253,12 +253,12 @@ class PruneTest(BitcoinTestFramework):
|
||||||
# Start by mining a simple chain that all nodes have
|
# Start by mining a simple chain that all nodes have
|
||||||
# N0=N1=N2 **...*(995)
|
# 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()
|
self.test_height_min()
|
||||||
# Extend this chain past the PruneAfterHeight
|
# Extend this chain past the PruneAfterHeight
|
||||||
# N0=N1=N2 **...*(1020)
|
# 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()
|
self.create_chain_with_staleblocks()
|
||||||
# Disconnect N0
|
# Disconnect N0
|
||||||
# And mine a 24 block chain on N1 and a separate 25 block chain on N0
|
# And mine a 24 block chain on N1 and a separate 25 block chain on N0
|
||||||
|
@ -282,7 +282,7 @@ class PruneTest(BitcoinTestFramework):
|
||||||
self.mainchainheight = self.nodes[2].getblockcount() #1320
|
self.mainchainheight = self.nodes[2].getblockcount() #1320
|
||||||
self.mainchainhash2 = self.nodes[2].getblockhash(self.mainchainheight)
|
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, )
|
(self.forkheight,self.forkhash) = self.reorg_test() #(1033, )
|
||||||
# Now create a 288 block reorg by mining a longer chain on N1
|
# Now create a 288 block reorg by mining a longer chain on N1
|
||||||
# First disconnect N1
|
# First disconnect N1
|
||||||
|
@ -315,7 +315,7 @@ class PruneTest(BitcoinTestFramework):
|
||||||
# \
|
# \
|
||||||
# *...**(1320)
|
# *...**(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()
|
self.reorg_back()
|
||||||
# Verify that N2 still has block 1033 on current chain (@), but not on main chain (*)
|
# 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
|
# Invalidate 1033 on current chain (@) on N2 and we should be able to reorg to
|
||||||
|
@ -335,7 +335,7 @@ class PruneTest(BitcoinTestFramework):
|
||||||
#
|
#
|
||||||
# N1 doesn't change because 1033 on main chain (*) is invalid
|
# N1 doesn't change because 1033 on main chain (*) is invalid
|
||||||
|
|
||||||
print "Done"
|
print("Done")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
PruneTest().main()
|
PruneTest().main()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class ReindexTest(BitcoinTestFramework):
|
||||||
wait_bitcoinds()
|
wait_bitcoinds()
|
||||||
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug", "-reindex", "-checkblockindex=1"])
|
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug", "-reindex", "-checkblockindex=1"])
|
||||||
assert_equal(self.nodes[0].getblockcount(), 3)
|
assert_equal(self.nodes[0].getblockcount(), 3)
|
||||||
print "Success"
|
print("Success")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
ReindexTest().main()
|
ReindexTest().main()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -82,34 +82,34 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
make_utxo(self.nodes[0], 1*COIN)
|
make_utxo(self.nodes[0], 1*COIN)
|
||||||
|
|
||||||
print "Running test simple doublespend..."
|
print("Running test simple doublespend...")
|
||||||
self.test_simple_doublespend()
|
self.test_simple_doublespend()
|
||||||
|
|
||||||
print "Running test doublespend chain..."
|
print("Running test doublespend chain...")
|
||||||
self.test_doublespend_chain()
|
self.test_doublespend_chain()
|
||||||
|
|
||||||
print "Running test doublespend tree..."
|
print("Running test doublespend tree...")
|
||||||
self.test_doublespend_tree()
|
self.test_doublespend_tree()
|
||||||
|
|
||||||
print "Running test replacement feeperkb..."
|
print("Running test replacement feeperkb...")
|
||||||
self.test_replacement_feeperkb()
|
self.test_replacement_feeperkb()
|
||||||
|
|
||||||
print "Running test spends of conflicting outputs..."
|
print("Running test spends of conflicting outputs...")
|
||||||
self.test_spends_of_conflicting_outputs()
|
self.test_spends_of_conflicting_outputs()
|
||||||
|
|
||||||
print "Running test new unconfirmed inputs..."
|
print("Running test new unconfirmed inputs...")
|
||||||
self.test_new_unconfirmed_inputs()
|
self.test_new_unconfirmed_inputs()
|
||||||
|
|
||||||
print "Running test too many replacements..."
|
print("Running test too many replacements...")
|
||||||
self.test_too_many_replacements()
|
self.test_too_many_replacements()
|
||||||
|
|
||||||
print "Running test opt-in..."
|
print("Running test opt-in...")
|
||||||
self.test_opt_in()
|
self.test_opt_in()
|
||||||
|
|
||||||
print "Running test prioritised transactions..."
|
print("Running test prioritised transactions...")
|
||||||
self.test_prioritised_transactions()
|
self.test_prioritised_transactions()
|
||||||
|
|
||||||
print "Passed\n"
|
print("Passed\n")
|
||||||
|
|
||||||
def test_simple_doublespend(self):
|
def test_simple_doublespend(self):
|
||||||
"""Simple doublespend"""
|
"""Simple doublespend"""
|
||||||
|
@ -459,7 +459,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||||
except JSONRPCException as exp:
|
except JSONRPCException as exp:
|
||||||
assert_equal(exp.error['code'], -26)
|
assert_equal(exp.error['code'], -26)
|
||||||
else:
|
else:
|
||||||
print tx1b_txid
|
print(tx1b_txid)
|
||||||
assert(False)
|
assert(False)
|
||||||
|
|
||||||
tx1_outpoint = make_utxo(self.nodes[0], int(1.1*COIN))
|
tx1_outpoint = make_utxo(self.nodes[0], int(1.1*COIN))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -13,16 +13,9 @@ from test_framework.util import *
|
||||||
from struct import *
|
from struct import *
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from codecs import encode
|
from codecs import encode
|
||||||
import binascii
|
|
||||||
|
|
||||||
try:
|
import http.client
|
||||||
import http.client as httplib
|
import urllib.parse
|
||||||
except ImportError:
|
|
||||||
import httplib
|
|
||||||
try:
|
|
||||||
import urllib.parse as urlparse
|
|
||||||
except ImportError:
|
|
||||||
import urlparse
|
|
||||||
|
|
||||||
def deser_uint256(f):
|
def deser_uint256(f):
|
||||||
r = 0
|
r = 0
|
||||||
|
@ -33,7 +26,7 @@ def deser_uint256(f):
|
||||||
|
|
||||||
#allows simple http get calls
|
#allows simple http get calls
|
||||||
def http_get_call(host, port, path, response_object = 0):
|
def http_get_call(host, port, path, response_object = 0):
|
||||||
conn = httplib.HTTPConnection(host, port)
|
conn = http.client.HTTPConnection(host, port)
|
||||||
conn.request('GET', path)
|
conn.request('GET', path)
|
||||||
|
|
||||||
if response_object:
|
if response_object:
|
||||||
|
@ -43,7 +36,7 @@ def http_get_call(host, port, path, response_object = 0):
|
||||||
|
|
||||||
#allows simple http post calls with a request body
|
#allows simple http post calls with a request body
|
||||||
def http_post_call(host, port, path, requestdata = '', response_object = 0):
|
def http_post_call(host, port, path, requestdata = '', response_object = 0):
|
||||||
conn = httplib.HTTPConnection(host, port)
|
conn = http.client.HTTPConnection(host, port)
|
||||||
conn.request('POST', path, requestdata)
|
conn.request('POST', path, requestdata)
|
||||||
|
|
||||||
if response_object:
|
if response_object:
|
||||||
|
@ -67,8 +60,8 @@ class RESTTest (BitcoinTestFramework):
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
url = urlparse.urlparse(self.nodes[0].url)
|
url = urllib.parse.urlparse(self.nodes[0].url)
|
||||||
print "Mining blocks..."
|
print("Mining blocks...")
|
||||||
|
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
@ -151,7 +144,7 @@ class RESTTest (BitcoinTestFramework):
|
||||||
output.write(bin_response)
|
output.write(bin_response)
|
||||||
output.seek(0)
|
output.seek(0)
|
||||||
chainHeight = unpack("i", output.read(4))[0]
|
chainHeight = 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(bb_hash, hashFromBinResponse) #check if getutxo's chaintip during calculation was fine
|
||||||
assert_equal(chainHeight, 102) #chain height must be 102
|
assert_equal(chainHeight, 102) #chain height must be 102
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ def run_allowip_test(tmpdir, allow_ips, rpchost, rpcport):
|
||||||
|
|
||||||
|
|
||||||
def run_test(tmpdir):
|
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
|
# find the first non-loopback interface for testing
|
||||||
non_loopback_ip = None
|
non_loopback_ip = None
|
||||||
for name,ip in all_interfaces():
|
for name,ip in all_interfaces():
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from test_framework.mininode import *
|
from test_framework.mininode import *
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
|
@ -266,8 +265,8 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# PART 1
|
# PART 1
|
||||||
# 1. Mine a block; expect inv announcements each time
|
# 1. Mine a block; expect inv announcements each time
|
||||||
print "Part 1: headers don't start before sendheaders message..."
|
print("Part 1: headers don't start before sendheaders message...")
|
||||||
for i in xrange(4):
|
for i in range(4):
|
||||||
old_tip = tip
|
old_tip = tip
|
||||||
tip = self.mine_blocks(1)
|
tip = self.mine_blocks(1)
|
||||||
assert_equal(inv_node.check_last_announcement(inv=[tip]), True)
|
assert_equal(inv_node.check_last_announcement(inv=[tip]), True)
|
||||||
|
@ -297,14 +296,14 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
inv_node.clear_last_announcement()
|
inv_node.clear_last_announcement()
|
||||||
test_node.clear_last_announcement()
|
test_node.clear_last_announcement()
|
||||||
|
|
||||||
print "Part 1: success!"
|
print("Part 1: success!")
|
||||||
print "Part 2: announce blocks with headers after sendheaders message..."
|
print("Part 2: announce blocks with headers after sendheaders message...")
|
||||||
# PART 2
|
# PART 2
|
||||||
# 2. Send a sendheaders message and test that headers announcements
|
# 2. Send a sendheaders message and test that headers announcements
|
||||||
# commence and keep working.
|
# commence and keep working.
|
||||||
test_node.send_message(msg_sendheaders())
|
test_node.send_message(msg_sendheaders())
|
||||||
prev_tip = int(self.nodes[0].getbestblockhash(), 16)
|
prev_tip = int(self.nodes[0].getbestblockhash(), 16)
|
||||||
test_node.get_headers(locator=[prev_tip], hashstop=0L)
|
test_node.get_headers(locator=[prev_tip], hashstop=0)
|
||||||
test_node.sync_with_ping()
|
test_node.sync_with_ping()
|
||||||
|
|
||||||
# Now that we've synced headers, headers announcements should work
|
# Now that we've synced headers, headers announcements should work
|
||||||
|
@ -314,14 +313,14 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
|
|
||||||
height = self.nodes[0].getblockcount()+1
|
height = self.nodes[0].getblockcount()+1
|
||||||
block_time += 10 # Advance far enough ahead
|
block_time += 10 # Advance far enough ahead
|
||||||
for i in xrange(10):
|
for i in range(10):
|
||||||
# Mine i blocks, and alternate announcing either via
|
# Mine i blocks, and alternate announcing either via
|
||||||
# inv (of tip) or via headers. After each, new blocks
|
# inv (of tip) or via headers. After each, new blocks
|
||||||
# mined by the node should successfully be announced
|
# mined by the node should successfully be announced
|
||||||
# with block header, even though the blocks are never requested
|
# with block header, even though the blocks are never requested
|
||||||
for j in xrange(2):
|
for j in range(2):
|
||||||
blocks = []
|
blocks = []
|
||||||
for b in xrange(i+1):
|
for b in range(i+1):
|
||||||
blocks.append(create_block(tip, create_coinbase(height), block_time))
|
blocks.append(create_block(tip, create_coinbase(height), block_time))
|
||||||
blocks[-1].solve()
|
blocks[-1].solve()
|
||||||
tip = blocks[-1].sha256
|
tip = blocks[-1].sha256
|
||||||
|
@ -360,13 +359,13 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
height += 1
|
height += 1
|
||||||
block_time += 1
|
block_time += 1
|
||||||
|
|
||||||
print "Part 2: success!"
|
print("Part 2: success!")
|
||||||
|
|
||||||
print "Part 3: headers announcements can stop after large reorg, and resume after headers/inv from peer..."
|
print("Part 3: headers announcements can stop after large reorg, and resume after headers/inv from peer...")
|
||||||
|
|
||||||
# PART 3. Headers announcements can stop after large reorg, and resume after
|
# PART 3. Headers announcements can stop after large reorg, and resume after
|
||||||
# getheaders or inv from peer.
|
# getheaders or inv from peer.
|
||||||
for j in xrange(2):
|
for j in range(2):
|
||||||
# First try mining a reorg that can propagate with header announcement
|
# First try mining a reorg that can propagate with header announcement
|
||||||
new_block_hashes = self.mine_reorg(length=7)
|
new_block_hashes = self.mine_reorg(length=7)
|
||||||
tip = new_block_hashes[-1]
|
tip = new_block_hashes[-1]
|
||||||
|
@ -392,7 +391,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
test_node.get_data(new_block_hashes)
|
test_node.get_data(new_block_hashes)
|
||||||
test_node.wait_for_block(new_block_hashes[-1])
|
test_node.wait_for_block(new_block_hashes[-1])
|
||||||
|
|
||||||
for i in xrange(3):
|
for i in range(3):
|
||||||
# Mine another block, still should get only an inv
|
# Mine another block, still should get only an inv
|
||||||
tip = self.mine_blocks(1)
|
tip = self.mine_blocks(1)
|
||||||
assert_equal(inv_node.check_last_announcement(inv=[tip]), True)
|
assert_equal(inv_node.check_last_announcement(inv=[tip]), True)
|
||||||
|
@ -414,7 +413,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
# of headers announcements, or mine a new block and inv it, also
|
# of headers announcements, or mine a new block and inv it, also
|
||||||
# triggering resumption of headers announcements.
|
# triggering resumption of headers announcements.
|
||||||
if j == 0:
|
if j == 0:
|
||||||
test_node.get_headers(locator=[tip], hashstop=0L)
|
test_node.get_headers(locator=[tip], hashstop=0)
|
||||||
test_node.sync_with_ping()
|
test_node.sync_with_ping()
|
||||||
else:
|
else:
|
||||||
test_node.send_block_inv(tip)
|
test_node.send_block_inv(tip)
|
||||||
|
@ -424,9 +423,9 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
assert_equal(inv_node.check_last_announcement(inv=[tip]), True)
|
assert_equal(inv_node.check_last_announcement(inv=[tip]), True)
|
||||||
assert_equal(test_node.check_last_announcement(headers=[tip]), True)
|
assert_equal(test_node.check_last_announcement(headers=[tip]), True)
|
||||||
|
|
||||||
print "Part 3: success!"
|
print("Part 3: success!")
|
||||||
|
|
||||||
print "Part 4: Testing direct fetch behavior..."
|
print("Part 4: Testing direct fetch behavior...")
|
||||||
tip = self.mine_blocks(1)
|
tip = self.mine_blocks(1)
|
||||||
height = self.nodes[0].getblockcount() + 1
|
height = self.nodes[0].getblockcount() + 1
|
||||||
last_time = self.nodes[0].getblock(self.nodes[0].getbestblockhash())['time']
|
last_time = self.nodes[0].getblock(self.nodes[0].getbestblockhash())['time']
|
||||||
|
@ -434,7 +433,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Create 2 blocks. Send the blocks, then send the headers.
|
# Create 2 blocks. Send the blocks, then send the headers.
|
||||||
blocks = []
|
blocks = []
|
||||||
for b in xrange(2):
|
for b in range(2):
|
||||||
blocks.append(create_block(tip, create_coinbase(height), block_time))
|
blocks.append(create_block(tip, create_coinbase(height), block_time))
|
||||||
blocks[-1].solve()
|
blocks[-1].solve()
|
||||||
tip = blocks[-1].sha256
|
tip = blocks[-1].sha256
|
||||||
|
@ -452,7 +451,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# This time, direct fetch should work
|
# This time, direct fetch should work
|
||||||
blocks = []
|
blocks = []
|
||||||
for b in xrange(3):
|
for b in range(3):
|
||||||
blocks.append(create_block(tip, create_coinbase(height), block_time))
|
blocks.append(create_block(tip, create_coinbase(height), block_time))
|
||||||
blocks[-1].solve()
|
blocks[-1].solve()
|
||||||
tip = blocks[-1].sha256
|
tip = blocks[-1].sha256
|
||||||
|
@ -473,7 +472,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
blocks = []
|
blocks = []
|
||||||
|
|
||||||
# Create extra blocks for later
|
# Create extra blocks for later
|
||||||
for b in xrange(20):
|
for b in range(20):
|
||||||
blocks.append(create_block(tip, create_coinbase(height), block_time))
|
blocks.append(create_block(tip, create_coinbase(height), block_time))
|
||||||
blocks[-1].solve()
|
blocks[-1].solve()
|
||||||
tip = blocks[-1].sha256
|
tip = blocks[-1].sha256
|
||||||
|
@ -507,7 +506,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
with mininode_lock:
|
with mininode_lock:
|
||||||
assert_equal(test_node.last_getdata, None)
|
assert_equal(test_node.last_getdata, None)
|
||||||
|
|
||||||
print "Part 4: success!"
|
print("Part 4: success!")
|
||||||
|
|
||||||
# Finally, check that the inv node never received a getdata request,
|
# Finally, check that the inv node never received a getdata request,
|
||||||
# throughout the test
|
# throughout the test
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2016 The Bitcoin Core developers
|
# Copyright (c) 2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ class EstimateFeeTest(BitcoinTestFramework):
|
||||||
self.confutxo = self.txouts # Start with the set of confirmed txouts after splitting
|
self.confutxo = self.txouts # Start with the set of confirmed txouts after splitting
|
||||||
print("Will output estimates for 1/2/3/6/15/25 blocks")
|
print("Will output estimates for 1/2/3/6/15/25 blocks")
|
||||||
|
|
||||||
for i in xrange(2):
|
for i in range(2):
|
||||||
print("Creating transactions and mining them with a block size that can't keep up")
|
print("Creating transactions and mining them with a block size that can't keep up")
|
||||||
# Create transactions and mine 10 small blocks with node 2, but create txs faster than we can mine
|
# Create transactions and mine 10 small blocks with node 2, but create txs faster than we can mine
|
||||||
self.transact_and_mine(10, self.nodes[2])
|
self.transact_and_mine(10, self.nodes[2])
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
#
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# bignum.py
|
# bignum.py
|
||||||
#
|
#
|
||||||
# This file is copied from python-bitcoinlib.
|
# This file is copied from python-bitcoinlib.
|
||||||
#
|
#
|
||||||
# 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
#
|
||||||
|
|
||||||
"""Bignum routines"""
|
"""Bignum routines"""
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
# BlockStore: a helper class that keeps a map of blocks and implements
|
# BlockStore: a helper class that keeps a map of blocks and implements
|
||||||
# helper functions for responding to getheaders and getdata,
|
# helper functions for responding to getheaders and getdata,
|
||||||
# and for constructing a getheaders message
|
# and for constructing a getheaders message
|
||||||
#
|
#
|
||||||
|
|
||||||
from .mininode import *
|
from .mininode import *
|
||||||
import dbm
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
import dbm.ndbm
|
||||||
|
|
||||||
class BlockStore(object):
|
class BlockStore(object):
|
||||||
def __init__(self, datadir):
|
def __init__(self, datadir):
|
||||||
self.blockDB = dbm.open(datadir + "/blocks", 'c')
|
self.blockDB = dbm.ndbm.open(datadir + "/blocks", 'c')
|
||||||
self.currentBlock = 0L
|
self.currentBlock = 0
|
||||||
self.headers_map = dict()
|
self.headers_map = dict()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
@ -67,7 +68,7 @@ class BlockStore(object):
|
||||||
try:
|
try:
|
||||||
self.blockDB[repr(block.sha256)] = bytes(block.serialize())
|
self.blockDB[repr(block.sha256)] = bytes(block.serialize())
|
||||||
except TypeError as e:
|
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
|
self.currentBlock = block.sha256
|
||||||
self.headers_map[block.sha256] = CBlockHeader(block)
|
self.headers_map[block.sha256] = CBlockHeader(block)
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ class BlockStore(object):
|
||||||
|
|
||||||
class TxStore(object):
|
class TxStore(object):
|
||||||
def __init__(self, datadir):
|
def __init__(self, datadir):
|
||||||
self.txDB = dbm.open(datadir + "/transactions", 'c')
|
self.txDB = dbm.ndbm.open(datadir + "/transactions", 'c')
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.txDB.close()
|
self.txDB.close()
|
||||||
|
@ -127,7 +128,7 @@ class TxStore(object):
|
||||||
try:
|
try:
|
||||||
self.txDB[repr(tx.sha256)] = bytes(tx.serialize())
|
self.txDB[repr(tx.sha256)] = bytes(tx.serialize())
|
||||||
except TypeError as e:
|
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):
|
def get_transactions(self, inv):
|
||||||
responses = []
|
responses = []
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
# blocktools.py - utilities for manipulating blocks and transactions
|
# blocktools.py - utilities for manipulating blocks and transactions
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from .mininode import *
|
from .mininode import *
|
||||||
from .script import CScript, OP_TRUE, OP_CHECKSIG
|
from .script import CScript, OP_TRUE, OP_CHECKSIG
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
from .mininode import *
|
from .mininode import *
|
||||||
from .blockstore import BlockStore, TxStore
|
from .blockstore import BlockStore, TxStore
|
||||||
|
@ -259,10 +258,10 @@ class TestManager(object):
|
||||||
if c.cb.bestblockhash == blockhash:
|
if c.cb.bestblockhash == blockhash:
|
||||||
return False
|
return False
|
||||||
if blockhash not in c.cb.block_reject_map:
|
if blockhash not in c.cb.block_reject_map:
|
||||||
print 'Block not in reject map: %064x' % (blockhash)
|
print('Block not in reject map: %064x' % (blockhash))
|
||||||
return False
|
return False
|
||||||
if not outcome.match(c.cb.block_reject_map[blockhash]):
|
if not outcome.match(c.cb.block_reject_map[blockhash]):
|
||||||
print 'Block rejected with %s instead of expected %s: %064x' % (c.cb.block_reject_map[blockhash], outcome, blockhash)
|
print('Block rejected with %s instead of expected %s: %064x' % (c.cb.block_reject_map[blockhash], outcome, blockhash))
|
||||||
return False
|
return False
|
||||||
elif ((c.cb.bestblockhash == blockhash) != outcome):
|
elif ((c.cb.bestblockhash == blockhash) != outcome):
|
||||||
# print c.cb.bestblockhash, blockhash, outcome
|
# print c.cb.bestblockhash, blockhash, outcome
|
||||||
|
@ -287,10 +286,10 @@ class TestManager(object):
|
||||||
if txhash in c.cb.lastInv:
|
if txhash in c.cb.lastInv:
|
||||||
return False
|
return False
|
||||||
if txhash not in c.cb.tx_reject_map:
|
if txhash not in c.cb.tx_reject_map:
|
||||||
print 'Tx not in reject map: %064x' % (txhash)
|
print('Tx not in reject map: %064x' % (txhash))
|
||||||
return False
|
return False
|
||||||
if not outcome.match(c.cb.tx_reject_map[txhash]):
|
if not outcome.match(c.cb.tx_reject_map[txhash]):
|
||||||
print 'Tx rejected with %s instead of expected %s: %064x' % (c.cb.tx_reject_map[txhash], outcome, txhash)
|
print('Tx rejected with %s instead of expected %s: %064x' % (c.cb.tx_reject_map[txhash], outcome, txhash))
|
||||||
return False
|
return False
|
||||||
elif ((txhash in c.cb.lastInv) != outcome):
|
elif ((txhash in c.cb.lastInv) != outcome):
|
||||||
# print c.rpc.getrawmempool(), c.cb.lastInv
|
# print c.rpc.getrawmempool(), c.cb.lastInv
|
||||||
|
@ -393,7 +392,7 @@ class TestManager(object):
|
||||||
if (not self.check_mempool(tx.sha256, tx_outcome)):
|
if (not self.check_mempool(tx.sha256, tx_outcome)):
|
||||||
raise AssertionError("Mempool test failed at test %d" % test_number)
|
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
|
test_number += 1
|
||||||
|
|
||||||
[ c.disconnect_node() for c in self.connections ]
|
[ c.disconnect_node() for c in self.connections ]
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This module contains utilities for doing coverage analysis on the RPC
|
This module contains utilities for doing coverage analysis on the RPC
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
# mininode.py - Bitcoin P2P network half-a-node
|
#!/usr/bin/env python3
|
||||||
#
|
# Copyright (c) 2010 ArtForz -- public domain half-a-node
|
||||||
# Distributed under the MIT/X11 software license, see the accompanying
|
# Copyright (c) 2012 Jeff Garzik
|
||||||
|
# Copyright (c) 2010-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.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#
|
||||||
|
# mininode.py - Bitcoin P2P network half-a-node
|
||||||
#
|
#
|
||||||
# This python code was modified from ArtForz' public domain half-a-node, as
|
# This python code was modified from ArtForz' public domain half-a-node, as
|
||||||
# found in the mini-node branch of http://github.com/jgarzik/pynode.
|
# found in the mini-node branch of http://github.com/jgarzik/pynode.
|
||||||
|
@ -34,12 +39,12 @@ import copy
|
||||||
|
|
||||||
BIP0031_VERSION = 60000
|
BIP0031_VERSION = 60000
|
||||||
MY_VERSION = 60001 # past bip-31 for ping/pong
|
MY_VERSION = 60001 # past bip-31 for ping/pong
|
||||||
MY_SUBVERSION = b"/python-mininode-tester:0.0.2/"
|
MY_SUBVERSION = b"/python-mininode-tester:0.0.3/"
|
||||||
|
|
||||||
MAX_INV_SZ = 50000
|
MAX_INV_SZ = 50000
|
||||||
MAX_BLOCK_SIZE = 1000000
|
MAX_BLOCK_SIZE = 1000000
|
||||||
|
|
||||||
COIN = 100000000L # 1 btc in satoshis
|
COIN = 100000000 # 1 btc in satoshis
|
||||||
|
|
||||||
# Keep our own socket map for asyncore, so that we can track disconnects
|
# Keep our own socket map for asyncore, so that we can track disconnects
|
||||||
# ourselves (to workaround an issue with closing an asyncore socket when
|
# ourselves (to workaround an issue with closing an asyncore socket when
|
||||||
|
@ -73,20 +78,18 @@ def deser_string(f):
|
||||||
nit = struct.unpack("<Q", f.read(8))[0]
|
nit = struct.unpack("<Q", f.read(8))[0]
|
||||||
return f.read(nit)
|
return f.read(nit)
|
||||||
|
|
||||||
|
|
||||||
def ser_string(s):
|
def ser_string(s):
|
||||||
if len(s) < 253:
|
if len(s) < 253:
|
||||||
return struct.pack("B", len(s)) + s
|
return struct.pack("B", len(s)) + s
|
||||||
elif len(s) < 0x10000:
|
elif len(s) < 0x10000:
|
||||||
return struct.pack("<BH", 253, len(s)) + s
|
return struct.pack("<BH", 253, len(s)) + s
|
||||||
elif len(s) < 0x100000000L:
|
elif len(s) < 0x100000000:
|
||||||
return struct.pack("<BI", 254, len(s)) + s
|
return struct.pack("<BI", 254, len(s)) + s
|
||||||
return struct.pack("<BQ", 255, len(s)) + s
|
return struct.pack("<BQ", 255, len(s)) + s
|
||||||
|
|
||||||
|
|
||||||
def deser_uint256(f):
|
def deser_uint256(f):
|
||||||
r = 0L
|
r = 0
|
||||||
for i in xrange(8):
|
for i in range(8):
|
||||||
t = struct.unpack("<I", f.read(4))[0]
|
t = struct.unpack("<I", f.read(4))[0]
|
||||||
r += t << (i * 32)
|
r += t << (i * 32)
|
||||||
return r
|
return r
|
||||||
|
@ -94,23 +97,23 @@ def deser_uint256(f):
|
||||||
|
|
||||||
def ser_uint256(u):
|
def ser_uint256(u):
|
||||||
rs = b""
|
rs = b""
|
||||||
for i in xrange(8):
|
for i in range(8):
|
||||||
rs += struct.pack("<I", u & 0xFFFFFFFFL)
|
rs += struct.pack("<I", u & 0xFFFFFFFF)
|
||||||
u >>= 32
|
u >>= 32
|
||||||
return rs
|
return rs
|
||||||
|
|
||||||
|
|
||||||
def uint256_from_str(s):
|
def uint256_from_str(s):
|
||||||
r = 0L
|
r = 0
|
||||||
t = struct.unpack("<IIIIIIII", s[:32])
|
t = struct.unpack("<IIIIIIII", s[:32])
|
||||||
for i in xrange(8):
|
for i in range(8):
|
||||||
r += t[i] << (i * 32)
|
r += t[i] << (i * 32)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def uint256_from_compact(c):
|
def uint256_from_compact(c):
|
||||||
nbytes = (c >> 24) & 0xFF
|
nbytes = (c >> 24) & 0xFF
|
||||||
v = (c & 0xFFFFFFL) << (8 * (nbytes - 3))
|
v = (c & 0xFFFFFF) << (8 * (nbytes - 3))
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,7 +126,7 @@ def deser_vector(f, c):
|
||||||
elif nit == 255:
|
elif nit == 255:
|
||||||
nit = struct.unpack("<Q", f.read(8))[0]
|
nit = struct.unpack("<Q", f.read(8))[0]
|
||||||
r = []
|
r = []
|
||||||
for i in xrange(nit):
|
for i in range(nit):
|
||||||
t = c()
|
t = c()
|
||||||
t.deserialize(f)
|
t.deserialize(f)
|
||||||
r.append(t)
|
r.append(t)
|
||||||
|
@ -136,7 +139,7 @@ def ser_vector(l):
|
||||||
r = struct.pack("B", len(l))
|
r = struct.pack("B", len(l))
|
||||||
elif len(l) < 0x10000:
|
elif len(l) < 0x10000:
|
||||||
r = struct.pack("<BH", 253, len(l))
|
r = struct.pack("<BH", 253, len(l))
|
||||||
elif len(l) < 0x100000000L:
|
elif len(l) < 0x100000000:
|
||||||
r = struct.pack("<BI", 254, len(l))
|
r = struct.pack("<BI", 254, len(l))
|
||||||
else:
|
else:
|
||||||
r = struct.pack("<BQ", 255, len(l))
|
r = struct.pack("<BQ", 255, len(l))
|
||||||
|
@ -154,7 +157,7 @@ def deser_uint256_vector(f):
|
||||||
elif nit == 255:
|
elif nit == 255:
|
||||||
nit = struct.unpack("<Q", f.read(8))[0]
|
nit = struct.unpack("<Q", f.read(8))[0]
|
||||||
r = []
|
r = []
|
||||||
for i in xrange(nit):
|
for i in range(nit):
|
||||||
t = deser_uint256(f)
|
t = deser_uint256(f)
|
||||||
r.append(t)
|
r.append(t)
|
||||||
return r
|
return r
|
||||||
|
@ -166,7 +169,7 @@ def ser_uint256_vector(l):
|
||||||
r = struct.pack("B", len(l))
|
r = struct.pack("B", len(l))
|
||||||
elif len(l) < 0x10000:
|
elif len(l) < 0x10000:
|
||||||
r = struct.pack("<BH", 253, len(l))
|
r = struct.pack("<BH", 253, len(l))
|
||||||
elif len(l) < 0x100000000L:
|
elif len(l) < 0x100000000:
|
||||||
r = struct.pack("<BI", 254, len(l))
|
r = struct.pack("<BI", 254, len(l))
|
||||||
else:
|
else:
|
||||||
r = struct.pack("<BQ", 255, len(l))
|
r = struct.pack("<BQ", 255, len(l))
|
||||||
|
@ -184,7 +187,7 @@ def deser_string_vector(f):
|
||||||
elif nit == 255:
|
elif nit == 255:
|
||||||
nit = struct.unpack("<Q", f.read(8))[0]
|
nit = struct.unpack("<Q", f.read(8))[0]
|
||||||
r = []
|
r = []
|
||||||
for i in xrange(nit):
|
for i in range(nit):
|
||||||
t = deser_string(f)
|
t = deser_string(f)
|
||||||
r.append(t)
|
r.append(t)
|
||||||
return r
|
return r
|
||||||
|
@ -196,7 +199,7 @@ def ser_string_vector(l):
|
||||||
r = struct.pack("B", len(l))
|
r = struct.pack("B", len(l))
|
||||||
elif len(l) < 0x10000:
|
elif len(l) < 0x10000:
|
||||||
r = struct.pack("<BH", 253, len(l))
|
r = struct.pack("<BH", 253, len(l))
|
||||||
elif len(l) < 0x100000000L:
|
elif len(l) < 0x100000000:
|
||||||
r = struct.pack("<BI", 254, len(l))
|
r = struct.pack("<BI", 254, len(l))
|
||||||
else:
|
else:
|
||||||
r = struct.pack("<BQ", 255, len(l))
|
r = struct.pack("<BQ", 255, len(l))
|
||||||
|
@ -214,7 +217,7 @@ def deser_int_vector(f):
|
||||||
elif nit == 255:
|
elif nit == 255:
|
||||||
nit = struct.unpack("<Q", f.read(8))[0]
|
nit = struct.unpack("<Q", f.read(8))[0]
|
||||||
r = []
|
r = []
|
||||||
for i in xrange(nit):
|
for i in range(nit):
|
||||||
t = struct.unpack("<i", f.read(4))[0]
|
t = struct.unpack("<i", f.read(4))[0]
|
||||||
r.append(t)
|
r.append(t)
|
||||||
return r
|
return r
|
||||||
|
@ -226,7 +229,7 @@ def ser_int_vector(l):
|
||||||
r = struct.pack("B", len(l))
|
r = struct.pack("B", len(l))
|
||||||
elif len(l) < 0x10000:
|
elif len(l) < 0x10000:
|
||||||
r = struct.pack("<BH", 253, len(l))
|
r = struct.pack("<BH", 253, len(l))
|
||||||
elif len(l) < 0x100000000L:
|
elif len(l) < 0x100000000:
|
||||||
r = struct.pack("<BI", 254, len(l))
|
r = struct.pack("<BI", 254, len(l))
|
||||||
else:
|
else:
|
||||||
r = struct.pack("<BQ", 255, len(l))
|
r = struct.pack("<BQ", 255, len(l))
|
||||||
|
@ -277,7 +280,7 @@ class CInv(object):
|
||||||
1: "TX",
|
1: "TX",
|
||||||
2: "Block"}
|
2: "Block"}
|
||||||
|
|
||||||
def __init__(self, t=0, h=0L):
|
def __init__(self, t=0, h=0):
|
||||||
self.type = t
|
self.type = t
|
||||||
self.hash = h
|
self.hash = h
|
||||||
|
|
||||||
|
@ -528,7 +531,7 @@ class CBlock(CBlockHeader):
|
||||||
hashes.append(ser_uint256(tx.sha256))
|
hashes.append(ser_uint256(tx.sha256))
|
||||||
while len(hashes) > 1:
|
while len(hashes) > 1:
|
||||||
newhashes = []
|
newhashes = []
|
||||||
for i in xrange(0, len(hashes), 2):
|
for i in range(0, len(hashes), 2):
|
||||||
i2 = min(i+1, len(hashes)-1)
|
i2 = min(i+1, len(hashes)-1)
|
||||||
newhashes.append(hash256(hashes[i] + hashes[i2]))
|
newhashes.append(hash256(hashes[i] + hashes[i2]))
|
||||||
hashes = newhashes
|
hashes = newhashes
|
||||||
|
@ -781,7 +784,7 @@ class msg_getblocks(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.locator = CBlockLocator()
|
self.locator = CBlockLocator()
|
||||||
self.hashstop = 0L
|
self.hashstop = 0
|
||||||
|
|
||||||
def deserialize(self, f):
|
def deserialize(self, f):
|
||||||
self.locator = CBlockLocator()
|
self.locator = CBlockLocator()
|
||||||
|
@ -869,7 +872,7 @@ class msg_ping_prebip31(object):
|
||||||
class msg_ping(object):
|
class msg_ping(object):
|
||||||
command = b"ping"
|
command = b"ping"
|
||||||
|
|
||||||
def __init__(self, nonce=0L):
|
def __init__(self, nonce=0):
|
||||||
self.nonce = nonce
|
self.nonce = nonce
|
||||||
|
|
||||||
def deserialize(self, f):
|
def deserialize(self, f):
|
||||||
|
@ -941,7 +944,7 @@ class msg_getheaders(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.locator = CBlockLocator()
|
self.locator = CBlockLocator()
|
||||||
self.hashstop = 0L
|
self.hashstop = 0
|
||||||
|
|
||||||
def deserialize(self, f):
|
def deserialize(self, f):
|
||||||
self.locator = CBlockLocator()
|
self.locator = CBlockLocator()
|
||||||
|
@ -989,7 +992,7 @@ class msg_reject(object):
|
||||||
self.message = b""
|
self.message = b""
|
||||||
self.code = 0
|
self.code = 0
|
||||||
self.reason = b""
|
self.reason = b""
|
||||||
self.data = 0L
|
self.data = 0
|
||||||
|
|
||||||
def deserialize(self, f):
|
def deserialize(self, f):
|
||||||
self.message = deser_string(f)
|
self.message = deser_string(f)
|
||||||
|
@ -1030,7 +1033,7 @@ def wait_until(predicate, attempts=float('inf'), timeout=float('inf')):
|
||||||
class msg_feefilter(object):
|
class msg_feefilter(object):
|
||||||
command = b"feefilter"
|
command = b"feefilter"
|
||||||
|
|
||||||
def __init__(self, feerate=0L):
|
def __init__(self, feerate=0):
|
||||||
self.feerate = feerate
|
self.feerate = feerate
|
||||||
|
|
||||||
def deserialize(self, f):
|
def deserialize(self, f):
|
||||||
|
@ -1079,10 +1082,10 @@ class NodeConnCB(object):
|
||||||
time.sleep(deliver_sleep)
|
time.sleep(deliver_sleep)
|
||||||
with mininode_lock:
|
with mininode_lock:
|
||||||
try:
|
try:
|
||||||
getattr(self, 'on_' + message.command)(conn, message)
|
getattr(self, 'on_' + message.command.decode('ascii'))(conn, message)
|
||||||
except:
|
except:
|
||||||
print "ERROR delivering %s (%s)" % (repr(message),
|
print("ERROR delivering %s (%s)" % (repr(message),
|
||||||
sys.exc_info()[0])
|
sys.exc_info()[0]))
|
||||||
|
|
||||||
def on_version(self, conn, message):
|
def on_version(self, conn, message):
|
||||||
if message.nVersion >= 209:
|
if message.nVersion >= 209:
|
||||||
|
@ -1200,8 +1203,8 @@ class NodeConn(asyncore.dispatcher):
|
||||||
vt.addrFrom.ip = "0.0.0.0"
|
vt.addrFrom.ip = "0.0.0.0"
|
||||||
vt.addrFrom.port = 0
|
vt.addrFrom.port = 0
|
||||||
self.send_message(vt, True)
|
self.send_message(vt, True)
|
||||||
print 'MiniNode: Connecting to Bitcoin Node IP # ' + dstaddr + ':' \
|
print('MiniNode: Connecting to Bitcoin Node IP # ' + dstaddr + ':' \
|
||||||
+ str(dstport)
|
+ str(dstport))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.connect((dstaddr, dstport))
|
self.connect((dstaddr, dstport))
|
||||||
|
@ -1294,7 +1297,9 @@ class NodeConn(asyncore.dispatcher):
|
||||||
self.show_debug_msg("Unknown command: '" + command + "' " +
|
self.show_debug_msg("Unknown command: '" + command + "' " +
|
||||||
repr(msg))
|
repr(msg))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print 'got_data:', repr(e)
|
print('got_data:', repr(e))
|
||||||
|
# import traceback
|
||||||
|
# traceback.print_tb(sys.exc_info()[2])
|
||||||
|
|
||||||
def send_message(self, message, pushbuf=False):
|
def send_message(self, message, pushbuf=False):
|
||||||
if self.state != "connected" and not pushbuf:
|
if self.state != "connected" and not pushbuf:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
|
#!/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.
|
||||||
|
|
||||||
#
|
#
|
||||||
# script.py
|
# script.py
|
||||||
#
|
#
|
||||||
# This file is modified from python-bitcoinlib.
|
# This file is modified from python-bitcoinlib.
|
||||||
#
|
#
|
||||||
# Distributed under the MIT/X11 software license, see the accompanying
|
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
||||||
#
|
|
||||||
|
|
||||||
"""Scripts
|
"""Scripts
|
||||||
|
|
||||||
Functionality to build scripts, as well as SignatureHash().
|
Functionality to build scripts, as well as SignatureHash().
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
||||||
|
|
||||||
from .mininode import CTransaction, CTxOut, hash256
|
from .mininode import CTransaction, CTxOut, hash256
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
@ -658,7 +659,7 @@ class CScript(bytes):
|
||||||
other = bchr(CScriptOp(OP_0))
|
other = bchr(CScriptOp(OP_0))
|
||||||
else:
|
else:
|
||||||
other = CScriptNum.encode(other)
|
other = CScriptNum.encode(other)
|
||||||
elif isinstance(other, (int, long)):
|
elif isinstance(other, int):
|
||||||
if 0 <= other <= 16:
|
if 0 <= other <= 16:
|
||||||
other = bytes(bchr(CScriptOp.encode_op_n(other)))
|
other = bytes(bchr(CScriptOp.encode_op_n(other)))
|
||||||
elif other == -1:
|
elif other == -1:
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
# 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
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
'''
|
'''
|
||||||
Dummy Socks5 server for testing.
|
Dummy Socks5 server for testing.
|
||||||
'''
|
'''
|
||||||
from __future__ import print_function, division, unicode_literals
|
|
||||||
import socket, threading, Queue
|
import socket, threading, queue
|
||||||
import traceback, sys
|
import traceback, sys
|
||||||
|
|
||||||
### Protocol constants
|
### Protocol constants
|
||||||
|
@ -132,7 +133,7 @@ class Socks5Server(object):
|
||||||
self.s.listen(5)
|
self.s.listen(5)
|
||||||
self.running = False
|
self.running = False
|
||||||
self.thread = None
|
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):
|
def run(self):
|
||||||
while self.running:
|
while self.running:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ class ComparisonTestFramework(BitcoinTestFramework):
|
||||||
help="bitcoind binary to use for reference nodes (if any)")
|
help="bitcoind binary to use for reference nodes (if any)")
|
||||||
|
|
||||||
def setup_chain(self):
|
def setup_chain(self):
|
||||||
print "Initializing test directory "+self.options.tmpdir
|
print("Initializing test directory "+self.options.tmpdir)
|
||||||
initialize_chain_clean(self.options.tmpdir, self.num_nodes)
|
initialize_chain_clean(self.options.tmpdir, self.num_nodes)
|
||||||
|
|
||||||
def setup_network(self):
|
def setup_network(self):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# 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
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -191,10 +192,10 @@ def initialize_chain(test_dir):
|
||||||
args.append("-connect=127.0.0.1:"+str(p2p_port(0)))
|
args.append("-connect=127.0.0.1:"+str(p2p_port(0)))
|
||||||
bitcoind_processes[i] = subprocess.Popen(args)
|
bitcoind_processes[i] = subprocess.Popen(args)
|
||||||
if os.getenv("PYTHON_DEBUG", ""):
|
if os.getenv("PYTHON_DEBUG", ""):
|
||||||
print "initialize_chain: bitcoind started, waiting for RPC to come up"
|
print("initialize_chain: bitcoind started, waiting for RPC to come up")
|
||||||
wait_for_bitcoind_start(bitcoind_processes[i], rpc_url(i), i)
|
wait_for_bitcoind_start(bitcoind_processes[i], rpc_url(i), i)
|
||||||
if os.getenv("PYTHON_DEBUG", ""):
|
if os.getenv("PYTHON_DEBUG", ""):
|
||||||
print "initialize_chain: RPC succesfully started"
|
print("initialize_chain: RPC succesfully started")
|
||||||
|
|
||||||
rpcs = []
|
rpcs = []
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
|
@ -275,11 +276,11 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
|
||||||
if extra_args is not None: args.extend(extra_args)
|
if extra_args is not None: args.extend(extra_args)
|
||||||
bitcoind_processes[i] = subprocess.Popen(args)
|
bitcoind_processes[i] = subprocess.Popen(args)
|
||||||
if os.getenv("PYTHON_DEBUG", ""):
|
if os.getenv("PYTHON_DEBUG", ""):
|
||||||
print "start_node: bitcoind started, waiting for RPC to come up"
|
print("start_node: bitcoind started, waiting for RPC to come up")
|
||||||
url = rpc_url(i, rpchost)
|
url = rpc_url(i, rpchost)
|
||||||
wait_for_bitcoind_start(bitcoind_processes[i], url, i)
|
wait_for_bitcoind_start(bitcoind_processes[i], url, i)
|
||||||
if os.getenv("PYTHON_DEBUG", ""):
|
if os.getenv("PYTHON_DEBUG", ""):
|
||||||
print "start_node: RPC succesfully started"
|
print("start_node: RPC succesfully started")
|
||||||
proxy = get_rpc_proxy(url, i, timeout=timewait)
|
proxy = get_rpc_proxy(url, i, timeout=timewait)
|
||||||
|
|
||||||
if COVERAGE_DIR:
|
if COVERAGE_DIR:
|
||||||
|
@ -469,7 +470,7 @@ def assert_is_hex_string(string):
|
||||||
"Couldn't interpret %r as hexadecimal; raised: %s" % (string, e))
|
"Couldn't interpret %r as hexadecimal; raised: %s" % (string, e))
|
||||||
|
|
||||||
def assert_is_hash_string(string, length=64):
|
def assert_is_hash_string(string, length=64):
|
||||||
if not isinstance(string, basestring):
|
if not isinstance(string, str):
|
||||||
raise AssertionError("Expected a string, got type %r" % type(string))
|
raise AssertionError("Expected a string, got type %r" % type(string))
|
||||||
elif length and len(string) != length:
|
elif length and len(string) != length:
|
||||||
raise AssertionError(
|
raise AssertionError(
|
||||||
|
@ -520,7 +521,7 @@ def create_confirmed_utxos(fee, node, count):
|
||||||
addr2 = node.getnewaddress()
|
addr2 = node.getnewaddress()
|
||||||
if iterations <= 0:
|
if iterations <= 0:
|
||||||
return utxos
|
return utxos
|
||||||
for i in xrange(iterations):
|
for i in range(iterations):
|
||||||
t = utxos.pop()
|
t = utxos.pop()
|
||||||
inputs = []
|
inputs = []
|
||||||
inputs.append({ "txid" : t["txid"], "vout" : t["vout"]})
|
inputs.append({ "txid" : t["txid"], "vout" : t["vout"]})
|
||||||
|
@ -546,11 +547,11 @@ def gen_return_txouts():
|
||||||
# So we have big transactions (and therefore can't fit very many into each block)
|
# So we have big transactions (and therefore can't fit very many into each block)
|
||||||
# create one script_pubkey
|
# create one script_pubkey
|
||||||
script_pubkey = "6a4d0200" #OP_RETURN OP_PUSH2 512 bytes
|
script_pubkey = "6a4d0200" #OP_RETURN OP_PUSH2 512 bytes
|
||||||
for i in xrange (512):
|
for i in range (512):
|
||||||
script_pubkey = script_pubkey + "01"
|
script_pubkey = script_pubkey + "01"
|
||||||
# concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change
|
# concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change
|
||||||
txouts = "81"
|
txouts = "81"
|
||||||
for k in xrange(128):
|
for k in range(128):
|
||||||
# add txout value
|
# add txout value
|
||||||
txouts = txouts + "0000000000000000"
|
txouts = txouts + "0000000000000000"
|
||||||
# add length of script_pubkey
|
# add length of script_pubkey
|
||||||
|
@ -572,7 +573,7 @@ def create_tx(node, coinbase, to_address, amount):
|
||||||
def create_lots_of_big_transactions(node, txouts, utxos, fee):
|
def create_lots_of_big_transactions(node, txouts, utxos, fee):
|
||||||
addr = node.getnewaddress()
|
addr = node.getnewaddress()
|
||||||
txids = []
|
txids = []
|
||||||
for i in xrange(len(utxos)):
|
for i in range(len(utxos)):
|
||||||
t = utxos.pop()
|
t = utxos.pop()
|
||||||
inputs = []
|
inputs = []
|
||||||
inputs.append({ "txid" : t["txid"], "vout" : t["vout"]})
|
inputs.append({ "txid" : t["txid"], "vout" : t["vout"]})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
assert_equal(len(self.nodes[1].listunspent()), 0)
|
assert_equal(len(self.nodes[1].listunspent()), 0)
|
||||||
assert_equal(len(self.nodes[2].listunspent()), 0)
|
assert_equal(len(self.nodes[2].listunspent()), 0)
|
||||||
|
|
||||||
print "Mining blocks..."
|
print("Mining blocks...")
|
||||||
|
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ class WalletTest (BitcoinTestFramework):
|
||||||
'-salvagewallet',
|
'-salvagewallet',
|
||||||
]
|
]
|
||||||
for m in maintenance:
|
for m in maintenance:
|
||||||
print "check " + m
|
print("check " + m)
|
||||||
stop_nodes(self.nodes)
|
stop_nodes(self.nodes)
|
||||||
wait_bitcoinds()
|
wait_bitcoinds()
|
||||||
self.nodes = start_nodes(3, self.options.tmpdir, [[m]] * 3)
|
self.nodes = start_nodes(3, self.options.tmpdir, [[m]] * 3)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class ZapWalletTXesTest (BitcoinTestFramework):
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
def run_test (self):
|
def run_test (self):
|
||||||
print "Mining blocks..."
|
print("Mining blocks...")
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[1].generate(101)
|
self.nodes[1].generate(101)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2015 The Bitcoin Core developers
|
# Copyright (c) 2015-2016 The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -10,17 +10,10 @@
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import *
|
from test_framework.util import *
|
||||||
import zmq
|
import zmq
|
||||||
import binascii
|
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
try:
|
import http.client
|
||||||
import http.client as httplib
|
import urllib.parse
|
||||||
except ImportError:
|
|
||||||
import httplib
|
|
||||||
try:
|
|
||||||
import urllib.parse as urlparse
|
|
||||||
except ImportError:
|
|
||||||
import urlparse
|
|
||||||
|
|
||||||
class ZMQTest (BitcoinTestFramework):
|
class ZMQTest (BitcoinTestFramework):
|
||||||
|
|
||||||
|
@ -45,7 +38,7 @@ class ZMQTest (BitcoinTestFramework):
|
||||||
genhashes = self.nodes[0].generate(1)
|
genhashes = self.nodes[0].generate(1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
print "listen..."
|
print("listen...")
|
||||||
msg = self.zmqSubSocket.recv_multipart()
|
msg = self.zmqSubSocket.recv_multipart()
|
||||||
topic = msg[0]
|
topic = msg[0]
|
||||||
assert_equal(topic, b"hashtx")
|
assert_equal(topic, b"hashtx")
|
||||||
|
|
Loading…
Reference in a new issue