From 64937fe51acc269fc96b784fc97bd4cfe3c1d072 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sat, 2 May 2015 12:53:35 +0200 Subject: [PATCH 1/6] [QA] restructure rpc tests directory * move non-test classes to subdir `test-framework` --- qa/rpc-tests/bipdersig-p2p.py | 12 ++++++------ qa/rpc-tests/bipdersig.py | 5 ++--- qa/rpc-tests/forknotify.py | 5 ++--- qa/rpc-tests/getblocktemplate_longpoll.py | 5 ++--- qa/rpc-tests/getblocktemplate_proposals.py | 5 ++--- qa/rpc-tests/getchaintips.py | 4 ++-- qa/rpc-tests/httpbasics.py | 4 ++-- qa/rpc-tests/invalidateblock.py | 5 ++--- qa/rpc-tests/invalidblockrequest.py | 10 +++++----- qa/rpc-tests/keypool.py | 4 ++-- qa/rpc-tests/listtransactions.py | 5 ++--- qa/rpc-tests/maxblocksinflight.py | 6 +++--- qa/rpc-tests/mempool_coinbase_spends.py | 5 ++--- qa/rpc-tests/mempool_resurrect_test.py | 6 ++---- qa/rpc-tests/mempool_spendcoinbase.py | 5 ++--- qa/rpc-tests/merkle_blocks.py | 5 ++--- qa/rpc-tests/proxy_test.py | 6 +++--- qa/rpc-tests/pruning.py | 5 ++--- qa/rpc-tests/receivedby.py | 5 ++--- qa/rpc-tests/reindex.py | 5 ++--- qa/rpc-tests/rest.py | 5 +++-- qa/rpc-tests/rpcbind_test.py | 5 ++--- qa/rpc-tests/script_test.py | 14 +++++++------- qa/rpc-tests/smartfees.py | 5 ++--- .../bitcoinrpc => test_framework}/__init__.py | 0 qa/rpc-tests/{ => test_framework}/bignum.py | 0 qa/rpc-tests/{ => test_framework}/blockstore.py | 0 qa/rpc-tests/{ => test_framework}/blocktools.py | 0 qa/rpc-tests/{ => test_framework}/comptool.py | 0 qa/rpc-tests/{ => test_framework}/mininode.py | 0 qa/rpc-tests/{ => test_framework}/netutil.py | 0 .../python-bitcoinrpc/bitcoinrpc/.gitignore | 0 .../python-bitcoinrpc/bitcoinrpc/__init__.py | 0 .../python-bitcoinrpc/bitcoinrpc/authproxy.py | 0 .../python-bitcoinrpc/setup.py | 0 qa/rpc-tests/{ => test_framework}/script.py | 4 ++-- qa/rpc-tests/{ => test_framework}/socks5.py | 0 .../{ => test_framework}/test_framework.py | 0 qa/rpc-tests/{ => test_framework}/util.py | 0 qa/rpc-tests/txn_doublespend.py | 5 ++--- qa/rpc-tests/wallet.py | 5 ++--- qa/rpc-tests/zapwallettxes.py | 4 ++-- 42 files changed, 71 insertions(+), 88 deletions(-) rename qa/rpc-tests/{python-bitcoinrpc/bitcoinrpc => test_framework}/__init__.py (100%) rename qa/rpc-tests/{ => test_framework}/bignum.py (100%) rename qa/rpc-tests/{ => test_framework}/blockstore.py (100%) rename qa/rpc-tests/{ => test_framework}/blocktools.py (100%) rename qa/rpc-tests/{ => test_framework}/comptool.py (100%) rename qa/rpc-tests/{ => test_framework}/mininode.py (100%) rename qa/rpc-tests/{ => test_framework}/netutil.py (100%) rename qa/rpc-tests/{ => test_framework}/python-bitcoinrpc/bitcoinrpc/.gitignore (100%) create mode 100644 qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/__init__.py rename qa/rpc-tests/{ => test_framework}/python-bitcoinrpc/bitcoinrpc/authproxy.py (100%) rename qa/rpc-tests/{ => test_framework}/python-bitcoinrpc/setup.py (100%) rename qa/rpc-tests/{ => test_framework}/script.py (99%) rename qa/rpc-tests/{ => test_framework}/socks5.py (100%) rename qa/rpc-tests/{ => test_framework}/test_framework.py (100%) rename qa/rpc-tests/{ => test_framework}/util.py (100%) diff --git a/qa/rpc-tests/bipdersig-p2p.py b/qa/rpc-tests/bipdersig-p2p.py index ff0c87889..41717377b 100755 --- a/qa/rpc-tests/bipdersig-p2p.py +++ b/qa/rpc-tests/bipdersig-p2p.py @@ -4,14 +4,14 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. # -from test_framework import ComparisonTestFramework -from util import * -from mininode import CTransaction, NetworkThread -from blocktools import create_coinbase, create_block +from test_framework.test_framework import ComparisonTestFramework +from test_framework.util import * +from test_framework.mininode import CTransaction, NetworkThread +from test_framework.blocktools import create_coinbase, create_block +from test_framework.comptool import TestInstance, TestManager +from test_framework.script import CScript from binascii import hexlify, unhexlify import cStringIO -from comptool import TestInstance, TestManager -from script import CScript import time # A canonical signature consists of: diff --git a/qa/rpc-tests/bipdersig.py b/qa/rpc-tests/bipdersig.py index 2c43bba86..243f816f6 100755 --- a/qa/rpc-tests/bipdersig.py +++ b/qa/rpc-tests/bipdersig.py @@ -7,9 +7,8 @@ # Test the BIP66 changeover logic # -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * import os import shutil diff --git a/qa/rpc-tests/forknotify.py b/qa/rpc-tests/forknotify.py index af22ffb1a..0acef8e30 100755 --- a/qa/rpc-tests/forknotify.py +++ b/qa/rpc-tests/forknotify.py @@ -7,9 +7,8 @@ # Test -alertnotify # -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * import os import shutil diff --git a/qa/rpc-tests/getblocktemplate_longpoll.py b/qa/rpc-tests/getblocktemplate_longpoll.py index 64fe49b83..aab456242 100755 --- a/qa/rpc-tests/getblocktemplate_longpoll.py +++ b/qa/rpc-tests/getblocktemplate_longpoll.py @@ -3,9 +3,8 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * def check_array_result(object_array, to_match, expected): diff --git a/qa/rpc-tests/getblocktemplate_proposals.py b/qa/rpc-tests/getblocktemplate_proposals.py index a63f456d6..aca0cd749 100755 --- a/qa/rpc-tests/getblocktemplate_proposals.py +++ b/qa/rpc-tests/getblocktemplate_proposals.py @@ -3,9 +3,8 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * from binascii import a2b_hex, b2a_hex from hashlib import sha256 diff --git a/qa/rpc-tests/getchaintips.py b/qa/rpc-tests/getchaintips.py index 83a953728..6a2bcb296 100755 --- a/qa/rpc-tests/getchaintips.py +++ b/qa/rpc-tests/getchaintips.py @@ -7,8 +7,8 @@ # on chains of different lengths, and join the network together again. # This gives us two tips, verify that it works. -from test_framework import BitcoinTestFramework -from util import assert_equal +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_equal class GetChainTipsTest (BitcoinTestFramework): diff --git a/qa/rpc-tests/httpbasics.py b/qa/rpc-tests/httpbasics.py index 24533741e..64ba49df6 100755 --- a/qa/rpc-tests/httpbasics.py +++ b/qa/rpc-tests/httpbasics.py @@ -7,8 +7,8 @@ # Test REST interface # -from test_framework import BitcoinTestFramework -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * import base64 try: diff --git a/qa/rpc-tests/invalidateblock.py b/qa/rpc-tests/invalidateblock.py index fd8a8e578..2b9c8154e 100755 --- a/qa/rpc-tests/invalidateblock.py +++ b/qa/rpc-tests/invalidateblock.py @@ -7,9 +7,8 @@ # Test InvalidateBlock code # -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * class InvalidateTest(BitcoinTestFramework): diff --git a/qa/rpc-tests/invalidblockrequest.py b/qa/rpc-tests/invalidblockrequest.py index 8b685ed9b..64b8e2639 100755 --- a/qa/rpc-tests/invalidblockrequest.py +++ b/qa/rpc-tests/invalidblockrequest.py @@ -4,11 +4,11 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. # -from test_framework import ComparisonTestFramework -from util import * -from comptool import TestManager, TestInstance -from mininode import * -from blocktools import * +from test_framework.test_framework import ComparisonTestFramework +from test_framework.util import * +from test_framework.comptool import TestManager, TestInstance +from test_framework.mininode import * +from test_framework.blocktools import * import logging import copy import time diff --git a/qa/rpc-tests/keypool.py b/qa/rpc-tests/keypool.py index 3840ea39d..307919d72 100755 --- a/qa/rpc-tests/keypool.py +++ b/qa/rpc-tests/keypool.py @@ -8,7 +8,7 @@ # Add python-bitcoinrpc to module search path: import os import sys -sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "python-bitcoinrpc")) +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_framework/python-bitcoinrpc")) import json import shutil @@ -17,7 +17,7 @@ import tempfile import traceback from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.util import * def check_array_result(object_array, to_match, expected): diff --git a/qa/rpc-tests/listtransactions.py b/qa/rpc-tests/listtransactions.py index 11e3635c0..eeae2d2fa 100755 --- a/qa/rpc-tests/listtransactions.py +++ b/qa/rpc-tests/listtransactions.py @@ -5,9 +5,8 @@ # Exercise the listtransactions API -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * def check_array_result(object_array, to_match, expected): diff --git a/qa/rpc-tests/maxblocksinflight.py b/qa/rpc-tests/maxblocksinflight.py index 87c80cd97..a601147ce 100755 --- a/qa/rpc-tests/maxblocksinflight.py +++ b/qa/rpc-tests/maxblocksinflight.py @@ -4,9 +4,9 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. # -from mininode import * -from test_framework import BitcoinTestFramework -from util import * +from test_framework.mininode import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * import logging ''' diff --git a/qa/rpc-tests/mempool_coinbase_spends.py b/qa/rpc-tests/mempool_coinbase_spends.py index 853d031de..c64a15b9f 100755 --- a/qa/rpc-tests/mempool_coinbase_spends.py +++ b/qa/rpc-tests/mempool_coinbase_spends.py @@ -8,9 +8,8 @@ # that spend (directly or indirectly) coinbase transactions. # -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * import os import shutil diff --git a/qa/rpc-tests/mempool_resurrect_test.py b/qa/rpc-tests/mempool_resurrect_test.py index 6f7f577e3..19c74bb75 100755 --- a/qa/rpc-tests/mempool_resurrect_test.py +++ b/qa/rpc-tests/mempool_resurrect_test.py @@ -8,9 +8,8 @@ # the blockchain is re-organized. # -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * import os import shutil @@ -34,7 +33,6 @@ class MempoolCoinbaseTest(BitcoinTestFramework): def run_test(self): node0_address = self.nodes[0].getnewaddress() - # Spend block 1/2/3's coinbase transactions # Mine a block. # Create three more transactions, spending the spends diff --git a/qa/rpc-tests/mempool_spendcoinbase.py b/qa/rpc-tests/mempool_spendcoinbase.py index ab5817c86..fc17c5069 100755 --- a/qa/rpc-tests/mempool_spendcoinbase.py +++ b/qa/rpc-tests/mempool_spendcoinbase.py @@ -13,9 +13,8 @@ # but less mature coinbase spends are NOT. # -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * import os import shutil diff --git a/qa/rpc-tests/merkle_blocks.py b/qa/rpc-tests/merkle_blocks.py index a143d21a2..72a80ce6c 100755 --- a/qa/rpc-tests/merkle_blocks.py +++ b/qa/rpc-tests/merkle_blocks.py @@ -7,9 +7,8 @@ # Test merkleblock fetch/validation # -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * import os import shutil diff --git a/qa/rpc-tests/proxy_test.py b/qa/rpc-tests/proxy_test.py index d6d9e6725..9a9b2f530 100755 --- a/qa/rpc-tests/proxy_test.py +++ b/qa/rpc-tests/proxy_test.py @@ -7,9 +7,9 @@ import traceback, sys from binascii import hexlify import time, os -from socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType -from test_framework import BitcoinTestFramework -from util import * +from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * ''' Test plan: - Start bitcoind's with different proxy configurations diff --git a/qa/rpc-tests/pruning.py b/qa/rpc-tests/pruning.py index 85fd1c982..2824c51ce 100755 --- a/qa/rpc-tests/pruning.py +++ b/qa/rpc-tests/pruning.py @@ -11,9 +11,8 @@ # This test takes 30 mins or more (up to 2 hours) # ******** -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * import os.path def calc_usage(blockdir): diff --git a/qa/rpc-tests/receivedby.py b/qa/rpc-tests/receivedby.py index 1a681e1aa..16d6bd4cf 100755 --- a/qa/rpc-tests/receivedby.py +++ b/qa/rpc-tests/receivedby.py @@ -5,9 +5,8 @@ # Exercise the listreceivedbyaddress API -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * def get_sub_array_from_array(object_array, to_match): diff --git a/qa/rpc-tests/reindex.py b/qa/rpc-tests/reindex.py index fe767586b..f2e3f248e 100755 --- a/qa/rpc-tests/reindex.py +++ b/qa/rpc-tests/reindex.py @@ -6,9 +6,8 @@ # # Test -reindex with CheckBlockIndex # -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * import os.path class ReindexTest(BitcoinTestFramework): diff --git a/qa/rpc-tests/rest.py b/qa/rpc-tests/rest.py index 9f0d049fe..fdb2508f5 100755 --- a/qa/rpc-tests/rest.py +++ b/qa/rpc-tests/rest.py @@ -7,8 +7,9 @@ # Test REST interface # -from test_framework import BitcoinTestFramework -from util import * + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * from struct import * import binascii import json diff --git a/qa/rpc-tests/rpcbind_test.py b/qa/rpc-tests/rpcbind_test.py index 655e00b6e..5ccc57347 100755 --- a/qa/rpc-tests/rpcbind_test.py +++ b/qa/rpc-tests/rpcbind_test.py @@ -16,9 +16,8 @@ import subprocess import tempfile import traceback -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * -from netutil import * +from test_framework.util import * +from test_framework.netutil import * def run_bind_test(tmpdir, allow_ips, connect_to, addresses, expected): ''' diff --git a/qa/rpc-tests/script_test.py b/qa/rpc-tests/script_test.py index 1ba3a478a..860fa56b6 100755 --- a/qa/rpc-tests/script_test.py +++ b/qa/rpc-tests/script_test.py @@ -19,12 +19,12 @@ that flag, we use a block time before the switchover date). NOTE: This test is very slow and may take more than 40 minutes to run. ''' -from test_framework import ComparisonTestFramework -from util import * -from comptool import TestInstance, TestManager -from mininode import * -from blocktools import * -from script import * +from test_framework.test_framework import ComparisonTestFramework +from test_framework.util import * +from test_framework.comptool import TestInstance, TestManager +from test_framework.mininode import * +from test_framework.blocktools import * +from test_framework.script import * import logging import copy import json @@ -42,7 +42,7 @@ class ScriptTestFile(object): def load_files(self): for f in self.files: - self.data.extend(json.loads(open(f).read())) + self.data.extend(json.loads(open(os.path.dirname(os.path.abspath(__file__))+"/"+f).read())) # Skip over records that are not long enough to be tests def get_records(self): diff --git a/qa/rpc-tests/smartfees.py b/qa/rpc-tests/smartfees.py index 69f3c22c1..c15c5fda0 100755 --- a/qa/rpc-tests/smartfees.py +++ b/qa/rpc-tests/smartfees.py @@ -7,9 +7,8 @@ # Test fee estimation code # -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * # Construct 2 trivial P2SH's and the ScriptSigs that spend them # So we can create many many transactions without needing to spend diff --git a/qa/rpc-tests/python-bitcoinrpc/bitcoinrpc/__init__.py b/qa/rpc-tests/test_framework/__init__.py similarity index 100% rename from qa/rpc-tests/python-bitcoinrpc/bitcoinrpc/__init__.py rename to qa/rpc-tests/test_framework/__init__.py diff --git a/qa/rpc-tests/bignum.py b/qa/rpc-tests/test_framework/bignum.py similarity index 100% rename from qa/rpc-tests/bignum.py rename to qa/rpc-tests/test_framework/bignum.py diff --git a/qa/rpc-tests/blockstore.py b/qa/rpc-tests/test_framework/blockstore.py similarity index 100% rename from qa/rpc-tests/blockstore.py rename to qa/rpc-tests/test_framework/blockstore.py diff --git a/qa/rpc-tests/blocktools.py b/qa/rpc-tests/test_framework/blocktools.py similarity index 100% rename from qa/rpc-tests/blocktools.py rename to qa/rpc-tests/test_framework/blocktools.py diff --git a/qa/rpc-tests/comptool.py b/qa/rpc-tests/test_framework/comptool.py similarity index 100% rename from qa/rpc-tests/comptool.py rename to qa/rpc-tests/test_framework/comptool.py diff --git a/qa/rpc-tests/mininode.py b/qa/rpc-tests/test_framework/mininode.py similarity index 100% rename from qa/rpc-tests/mininode.py rename to qa/rpc-tests/test_framework/mininode.py diff --git a/qa/rpc-tests/netutil.py b/qa/rpc-tests/test_framework/netutil.py similarity index 100% rename from qa/rpc-tests/netutil.py rename to qa/rpc-tests/test_framework/netutil.py diff --git a/qa/rpc-tests/python-bitcoinrpc/bitcoinrpc/.gitignore b/qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/.gitignore similarity index 100% rename from qa/rpc-tests/python-bitcoinrpc/bitcoinrpc/.gitignore rename to qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/.gitignore diff --git a/qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/__init__.py b/qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/qa/rpc-tests/python-bitcoinrpc/bitcoinrpc/authproxy.py b/qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/authproxy.py similarity index 100% rename from qa/rpc-tests/python-bitcoinrpc/bitcoinrpc/authproxy.py rename to qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/authproxy.py diff --git a/qa/rpc-tests/python-bitcoinrpc/setup.py b/qa/rpc-tests/test_framework/python-bitcoinrpc/setup.py similarity index 100% rename from qa/rpc-tests/python-bitcoinrpc/setup.py rename to qa/rpc-tests/test_framework/python-bitcoinrpc/setup.py diff --git a/qa/rpc-tests/script.py b/qa/rpc-tests/test_framework/script.py similarity index 99% rename from qa/rpc-tests/script.py rename to qa/rpc-tests/test_framework/script.py index 03695b863..e37ab5d45 100644 --- a/qa/rpc-tests/script.py +++ b/qa/rpc-tests/test_framework/script.py @@ -14,7 +14,7 @@ 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 test_framework.mininode import CTransaction, CTxOut, hash256 import sys bchr = chr @@ -27,7 +27,7 @@ if sys.version > '3': import copy import struct -import bignum +import test_framework.bignum MAX_SCRIPT_SIZE = 10000 MAX_SCRIPT_ELEMENT_SIZE = 520 diff --git a/qa/rpc-tests/socks5.py b/qa/rpc-tests/test_framework/socks5.py similarity index 100% rename from qa/rpc-tests/socks5.py rename to qa/rpc-tests/test_framework/socks5.py diff --git a/qa/rpc-tests/test_framework.py b/qa/rpc-tests/test_framework/test_framework.py similarity index 100% rename from qa/rpc-tests/test_framework.py rename to qa/rpc-tests/test_framework/test_framework.py diff --git a/qa/rpc-tests/util.py b/qa/rpc-tests/test_framework/util.py similarity index 100% rename from qa/rpc-tests/util.py rename to qa/rpc-tests/test_framework/util.py diff --git a/qa/rpc-tests/txn_doublespend.py b/qa/rpc-tests/txn_doublespend.py index fe9168944..99dcdae55 100755 --- a/qa/rpc-tests/txn_doublespend.py +++ b/qa/rpc-tests/txn_doublespend.py @@ -7,10 +7,9 @@ # Test proper accounting with malleable transactions # -from test_framework import BitcoinTestFramework -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * from decimal import Decimal -from util import * import os import shutil diff --git a/qa/rpc-tests/wallet.py b/qa/rpc-tests/wallet.py index b8965b366..46dc7765b 100755 --- a/qa/rpc-tests/wallet.py +++ b/qa/rpc-tests/wallet.py @@ -19,9 +19,8 @@ # k) test ResendWalletTransactions - create transactions, startup fourth node, make sure it syncs # -from test_framework import BitcoinTestFramework -from util import * - +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * class WalletTest (BitcoinTestFramework): diff --git a/qa/rpc-tests/zapwallettxes.py b/qa/rpc-tests/zapwallettxes.py index 045614e94..0ec8ec536 100755 --- a/qa/rpc-tests/zapwallettxes.py +++ b/qa/rpc-tests/zapwallettxes.py @@ -3,8 +3,8 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework import BitcoinTestFramework -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * class ZapWalletTXesTest (BitcoinTestFramework): From 344e08ed1657153a4e8d83e1cdbb36f1f9df04e8 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sat, 2 May 2015 13:15:26 +0200 Subject: [PATCH 2/6] extend rpc-tests.sh control script with non-travis tests --- qa/pull-tester/rpc-tests.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index ecde45059..7406563cb 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -31,6 +31,21 @@ testScripts=( 'proxy_test.py' 'merkle_blocks.py' 'signrawtransactions.py' +); +testScriptsExt=( + 'bipdersig-p2p.py' + 'bipdersig.py' + 'getblocktemplate_longpoll.py' + 'getblocktemplate_proposals.py' + 'prune.py' + 'forknotify.py' + 'invalidateblock.py' + 'keypool.py' + 'receivedby.py' + 'reindex.py' + 'rpcbind_test.py' + 'script_test.py' + 'smartfees.py' 'maxblocksinflight.py' 'invalidblockrequest.py' 'rawtransactions.py' @@ -39,12 +54,20 @@ testScripts=( if [ "x${ENABLE_BITCOIND}${ENABLE_UTILS}${ENABLE_WALLET}" = "x111" ]; then for (( i = 0; i < ${#testScripts[@]}; i++ )) do - if [ -z "$1" ] || [ "$1" == "${testScripts[$i]}" ] || [ "$1.py" == "${testScripts[$i]}" ] + if [ -z "$1" ] || [ "$1" == "-extended" ] || [ "$1" == "${testScripts[$i]}" ] || [ "$1.py" == "${testScripts[$i]}" ] then echo -e "Running testscript \033[1m${testScripts[$i]}...\033[0m" ${BUILDDIR}/qa/rpc-tests/${testScripts[$i]} --srcdir "${BUILDDIR}/src" fi done + for (( i = 0; i < ${#testScriptsExt[@]}; i++ )) + do + if [ "$1" == "-extended" ] || [ "$1" == "${testScriptsExt[$i]}" ] || [ "$1.py" == "${testScriptsExt[$i]}" ] + then + echo -e "Running testscript \033[1m${testScriptsExt[$i]}...\033[0m" + ${BUILDDIR}/qa/rpc-tests/${testScriptsExt[$i]} --srcdir "${BUILDDIR}/src" + fi + done else echo "No rpc tests to run. Wallet, utils, and bitcoind must all be enabled" fi From 00706a54362a04cd8938f101359c2f5dfaa294e5 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sat, 2 May 2015 13:25:03 +0200 Subject: [PATCH 3/6] update rpc-tests readme.md --- qa/rpc-tests/README.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/qa/rpc-tests/README.md b/qa/rpc-tests/README.md index d9fbb109e..6221c93d8 100644 --- a/qa/rpc-tests/README.md +++ b/qa/rpc-tests/README.md @@ -6,25 +6,37 @@ Git subtree of [https://github.com/jgarzik/python-bitcoinrpc](https://github.com Changes to python-bitcoinrpc should be made upstream, and then pulled here using git subtree. -### [test_framework.py](test_framework.py) +### [test_framework/test_framework.py](test_framework/test_framework.py) Base class for new regression tests. -### [listtransactions.py](listtransactions.py) -Tests for the listtransactions RPC call. - -### [util.py](util.py) +### [test_framework/util.py](test_framework/util.py) Generally useful functions. Bash-based tests, to be ported to Python: ----------------------------------------- -- wallet.sh : Exercise wallet send/receive code. -- walletbackup.sh : Exercise wallet backup / dump / import -- txnmall.sh : Test proper accounting of malleable transactions - conflictedbalance.sh : More testing of malleable transaction handling Notes ===== +You can run a single test by calling `qa/pull-tester/rpc-tests.sh `. + +Run all possible tests with `qa/pull-tester/rpc-tests.sh -extended`. + +Possible options: + +```` +-h, --help show this help message and exit + --nocleanup Leave bitcoinds and test.* datadir on exit or error + --noshutdown Don't stop bitcoinds after the test execution + --srcdir=SRCDIR Source directory containing bitcoind/bitcoin-cli (default: + ../../src) + --tmpdir=TMPDIR Root directory for datadirs + --tracerpc Print out all RPC calls as they are made +``` + +If you set the environment variable `PYTHON_DEBUG=1` you will get some debug output (example: `PYTHON_DEBUG=1 qa/pull-tester/rpc-tests.sh wallet`). + A 200-block -regtest blockchain and wallets for four nodes is created the first time a regression test is run and is stored in the cache/ directory. Each node has 25 mature From 3e875b1befad5ed5dbd2736c9befccd32d67721c Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sat, 2 May 2015 13:58:10 +0200 Subject: [PATCH 4/6] pull-tester/rpc-tests.sh: allow passing throug of arguments --- qa/pull-tester/rpc-tests.sh | 16 ++++++++++------ qa/rpc-tests/rawtransactions.py | 4 ++-- qa/rpc-tests/signrawtransactions.py | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 7406563cb..051027966 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -37,7 +37,7 @@ testScriptsExt=( 'bipdersig.py' 'getblocktemplate_longpoll.py' 'getblocktemplate_proposals.py' - 'prune.py' + 'pruning.py' 'forknotify.py' 'invalidateblock.py' 'keypool.py' @@ -51,21 +51,25 @@ testScriptsExt=( 'rawtransactions.py' # 'forknotify.py' ); + +extArg="-extended" +passOn=${@#$extArg} + if [ "x${ENABLE_BITCOIND}${ENABLE_UTILS}${ENABLE_WALLET}" = "x111" ]; then for (( i = 0; i < ${#testScripts[@]}; i++ )) do - if [ -z "$1" ] || [ "$1" == "-extended" ] || [ "$1" == "${testScripts[$i]}" ] || [ "$1.py" == "${testScripts[$i]}" ] + if [ -z "$1" ] || [ "${1:0:1}" == "-" ] || [ "$1" == "${testScripts[$i]}" ] || [ "$1.py" == "${testScripts[$i]}" ] then echo -e "Running testscript \033[1m${testScripts[$i]}...\033[0m" - ${BUILDDIR}/qa/rpc-tests/${testScripts[$i]} --srcdir "${BUILDDIR}/src" + ${BUILDDIR}/qa/rpc-tests/${testScripts[$i]} --srcdir "${BUILDDIR}/src" ${passOn} fi done for (( i = 0; i < ${#testScriptsExt[@]}; i++ )) do - if [ "$1" == "-extended" ] || [ "$1" == "${testScriptsExt[$i]}" ] || [ "$1.py" == "${testScriptsExt[$i]}" ] + if [ "$1" == $extArg ] || [ "$1" == "${testScriptsExt[$i]}" ] || [ "$1.py" == "${testScriptsExt[$i]}" ] then - echo -e "Running testscript \033[1m${testScriptsExt[$i]}...\033[0m" - ${BUILDDIR}/qa/rpc-tests/${testScriptsExt[$i]} --srcdir "${BUILDDIR}/src" + echo -e "Running \033[1m2nd level\033[0m testscript \033[1m${testScriptsExt[$i]}...\033[0m" + ${BUILDDIR}/qa/rpc-tests/${testScriptsExt[$i]} --srcdir "${BUILDDIR}/src" ${passOn} fi done else diff --git a/qa/rpc-tests/rawtransactions.py b/qa/rpc-tests/rawtransactions.py index 3d80c97d7..1378514c8 100755 --- a/qa/rpc-tests/rawtransactions.py +++ b/qa/rpc-tests/rawtransactions.py @@ -8,8 +8,8 @@ # that spend (directly or indirectly) coinbase transactions. # -from test_framework import BitcoinTestFramework -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * from pprint import pprint from time import sleep diff --git a/qa/rpc-tests/signrawtransactions.py b/qa/rpc-tests/signrawtransactions.py index 943634bd1..d51d6ee61 100755 --- a/qa/rpc-tests/signrawtransactions.py +++ b/qa/rpc-tests/signrawtransactions.py @@ -3,8 +3,8 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework import BitcoinTestFramework -from util import * +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import * class SignRawTransactionsTest(BitcoinTestFramework): From a85b2e221ba52e6885d609f2fcecb30a2274cfb3 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Mon, 18 May 2015 15:29:39 +0200 Subject: [PATCH 5/6] pull-tester/rpc-tests.sh: disable script_test.py test --- qa/pull-tester/rpc-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 051027966..8ed942643 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -44,7 +44,7 @@ testScriptsExt=( 'receivedby.py' 'reindex.py' 'rpcbind_test.py' - 'script_test.py' +# 'script_test.py' 'smartfees.py' 'maxblocksinflight.py' 'invalidblockrequest.py' From 7b7f258396432b6b4a0c111b06e34be03e42b000 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 21 May 2015 21:22:22 +0200 Subject: [PATCH 6/6] rpc-tests: remove python-bitcoinrpc directory place authproxy.py at same level as other utility classes --- qa/rpc-tests/keypool.py | 2 -- qa/rpc-tests/rpcbind_test.py | 1 - .../bitcoinrpc => }/authproxy.py | 0 .../python-bitcoinrpc/bitcoinrpc/.gitignore | 1 - .../python-bitcoinrpc/bitcoinrpc/__init__.py | 0 .../test_framework/python-bitcoinrpc/setup.py | 15 --------------- qa/rpc-tests/test_framework/test_framework.py | 3 +-- qa/rpc-tests/test_framework/util.py | 3 +-- 8 files changed, 2 insertions(+), 23 deletions(-) rename qa/rpc-tests/test_framework/{python-bitcoinrpc/bitcoinrpc => }/authproxy.py (100%) delete mode 100644 qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/.gitignore delete mode 100644 qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/__init__.py delete mode 100644 qa/rpc-tests/test_framework/python-bitcoinrpc/setup.py diff --git a/qa/rpc-tests/keypool.py b/qa/rpc-tests/keypool.py index 307919d72..aee29a596 100755 --- a/qa/rpc-tests/keypool.py +++ b/qa/rpc-tests/keypool.py @@ -8,7 +8,6 @@ # Add python-bitcoinrpc to module search path: import os import sys -sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_framework/python-bitcoinrpc")) import json import shutil @@ -16,7 +15,6 @@ import subprocess import tempfile import traceback -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException from test_framework.util import * diff --git a/qa/rpc-tests/rpcbind_test.py b/qa/rpc-tests/rpcbind_test.py index 5ccc57347..04110c283 100755 --- a/qa/rpc-tests/rpcbind_test.py +++ b/qa/rpc-tests/rpcbind_test.py @@ -8,7 +8,6 @@ # Add python-bitcoinrpc to module search path: import os import sys -sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "python-bitcoinrpc")) import json import shutil diff --git a/qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/authproxy.py b/qa/rpc-tests/test_framework/authproxy.py similarity index 100% rename from qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/authproxy.py rename to qa/rpc-tests/test_framework/authproxy.py diff --git a/qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/.gitignore b/qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/__init__.py b/qa/rpc-tests/test_framework/python-bitcoinrpc/bitcoinrpc/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/qa/rpc-tests/test_framework/python-bitcoinrpc/setup.py b/qa/rpc-tests/test_framework/python-bitcoinrpc/setup.py deleted file mode 100644 index 43cdb1c03..000000000 --- a/qa/rpc-tests/test_framework/python-bitcoinrpc/setup.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python2 - -from distutils.core import setup - -setup(name='python-bitcoinrpc', - version='0.1', - description='Enhanced version of python-jsonrpc for use with Bitcoin', - long_description=open('README').read(), - author='Jeff Garzik', - author_email='', - maintainer='Jeff Garzik', - maintainer_email='', - url='http://www.github.com/jgarzik/python-bitcoinrpc', - packages=['bitcoinrpc'], - classifiers=['License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)', 'Operating System :: OS Independent']) diff --git a/qa/rpc-tests/test_framework/test_framework.py b/qa/rpc-tests/test_framework/test_framework.py index 15a357a34..5671431f6 100755 --- a/qa/rpc-tests/test_framework/test_framework.py +++ b/qa/rpc-tests/test_framework/test_framework.py @@ -8,13 +8,12 @@ # Add python-bitcoinrpc to module search path: import os import sys -sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "python-bitcoinrpc")) import shutil import tempfile import traceback -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException +from authproxy import AuthServiceProxy, JSONRPCException from util import * diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 997bbcc37..c236ec260 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -8,7 +8,6 @@ # Add python-bitcoinrpc to module search path: import os import sys -sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "python-bitcoinrpc")) from decimal import Decimal, ROUND_DOWN import json @@ -18,7 +17,7 @@ import subprocess import time import re -from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException +from authproxy import AuthServiceProxy, JSONRPCException from util import * def p2p_port(n):