Browse Source

Clean up imports to be pyflakes-checkable. fixes #2450

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
metaverse
Daira Hopwood 7 years ago
parent
commit
aff0bf7fa1
  1. 4
      qa/rpc-tests/decodescript.py
  2. 3
      qa/rpc-tests/disablewallet.py
  3. 4
      qa/rpc-tests/forknotify.py
  4. 9
      qa/rpc-tests/fundrawtransaction.py
  5. 3
      qa/rpc-tests/getblocktemplate.py
  6. 4
      qa/rpc-tests/getblocktemplate_longpoll.py
  7. 2
      qa/rpc-tests/getblocktemplate_proposals.py
  8. 5
      qa/rpc-tests/hardforkdetection.py
  9. 3
      qa/rpc-tests/httpbasics.py
  10. 5
      qa/rpc-tests/invalidateblock.py
  11. 8
      qa/rpc-tests/invalidblockrequest.py
  12. 11
      qa/rpc-tests/keypool.py
  13. 2
      qa/rpc-tests/listtransactions.py
  14. 10
      qa/rpc-tests/maxblocksinflight.py
  15. 5
      qa/rpc-tests/mempool_coinbase_spends.py
  16. 5
      qa/rpc-tests/mempool_resurrect_test.py
  17. 7
      qa/rpc-tests/mempool_spendcoinbase.py
  18. 14
      qa/rpc-tests/mempool_tx_input_limit.py
  19. 7
      qa/rpc-tests/merkle_blocks.py
  20. 9
      qa/rpc-tests/nodehandling.py
  21. 11
      qa/rpc-tests/p2p-acceptblock.py
  22. 9
      qa/rpc-tests/prioritisetransaction.py
  23. 16
      qa/rpc-tests/proton_test.py
  24. 10
      qa/rpc-tests/proxy_test.py
  25. 6
      qa/rpc-tests/pruning.py
  26. 8
      qa/rpc-tests/rawtransactions.py
  27. 2
      qa/rpc-tests/receivedby.py
  28. 6
      qa/rpc-tests/reindex.py
  29. 18
      qa/rpc-tests/rest.py
  30. 13
      qa/rpc-tests/rpcbind_test.py
  31. 11
      qa/rpc-tests/script_test.py
  32. 3
      qa/rpc-tests/signrawtransactions.py
  33. 6
      qa/rpc-tests/smartfees.py
  34. 5
      qa/rpc-tests/test_framework/blockstore.py
  35. 3
      qa/rpc-tests/test_framework/blocktools.py
  36. 7
      qa/rpc-tests/test_framework/comptool.py
  37. 4
      qa/rpc-tests/test_framework/script.py
  38. 7
      qa/rpc-tests/test_framework/test_framework.py
  39. 3
      qa/rpc-tests/test_framework/util.py
  40. 7
      qa/rpc-tests/txn_doublespend.py
  41. 13
      qa/rpc-tests/wallet.py
  42. 10
      qa/rpc-tests/wallet_1941.py
  43. 15
      qa/rpc-tests/wallet_nullifiers.py
  44. 13
      qa/rpc-tests/wallet_protectcoinbase.py
  45. 11
      qa/rpc-tests/wallet_treestate.py
  46. 9
      qa/rpc-tests/walletbackup.py
  47. 4
      qa/rpc-tests/zapwallettxes.py
  48. 8
      qa/rpc-tests/zcjoinsplit.py
  49. 9
      qa/rpc-tests/zcjoinsplitdoublespend.py
  50. 13
      qa/rpc-tests/zmq_test.py

4
qa/rpc-tests/decodescript.py

@ -4,7 +4,9 @@
# 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 assert_equal, initialize_chain_clean, \
start_nodes
class DecodeScriptTest(BitcoinTestFramework): class DecodeScriptTest(BitcoinTestFramework):
"""Tests decoding scripts via RPC command "decodescript".""" """Tests decoding scripts via RPC command "decodescript"."""

3
qa/rpc-tests/disablewallet.py

@ -8,7 +8,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 initialize_chain_clean, start_nodes
class DisableWalletTest (BitcoinTestFramework): class DisableWalletTest (BitcoinTestFramework):

4
qa/rpc-tests/forknotify.py

@ -8,9 +8,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 start_node, connect_nodes
import os import os
import shutil
class ForkNotifyTest(BitcoinTestFramework): class ForkNotifyTest(BitcoinTestFramework):

9
qa/rpc-tests/fundrawtransaction.py

@ -4,9 +4,12 @@
# 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.authproxy import JSONRPCException
from pprint import pprint from test_framework.util import assert_equal, assert_greater_than, \
from time import sleep initialize_chain_clean, start_nodes, connect_nodes_bi, stop_nodes, \
wait_bitcoinds
from decimal import Decimal
# Create one-input, one-output, no-fee transaction: # Create one-input, one-output, no-fee transaction:
class RawTransactionsTest(BitcoinTestFramework): class RawTransactionsTest(BitcoinTestFramework):

3
qa/rpc-tests/getblocktemplate.py

@ -4,7 +4,8 @@
# 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 initialize_chain_clean, start_nodes, \
connect_nodes_bi
class GetBlockTemplateTest(BitcoinTestFramework): class GetBlockTemplateTest(BitcoinTestFramework):

4
qa/rpc-tests/getblocktemplate_longpoll.py

@ -4,8 +4,10 @@
# 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.authproxy import AuthServiceProxy
from test_framework.util import random_transaction
from decimal import Decimal
def check_array_result(object_array, to_match, expected): def check_array_result(object_array, to_match, expected):
""" """

2
qa/rpc-tests/getblocktemplate_proposals.py

@ -4,7 +4,7 @@
# 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.authproxy import JSONRPCException
from binascii import a2b_hex, b2a_hex from binascii import a2b_hex, b2a_hex
from hashlib import sha256 from hashlib import sha256

5
qa/rpc-tests/hardforkdetection.py

@ -5,9 +5,10 @@
# #
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, start_node
import os import os
import shutil
class HardForkDetectionTest(BitcoinTestFramework): class HardForkDetectionTest(BitcoinTestFramework):

3
qa/rpc-tests/httpbasics.py

@ -8,7 +8,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 assert_equal, start_nodes
import base64 import base64
try: try:

5
qa/rpc-tests/invalidateblock.py

@ -8,7 +8,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 initialize_chain_clean, start_node, \
connect_nodes_bi, sync_blocks
import time
class InvalidateTest(BitcoinTestFramework): class InvalidateTest(BitcoinTestFramework):

8
qa/rpc-tests/invalidblockrequest.py

@ -5,11 +5,11 @@
# #
from test_framework.test_framework import ComparisonTestFramework from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import * from test_framework.util import assert_equal
from test_framework.comptool import TestManager, TestInstance from test_framework.comptool import TestManager, TestInstance
from test_framework.mininode import * from test_framework.mininode import NetworkThread
from test_framework.blocktools import * from test_framework.blocktools import create_block, create_coinbase, create_transaction
import logging
import copy import copy
import time import time

11
qa/rpc-tests/keypool.py

@ -6,18 +6,17 @@
# Exercise the wallet keypool, and interaction with wallet encryption/locking # Exercise the wallet keypool, and interaction with wallet encryption/locking
# Add python-bitcoinrpc to module search path: # Add python-bitcoinrpc to module search path:
from test_framework.authproxy import JSONRPCException
from test_framework.util import check_json_precision, initialize_chain, \
start_nodes, start_node, stop_nodes, wait_bitcoinds, bitcoind_processes
import os import os
import sys import sys
import json
import shutil import shutil
import subprocess
import tempfile import tempfile
import traceback import traceback
from test_framework.util import *
def check_array_result(object_array, to_match, expected): def check_array_result(object_array, to_match, expected):
""" """
Pass in array of JSON objects, a dictionary with key/value pairs Pass in array of JSON objects, a dictionary with key/value pairs

2
qa/rpc-tests/listtransactions.py

@ -6,8 +6,8 @@
# Exercise the listtransactions API # Exercise the listtransactions API
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from decimal import Decimal
def check_array_result(object_array, to_match, expected): def check_array_result(object_array, to_match, expected):
""" """

10
qa/rpc-tests/maxblocksinflight.py

@ -4,9 +4,15 @@
# 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 NodeConn, NodeConnCB, NetworkThread, \
EarlyDisconnectError, CInv, msg_inv, mininode_lock
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import initialize_chain_clean, start_nodes, \
p2p_port
import os
import time
import random
import logging import logging
''' '''

5
qa/rpc-tests/mempool_coinbase_spends.py

@ -9,9 +9,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 assert_equal, start_node, connect_nodes
import os
import shutil
# Create one-input, one-output, no-fee transaction: # Create one-input, one-output, no-fee transaction:
class MempoolCoinbaseTest(BitcoinTestFramework): class MempoolCoinbaseTest(BitcoinTestFramework):

5
qa/rpc-tests/mempool_resurrect_test.py

@ -9,9 +9,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 assert_equal, start_node
import os
import shutil
# Create one-input, one-output, no-fee transaction: # Create one-input, one-output, no-fee transaction:
class MempoolCoinbaseTest(BitcoinTestFramework): class MempoolCoinbaseTest(BitcoinTestFramework):

7
qa/rpc-tests/mempool_spendcoinbase.py

@ -14,9 +14,10 @@
# #
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.authproxy import JSONRPCException
import os from test_framework.util import assert_equal, assert_greater_than, assert_raises, \
import shutil start_node
# Create one-input, one-output, no-fee transaction: # Create one-input, one-output, no-fee transaction:
class MempoolSpendCoinbaseTest(BitcoinTestFramework): class MempoolSpendCoinbaseTest(BitcoinTestFramework):

14
qa/rpc-tests/mempool_tx_input_limit.py

@ -4,10 +4,12 @@
# 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.authproxy import JSONRPCException
import os from test_framework.util import assert_equal, initialize_chain_clean, \
import shutil start_node, connect_nodes
from time import sleep
import time
from decimal import Decimal
# Test -mempooltxinputlimit # Test -mempooltxinputlimit
class MempoolTxInputLimitTest(BitcoinTestFramework): class MempoolTxInputLimitTest(BitcoinTestFramework):
@ -44,7 +46,7 @@ class MempoolTxInputLimitTest(BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[0].z_getoperationresult(opids) results = self.nodes[0].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
if status == "failed": if status == "failed":
@ -90,7 +92,7 @@ class MempoolTxInputLimitTest(BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[0].z_getoperationresult(opids) results = self.nodes[0].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
msg = results[0]["error"]["message"] msg = results[0]["error"]["message"]

7
qa/rpc-tests/merkle_blocks.py

@ -8,9 +8,10 @@
# #
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.authproxy import JSONRPCException
import os from test_framework.util import assert_equal, assert_raises, \
import shutil initialize_chain_clean, start_node, connect_nodes
class MerkleBlockTest(BitcoinTestFramework): class MerkleBlockTest(BitcoinTestFramework):

9
qa/rpc-tests/nodehandling.py

@ -8,13 +8,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 assert_equal, connect_nodes_bi, p2p_port
import base64
import time
try:
import http.client as httplib
except ImportError:
import httplib
try: try:
import urllib.parse as urlparse import urllib.parse as urlparse
except ImportError: except ImportError:

11
qa/rpc-tests/p2p-acceptblock.py

@ -4,12 +4,17 @@
# 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 CBlockHeader, CInv, NodeConn, NodeConnCB, \
NetworkThread, msg_block, msg_headers, msg_inv, msg_ping, msg_pong, \
mininode_lock
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, initialize_chain_clean, \
import time start_node, p2p_port
from test_framework.blocktools import create_block, create_coinbase from test_framework.blocktools import create_block, create_coinbase
import os
import time
''' '''
AcceptBlockTest -- test processing of unrequested blocks. AcceptBlockTest -- test processing of unrequested blocks.

9
qa/rpc-tests/prioritisetransaction.py

@ -4,9 +4,10 @@
# 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 assert_equal, initialize_chain_clean, \
from time import * start_node, connect_nodes
from test_framework.mininode import COIN from test_framework.mininode import COIN
import time import time
@ -37,7 +38,7 @@ class PrioritiseTransactionTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[0].z_getoperationresult(opids) results = self.nodes[0].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
if status == "failed": if status == "failed":
@ -120,7 +121,7 @@ class PrioritiseTransactionTest (BitcoinTestFramework):
break break
if time.time() - start > 30: if time.time() - start > 30:
raise AssertionError("Test timed out because prioritised transaction was not returned by getblocktemplate within 30 seconds.") raise AssertionError("Test timed out because prioritised transaction was not returned by getblocktemplate within 30 seconds.")
sleep(1) time.sleep(1)
block_template = self.nodes[0].getblocktemplate() block_template = self.nodes[0].getblocktemplate()
assert(in_block_template) assert(in_block_template)

16
qa/rpc-tests/proton_test.py

@ -14,21 +14,13 @@
# #
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, bytes_to_hex_str, \
start_nodes
from proton.handlers import MessagingHandler from proton.handlers import MessagingHandler
from proton.reactor import Container from proton.reactor import Container
import binascii
import struct
import threading
try: import threading
import http.client as httplib
except ImportError:
import httplib
try:
import urllib.parse as urlparse
except ImportError:
import urlparse
class Server(MessagingHandler): class Server(MessagingHandler):

10
qa/rpc-tests/proxy_test.py

@ -2,14 +2,14 @@
# Copyright (c) 2015 The Bitcoin Core developers # Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
import socket
import traceback, sys
from binascii import hexlify
import time, os
from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, start_nodes
import socket
import os
''' '''
Test plan: Test plan:
- Start bitcoind's with different proxy configurations - Start bitcoind's with different proxy configurations

6
qa/rpc-tests/pruning.py

@ -12,8 +12,12 @@
# ******** # ********
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.authproxy import JSONRPCException
from test_framework.util import initialize_chain_clean, start_node, \
connect_nodes, stop_node, sync_blocks
import os.path import os.path
import time
def calc_usage(blockdir): def calc_usage(blockdir):
return sum(os.path.getsize(blockdir+f) for f in os.listdir(blockdir) if os.path.isfile(blockdir+f))/(1024*1024) return sum(os.path.getsize(blockdir+f) for f in os.listdir(blockdir) if os.path.isfile(blockdir+f))/(1024*1024)

8
qa/rpc-tests/rawtransactions.py

@ -9,9 +9,11 @@
# #
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.authproxy import JSONRPCException
from pprint import pprint from test_framework.util import assert_equal, initialize_chain_clean, \
from time import sleep start_nodes, connect_nodes_bi
from decimal import Decimal
# Create one-input, one-output, no-fee transaction: # Create one-input, one-output, no-fee transaction:
class RawTransactionsTest(BitcoinTestFramework): class RawTransactionsTest(BitcoinTestFramework):

2
qa/rpc-tests/receivedby.py

@ -6,8 +6,8 @@
# Exercise the listreceivedbyaddress API # Exercise the listreceivedbyaddress API
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from decimal import Decimal
def get_sub_array_from_array(object_array, to_match): def get_sub_array_from_array(object_array, to_match):
''' '''

6
qa/rpc-tests/reindex.py

@ -6,9 +6,11 @@
# #
# Test -reindex with CheckBlockIndex # Test -reindex with CheckBlockIndex
# #
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, initialize_chain_clean, \
import os.path start_node, stop_node, wait_bitcoinds
class ReindexTest(BitcoinTestFramework): class ReindexTest(BitcoinTestFramework):

18
qa/rpc-tests/rest.py

@ -9,12 +9,14 @@
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, assert_greater_than, \
from struct import * initialize_chain_clean, start_nodes, connect_nodes_bi
import struct
import binascii import binascii
import json import json
import StringIO import StringIO
import decimal from decimal import Decimal
try: try:
import http.client as httplib import http.client as httplib
@ -28,7 +30,7 @@ except ImportError:
def deser_uint256(f): def deser_uint256(f):
r = 0 r = 0
for i in range(8): for i in range(8):
t = unpack(b"<I", f.read(4))[0] t = struct.unpack(b"<I", f.read(4))[0]
r += t << (i * 32) r += t << (i * 32)
return r return r
@ -143,15 +145,15 @@ class RESTTest (BitcoinTestFramework):
binaryRequest = b'\x01\x02' binaryRequest = b'\x01\x02'
binaryRequest += binascii.unhexlify(txid) binaryRequest += binascii.unhexlify(txid)
binaryRequest += pack("i", n); binaryRequest += struct.pack("i", n);
binaryRequest += binascii.unhexlify(vintx); binaryRequest += binascii.unhexlify(vintx);
binaryRequest += pack("i", 0); binaryRequest += struct.pack("i", 0);
bin_response = http_post_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', binaryRequest) bin_response = http_post_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', binaryRequest)
output = StringIO.StringIO() output = StringIO.StringIO()
output.write(bin_response) output.write(bin_response)
output.seek(0) output.seek(0)
chainHeight = unpack("i", output.read(4))[0] chainHeight = struct.unpack("i", output.read(4))[0]
hashFromBinResponse = hex(deser_uint256(output))[2:].zfill(65).rstrip("L") hashFromBinResponse = hex(deser_uint256(output))[2:].zfill(65).rstrip("L")
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
@ -263,7 +265,7 @@ class RESTTest (BitcoinTestFramework):
response_header_json = http_get_call(url.hostname, url.port, '/rest/headers/1/'+bb_hash+self.FORMAT_SEPARATOR+"json", True) response_header_json = http_get_call(url.hostname, url.port, '/rest/headers/1/'+bb_hash+self.FORMAT_SEPARATOR+"json", True)
assert_equal(response_header_json.status, 200) assert_equal(response_header_json.status, 200)
response_header_json_str = response_header_json.read() response_header_json_str = response_header_json.read()
json_obj = json.loads(response_header_json_str, parse_float=decimal.Decimal) json_obj = json.loads(response_header_json_str, parse_float=Decimal)
assert_equal(len(json_obj), 1) #ensure that there is one header in the json response assert_equal(len(json_obj), 1) #ensure that there is one header in the json response
assert_equal(json_obj[0]['hash'], bb_hash) #request/response hash should be the same assert_equal(json_obj[0]['hash'], bb_hash) #request/response hash should be the same

13
qa/rpc-tests/rpcbind_test.py

@ -6,18 +6,19 @@
# Test for -rpcbind, as well as -rpcallowip and -rpcconnect # Test for -rpcbind, as well as -rpcallowip and -rpcconnect
# Add python-bitcoinrpc to module search path: # Add python-bitcoinrpc to module search path:
from test_framework.util import assert_equal, check_json_precision, \
initialize_chain, start_nodes, stop_nodes, wait_bitcoinds, \
bitcoind_processes, rpc_port
from test_framework.authproxy import AuthServiceProxy
from test_framework.netutil import addr_to_hex, get_bind_addrs, all_interfaces
import os import os
import sys import sys
import json
import shutil import shutil
import subprocess
import tempfile import tempfile
import traceback import traceback
from test_framework.util import *
from test_framework.netutil import *
def run_bind_test(tmpdir, allow_ips, connect_to, addresses, expected): def run_bind_test(tmpdir, allow_ips, connect_to, addresses, expected):
''' '''
Start a node with requested rpcallowip and rpcbind parameters, Start a node with requested rpcallowip and rpcbind parameters,

11
qa/rpc-tests/script_test.py

@ -20,13 +20,12 @@ NOTE: This test is very slow and may take more than 40 minutes to run.
''' '''
from test_framework.test_framework import ComparisonTestFramework from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.comptool import TestInstance, TestManager from test_framework.comptool import TestInstance, TestManager
from test_framework.mininode import * from test_framework.mininode import NetworkThread
from test_framework.blocktools import * from test_framework.blocktools import create_block, create_coinbase, create_transaction
from test_framework.script import * from test_framework.script import CScript, CScriptOp, CScriptNum, OPCODES_BY_NAME
import logging
import copy import os
import json import json
script_valid_file = "../../src/test/data/script_valid.json" script_valid_file = "../../src/test/data/script_valid.json"

3
qa/rpc-tests/signrawtransactions.py

@ -4,7 +4,8 @@
# 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 assert_equal, initialize_chain_clean, \
start_nodes
class SignRawTransactionsTest(BitcoinTestFramework): class SignRawTransactionsTest(BitcoinTestFramework):

6
qa/rpc-tests/smartfees.py

@ -8,7 +8,11 @@
# #
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import start_node, connect_nodes, \
sync_blocks, sync_mempools
import random
from decimal import Decimal, ROUND_DOWN
# Construct 2 trivial P2SH's and the ScriptSigs that spend them # Construct 2 trivial P2SH's and the ScriptSigs that spend them
# So we can create many many transactions without needing to spend # So we can create many many transactions without needing to spend

5
qa/rpc-tests/test_framework/blockstore.py

@ -3,7 +3,10 @@
# and for constructing a getheaders message # and for constructing a getheaders message
# #
from mininode import * from mininode import CBlock, CBlockHeader, CBlockLocator, CTransaction, msg_block, msg_headers, msg_tx
import sys
import cStringIO
import dbm import dbm
class BlockStore(object): class BlockStore(object):

3
qa/rpc-tests/test_framework/blocktools.py

@ -4,8 +4,7 @@
# 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 CBlock, CTransaction, CTxIn, CTxOut, COutPoint, ser_string
from script import CScript, CScriptOp
# Create a block (with regtest difficulty) # Create a block (with regtest difficulty)
def create_block(hashprev, coinbase, nTime=None): def create_block(hashprev, coinbase, nTime=None):

7
qa/rpc-tests/test_framework/comptool.py

@ -4,10 +4,13 @@
# 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 CBlock, CTransaction, CInv, NodeConn, NodeConnCB, \
msg_inv, msg_getheaders, msg_ping, msg_mempool, mininode_lock, MAX_INV_SZ
from blockstore import BlockStore, TxStore from blockstore import BlockStore, TxStore
from util import p2p_port from util import p2p_port
import time
''' '''
This is a tool for comparing two or more bitcoinds to each other This is a tool for comparing two or more bitcoinds to each other
using a script provided. using a script provided.
@ -25,8 +28,6 @@ generator that returns TestInstance objects. See below for definition.
# on_getheaders: provide headers via BlockStore # on_getheaders: provide headers via BlockStore
# on_getdata: provide blocks via BlockStore # on_getdata: provide blocks via BlockStore
global mininode_lock
def wait_until(predicate, attempts=float('inf'), timeout=float('inf')): def wait_until(predicate, attempts=float('inf'), timeout=float('inf')):
attempt = 0 attempt = 0
elapsed = 0 elapsed = 0

4
qa/rpc-tests/test_framework/script.py

@ -24,10 +24,10 @@ if sys.version > '3':
bchr = lambda x: bytes([x]) bchr = lambda x: bytes([x])
bord = lambda x: x bord = lambda x: x
import copy
import struct import struct
import binascii
import test_framework.bignum from test_framework import bignum
MAX_SCRIPT_SIZE = 10000 MAX_SCRIPT_SIZE = 10000
MAX_SCRIPT_ELEMENT_SIZE = 520 MAX_SCRIPT_ELEMENT_SIZE = 520

7
qa/rpc-tests/test_framework/test_framework.py

@ -13,8 +13,11 @@ import shutil
import tempfile import tempfile
import traceback import traceback
from authproxy import AuthServiceProxy, JSONRPCException from authproxy import JSONRPCException
from util import * from util import assert_equal, check_json_precision, \
initialize_chain, initialize_chain_clean, \
start_nodes, connect_nodes_bi, stop_nodes, \
sync_blocks, sync_mempools, wait_bitcoinds
class BitcoinTestFramework(object): class BitcoinTestFramework(object):

3
qa/rpc-tests/test_framework/util.py

@ -21,8 +21,7 @@ import subprocess
import time import time
import re import re
from authproxy import AuthServiceProxy, JSONRPCException from authproxy import AuthServiceProxy
from util import *
def p2p_port(n): def p2p_port(n):
return 11000 + n + os.getpid()%999 return 11000 + n + os.getpid()%999

7
qa/rpc-tests/txn_doublespend.py

@ -8,10 +8,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 assert_equal, connect_nodes, \
from decimal import Decimal sync_blocks, gather_inputs
import os
import shutil
class TxnMallTest(BitcoinTestFramework): class TxnMallTest(BitcoinTestFramework):

13
qa/rpc-tests/wallet.py

@ -5,8 +5,13 @@
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.authproxy import JSONRPCException
from time import * from test_framework.util import assert_equal, assert_greater_than, \
initialize_chain_clean, start_nodes, start_node, connect_nodes_bi, \
stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds
import time
from decimal import Decimal
class WalletTest (BitcoinTestFramework): class WalletTest (BitcoinTestFramework):
@ -306,7 +311,7 @@ class WalletTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[2].z_getoperationresult(opids) results = self.nodes[2].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
mytxid = results[0]["result"]["txid"] mytxid = results[0]["result"]["txid"]
@ -363,7 +368,7 @@ class WalletTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[2].z_getoperationresult(opids) results = self.nodes[2].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
break break

10
qa/rpc-tests/wallet_1941.py

@ -6,10 +6,12 @@
# This is a regression test for #1941. # This is a regression test for #1941.
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, initialize_chain_clean, \
from time import * initialize_datadir, start_nodes, start_node, connect_nodes_bi, \
bitcoind_processes
import sys import time
from decimal import Decimal
starttime = 1388534400 starttime = 1388534400
@ -49,7 +51,7 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[0].z_getoperationresult(opids) results = self.nodes[0].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
if status == "failed": if status == "failed":

15
qa/rpc-tests/wallet_nullifiers.py

@ -5,8 +5,11 @@
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, start_node, \
from time import * start_nodes, connect_nodes_bi, bitcoind_processes
import time
from decimal import Decimal
class WalletNullifiersTest (BitcoinTestFramework): class WalletNullifiersTest (BitcoinTestFramework):
@ -32,7 +35,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[0].z_getoperationresult(opids) results = self.nodes[0].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
assert_equal("success", status) assert_equal("success", status)
@ -73,7 +76,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[0].z_getoperationresult(opids) results = self.nodes[0].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
assert_equal("success", status) assert_equal("success", status)
@ -105,7 +108,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[2].z_getoperationresult(opids) results = self.nodes[2].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
assert_equal("success", status) assert_equal("success", status)
@ -146,7 +149,7 @@ class WalletNullifiersTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[1].z_getoperationresult(opids) results = self.nodes[1].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
assert_equal("success", status) assert_equal("success", status)

13
qa/rpc-tests/wallet_protectcoinbase.py

@ -5,8 +5,13 @@
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.authproxy import JSONRPCException
from time import * from test_framework.util import assert_equal, initialize_chain_clean, \
start_nodes, connect_nodes_bi
import sys
import time
from decimal import Decimal
class WalletProtectCoinbaseTest (BitcoinTestFramework): class WalletProtectCoinbaseTest (BitcoinTestFramework):
@ -35,7 +40,7 @@ class WalletProtectCoinbaseTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[0].z_getoperationresult(opids) results = self.nodes[0].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
if status == "failed": if status == "failed":
@ -94,7 +99,7 @@ class WalletProtectCoinbaseTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[0].z_getoperationresult(opids) results = self.nodes[0].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
errorString = results[0]["error"]["message"] errorString = results[0]["error"]["message"]

11
qa/rpc-tests/wallet_treestate.py

@ -5,10 +5,11 @@
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, initialize_chain_clean, \
from time import * start_nodes, connect_nodes_bi
import sys import time
from decimal import Decimal
class WalletTreeStateTest (BitcoinTestFramework): class WalletTreeStateTest (BitcoinTestFramework):
@ -35,7 +36,7 @@ class WalletTreeStateTest (BitcoinTestFramework):
for x in xrange(1, timeout): for x in xrange(1, timeout):
results = self.nodes[0].z_getoperationresult(opids) results = self.nodes[0].z_getoperationresult(opids)
if len(results)==0: if len(results)==0:
sleep(1) time.sleep(1)
else: else:
status = results[0]["status"] status = results[0]["status"]
if status == "failed": if status == "failed":
@ -106,7 +107,7 @@ class WalletTreeStateTest (BitcoinTestFramework):
status = results[0]["status"] status = results[0]["status"]
if status == "executing": if status == "executing":
break break
sleep(1) time.sleep(1)
# Now mine Tx 1 which will change global treestate before Tx 2's second joinsplit begins processing # Now mine Tx 1 which will change global treestate before Tx 2's second joinsplit begins processing
self.sync_all() self.sync_all()

9
qa/rpc-tests/walletbackup.py

@ -34,9 +34,16 @@ and confirm again balances are correct.
""" """
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, initialize_chain_clean, \
start_nodes, start_node, connect_nodes, stop_node, \
sync_blocks, sync_mempools
import os
import shutil
from random import randint from random import randint
from decimal import Decimal
import logging import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO) logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
class WalletBackupTest(BitcoinTestFramework): class WalletBackupTest(BitcoinTestFramework):

4
qa/rpc-tests/zapwallettxes.py

@ -4,7 +4,9 @@
# 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.authproxy import JSONRPCException
from test_framework.util import assert_equal, initialize_chain_clean, \
start_nodes, start_node, connect_nodes_bi, bitcoind_processes
class ZapWalletTXesTest (BitcoinTestFramework): class ZapWalletTXesTest (BitcoinTestFramework):

8
qa/rpc-tests/zcjoinsplit.py

@ -5,11 +5,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 assert_equal, start_node, \
from decimal import Decimal gather_inputs
import os
import shutil
import sys
class JoinSplitTest(BitcoinTestFramework): class JoinSplitTest(BitcoinTestFramework):
def setup_network(self): def setup_network(self):

9
qa/rpc-tests/zcjoinsplitdoublespend.py

@ -5,11 +5,10 @@
# #
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.authproxy import JSONRPCException
from decimal import Decimal from test_framework.util import assert_equal, connect_nodes, \
import os gather_inputs, sync_blocks
import shutil
import sys
import time import time
class JoinSplitTest(BitcoinTestFramework): class JoinSplitTest(BitcoinTestFramework):

13
qa/rpc-tests/zmq_test.py

@ -8,20 +8,11 @@
# #
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import * from test_framework.util import assert_equal, bytes_to_hex_str, start_nodes
import zmq import zmq
import binascii
import struct import struct
try:
import http.client as httplib
except ImportError:
import httplib
try:
import urllib.parse as urlparse
except ImportError:
import urlparse
class ZMQTest (BitcoinTestFramework): class ZMQTest (BitcoinTestFramework):
port = 28332 port = 28332

Loading…
Cancel
Save