Merge #13054: tests: Enable automatic detection of undefined names in Python tests scripts. Remove wildcard imports.

68400d8b96 tests: Use explicit imports (practicalswift)

Pull request description:

  Enable automatic detection of undefined names in Python tests scripts. Remove wildcard imports.

  Wildcard imports make it unclear which names are present in the namespace, confusing both readers and many automated tools.

  An additional benefit of not using wildcard imports in tests scripts is that readers of a test script then can infer the rough testing scope just by looking at the imports.

  Before this commit:

  ```
  $ contrib/devtools/lint-python.sh | head -10
  ./test/functional/feature_rbf.py:8:1: F403 'from test_framework.util import *' used; unable to detect undefined names
  ./test/functional/feature_rbf.py:9:1: F403 'from test_framework.script import *' used; unable to detect undefined names
  ./test/functional/feature_rbf.py:10:1: F403 'from test_framework.mininode import *' used; unable to detect undefined names
  ./test/functional/feature_rbf.py:15:12: F405 bytes_to_hex_str may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util
  ./test/functional/feature_rbf.py:17:58: F405 CScript may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util
  ./test/functional/feature_rbf.py:25:13: F405 COIN may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util
  ./test/functional/feature_rbf.py:26:31: F405 satoshi_round may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util
  ./test/functional/feature_rbf.py:26:60: F405 COIN may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util
  ./test/functional/feature_rbf.py:30:41: F405 satoshi_round may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util
  ./test/functional/feature_rbf.py:30:68: F405 COIN may be undefined, or defined from star imports: test_framework.mininode, test_framework.script, test_framework.util
  $
  ```

  After this commit:

  ```
  $ contrib/devtools/lint-python.sh | head -10
  $
  ```

Tree-SHA512: 3f826d39cffb6438388e5efcb20a9622ff8238247e882d68f7b38609877421b2a8e10e9229575f8eb6a8fa42dec4256986692e92922c86171f750a0e887438d9
This commit is contained in:
MarcoFalke 2018-08-13 08:24:43 -04:00 committed by UdjinM6
parent 7f46a29dee
commit 9f4f52ae4e
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9
65 changed files with 209 additions and 140 deletions

View File

@ -7,12 +7,13 @@
# Test addressindex generation and fetching
#
import binascii
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_node import ErrorMatch
from test_framework.util import *
from test_framework.script import *
from test_framework.mininode import *
import binascii
from test_framework.script import CScript, OP_CHECKSIG, OP_DUP, OP_EQUAL, OP_EQUALVERIFY, OP_HASH160
from test_framework.util import assert_equal, connect_nodes
class AddressIndexTest(BitcoinTestFramework):

View File

@ -4,10 +4,11 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test BIP68 implementation."""
from test_framework.blocktools import create_block, create_coinbase
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, FromHex, ToHex
from test_framework.script import CScript
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.blocktools import *
from test_framework.messages import FromHex, ToHex
from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, get_bip9_status, satoshi_round
SEQUENCE_LOCKTIME_DISABLE_FLAG = (1<<31)
SEQUENCE_LOCKTIME_TYPE_FLAG = (1<<22) # this means use time (0 means height)

View File

@ -8,7 +8,7 @@ import struct
from test_framework.blocktools import create_block, create_coinbase, create_tx_with_script, get_legacy_sigopcount_block
from test_framework.key import CECKey
from test_framework.mininode import (
from test_framework.messages import (
CBlock,
COIN,
COutPoint,

View File

@ -8,11 +8,13 @@ Test that the CHECKLOCKTIMEVERIFY soft-fork activates at (regtest) block height
1351.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.mininode import *
from test_framework.blocktools import create_coinbase, create_block, create_transaction
from test_framework.messages import CTransaction, msg_block, ToHex
from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP, CScriptNum
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, hex_str_to_bytes, wait_until
from io import BytesIO
CLTV_HEIGHT = 1351

View File

@ -47,7 +47,7 @@ from itertools import product
from io import BytesIO
from test_framework.blocktools import create_coinbase, create_block, create_transaction
from test_framework.mininode import ToHex, CTransaction
from test_framework.messages import ToHex, CTransaction
from test_framework.mininode import P2PDataStore
from test_framework.script import (
CScript,

View File

@ -31,10 +31,9 @@ import random
import sys
import time
from test_framework.mininode import *
from test_framework.script import *
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, ToHex
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, create_confirmed_utxos, hex_str_to_bytes
HTTP_DISCONNECT_ERRORS = [http.client.CannotSendRequest]
try:

View File

@ -7,11 +7,12 @@
Test that the DERSIG soft-fork activates at (regtest) height 1251.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.mininode import *
from test_framework.blocktools import create_coinbase, create_block, create_transaction
from test_framework.messages import msg_block
from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.script import CScript
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, wait_until
DERSIG_HEIGHT = 1251

View File

@ -2,8 +2,7 @@
# Copyright (c) 2015-2020 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.messages import COutPoint, CTransaction, CTxIn, CTxOut, ToHex
from test_framework.mininode import COIN
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, ToHex
from test_framework.script import CScript, OP_CAT, OP_DROP, OP_TRUE
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, get_bip9_status, satoshi_round

View File

@ -6,11 +6,13 @@
#
# Test deterministic masternodes
#
from decimal import Decimal
from test_framework.blocktools import create_block, create_coinbase, get_masternode_payment
from test_framework.messages import uint256_to_string
from test_framework.mininode import CTransaction, ToHex, FromHex, COIN, CCbTx
from test_framework.messages import CCbTx, COIN, CTransaction, FromHex, ToHex, uint256_to_string
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, connect_nodes, force_finish_mnsync, get_bip9_status, p2p_port
class Masternode(object):
pass

View File

@ -2,9 +2,6 @@
# Copyright (c) 2015-2021 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.mininode import *
from test_framework.test_framework import DashTestFramework
from test_framework.util import assert_equal
'''
feature_dip4_coinbasemerkleroots.py
@ -13,6 +10,14 @@ Checks DIP4 merkle roots in coinbases
'''
from io import BytesIO
from test_framework.messages import CBlock, CBlockHeader, CCbTx, CMerkleBlock, FromHex, hash256, msg_getmnlistd, QuorumId, ser_uint256
from test_framework.mininode import P2PInterface
from test_framework.test_framework import DashTestFramework
from test_framework.util import assert_equal, wait_until
class TestP2PConn(P2PInterface):
def __init__(self):
super().__init__()

View File

@ -6,7 +6,7 @@
from decimal import Decimal
import random
from test_framework.mininode import CTransaction, CTxIn, CTxOut, COutPoint, ToHex, COIN
from test_framework.messages import CTransaction, CTxIn, CTxOut, COutPoint, ToHex, COIN
from test_framework.script import CScript, OP_1, OP_DROP, OP_2, OP_HASH160, OP_EQUAL, hash160, OP_TRUE
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (

View File

@ -4,9 +4,12 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Tests around dash governance objects."""
import json
import time
from test_framework.messages import uint256_to_string
from test_framework.test_framework import DashTestFramework
from test_framework.util import *
from test_framework.messages import *
from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error
def validate_object(prepared, rpc_prepared):

View File

@ -3,12 +3,6 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
import time
from test_framework.mininode import *
from test_framework.test_framework import DashTestFramework
from test_framework.util import *
'''
feature_llmq_chainlocks.py
@ -16,6 +10,12 @@ Checks LLMQs based ChainLocks
'''
import time
from test_framework.test_framework import DashTestFramework
from test_framework.util import connect_nodes, isolate_node, reconnect_isolated_node
class LLMQChainLocksTest(DashTestFramework):
def set_test_params(self):
self.set_dash_test_params(4, 3, fast_dip3_enforcement=True)

View File

@ -3,9 +3,6 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.test_framework import DashTestFramework
from test_framework.util import *
'''
feature_llmq_connections.py
@ -13,6 +10,12 @@ Checks intra quorum connections
'''
import time
from test_framework.test_framework import DashTestFramework
from test_framework.util import assert_greater_than_or_equal, connect_nodes, wait_until
class LLMQConnections(DashTestFramework):
def set_test_params(self):
self.set_dash_test_params(15, 14, fast_dip3_enforcement=True)

View File

@ -2,13 +2,6 @@
# Copyright (c) 2015-2021 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
import time
from decimal import Decimal
from test_framework.blocktools import get_masternode_payment, create_coinbase, create_block
from test_framework.mininode import *
from test_framework.test_framework import DashTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, get_bip9_status
'''
feature_llmq_is_cl_conflicts.py
@ -17,6 +10,18 @@ Checks conflict handling between ChainLocks and InstantSend
'''
from codecs import encode
from decimal import Decimal
import struct
import time
from test_framework.blocktools import get_masternode_payment, create_coinbase, create_block
from test_framework.messages import CCbTx, CInv, COIN, CTransaction, FromHex, hash256, msg_clsig, msg_inv, ser_string, ToHex, uint256_from_str, uint256_to_string
from test_framework.mininode import P2PInterface
from test_framework.test_framework import DashTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, hex_str_to_bytes, get_bip9_status
class TestP2PConn(P2PInterface):
def __init__(self):
super().__init__()

View File

@ -3,10 +3,6 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.mininode import *
from test_framework.test_framework import DashTestFramework
from test_framework.util import set_node_times, isolate_node, reconnect_isolated_node
'''
feature_llmq_is_retroactive.py
@ -17,6 +13,12 @@ Mempool inconsistencies are simulated via disconnecting/reconnecting node 3
and by having a higher relay fee on nodes 4 and 5.
'''
import time
from test_framework.test_framework import DashTestFramework
from test_framework.util import set_node_times, isolate_node, reconnect_isolated_node
class LLMQ_IS_RetroactiveSigning(DashTestFramework):
def set_test_params(self):
# -whitelist is needed to avoid the trickling logic on node0

View File

@ -3,10 +3,6 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.mininode import *
from test_framework.test_framework import DashTestFramework
from test_framework.util import *
'''
feature_llmq_signing.py
@ -14,6 +10,12 @@ Checks LLMQs signing sessions
'''
from test_framework.messages import CSigShare, msg_qsigshare, uint256_to_string
from test_framework.mininode import P2PInterface
from test_framework.test_framework import DashTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, force_finish_mnsync, hex_str_to_bytes, wait_until
class LLMQSigningTest(DashTestFramework):
def set_test_params(self):
self.set_dash_test_params(6, 5, fast_dip3_enforcement=True)

View File

@ -3,11 +3,6 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
import time
from test_framework.test_framework import DashTestFramework
from test_framework.util import *
'''
feature_llmq_simplepose.py
@ -15,6 +10,12 @@ Checks simple PoSe system based on LLMQ commitments
'''
import time
from test_framework.test_framework import DashTestFramework
from test_framework.util import connect_nodes, force_finish_mnsync, p2p_port, wait_until
class LLMQSimplePoSeTest(DashTestFramework):
def set_test_params(self):
self.set_dash_test_params(6, 5, fast_dip3_enforcement=True)

View File

@ -12,9 +12,11 @@ if uploadtarget has been reached.
"""
from collections import defaultdict
from test_framework.mininode import *
from test_framework.messages import CInv, MAX_BLOCK_SIZE, msg_getdata
from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, mine_large_block, set_node_times
class TestP2PConn(P2PInterface):
def __init__(self):

View File

@ -13,11 +13,12 @@ Generate 427 more blocks.
[Policy/Consensus] Check that the new NULLDUMMY rules are enforced on the 432nd block.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.messages import CTransaction
from test_framework.blocktools import create_coinbase, create_block, create_transaction
from test_framework.messages import CTransaction
from test_framework.script import CScript
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str
NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero) (code 64)"

View File

@ -10,7 +10,8 @@ This test takes 30 mins or more (up to 2 hours)
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, connect_nodes, mine_large_block, wait_until
import os
MIN_BLOCKS_TO_KEEP = 288

View File

@ -7,12 +7,15 @@
# Test addressindex generation and fetching
#
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_node import ErrorMatch
from test_framework.util import *
from test_framework.script import *
from test_framework.mininode import *
import binascii
from decimal import Decimal
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut
from test_framework.script import CScript, OP_CHECKSIG, OP_DUP, OP_EQUALVERIFY, OP_HASH160
from test_framework.test_node import ErrorMatch
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, connect_nodes
class SpentIndexTest(BitcoinTestFramework):

View File

@ -9,7 +9,7 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_node import ErrorMatch
from test_framework.util import *
from test_framework.util import assert_equal, connect_nodes
class TimestampIndexTest(BitcoinTestFramework):

View File

@ -7,12 +7,14 @@
# Test txindex generation and fetching
#
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.script import *
from test_framework.mininode import *
import binascii
from test_framework.messages import COutPoint, CTransaction, CTxIn, CTxOut
from test_framework.script import CScript, OP_CHECKSIG, OP_DUP, OP_EQUALVERIFY, OP_HASH160
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, connect_nodes
class TxIndexTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -5,7 +5,7 @@
"""Test the RPC HTTP basics."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, str_to_b64str
import http.client
import urllib.parse

View File

@ -9,7 +9,7 @@ from codecs import encode
from test_framework.test_framework import (
BitcoinTestFramework, skip_if_no_bitcoind_zmq, skip_if_no_py3_zmq)
from test_framework.mininode import dashhash
from test_framework.messages import dashhash
from test_framework.util import (assert_equal,
bytes_to_hex_str,
hash256,

View File

@ -4,8 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test mempool limiting together/eviction with the wallet."""
from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, create_confirmed_utxos, create_lots_of_big_transactions, gen_return_txouts
class MempoolLimitTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -4,9 +4,11 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test descendant package tracking code."""
from decimal import Decimal
from test_framework.messages import COIN
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.mininode import COIN
from test_framework.util import assert_equal, assert_raises_rpc_error, satoshi_round
MAX_ANCESTORS = 25
MAX_DESCENDANTS = 25

View File

@ -35,11 +35,12 @@ Test is as follows:
node1 can't write to disk.
"""
from decimal import Decimal
import os
import time
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, assert_raises_rpc_error, wait_until
class MempoolPersistTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -8,9 +8,9 @@ Test re-org scenarios with a mempool that contains transactions
that spend (directly or indirectly) coinbase transactions.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.blocktools import create_raw_transaction
from test_framework.util import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error
class MempoolCoinbaseTest(BitcoinTestFramework):

View File

@ -4,9 +4,9 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test resurrection of mined transactions when the blockchain is re-organized."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.blocktools import create_raw_transaction
from test_framework.util import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
class MempoolCoinbaseTest(BitcoinTestFramework):

View File

@ -12,9 +12,11 @@ in the next block are accepted into the memory pool,
but less mature coinbase spends are NOT.
"""
from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
from test_framework.blocktools import create_raw_transaction
from test_framework.util import *
from test_framework.util import assert_equal, assert_raises_rpc_error
class MempoolSpendCoinbaseTest(BitcoinTestFramework):

View File

@ -13,7 +13,7 @@ from binascii import b2a_hex
from decimal import Decimal
from test_framework.blocktools import create_coinbase
from test_framework.mininode import CBlock
from test_framework.messages import CBlock
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error

View File

@ -4,8 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test longpolling with getblocktemplate."""
from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import get_rpc_proxy, random_transaction, wait_until
import threading

View File

@ -4,9 +4,9 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the prioritisetransaction mining RPC."""
from test_framework.messages import COIN, MAX_BLOCK_SIZE
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.mininode import COIN, MAX_BLOCK_SIZE
from test_framework.util import assert_equal, assert_raises_rpc_error, create_confirmed_utxos, create_lots_of_big_transactions, gen_return_txouts
class PrioritiseTransactionTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -5,12 +5,14 @@
"""CompactBlocksTest -- test compact blocks (BIP 152, without segwit support, version 1)
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.blocktools import create_block, create_coinbase
from test_framework.script import CScript, OP_TRUE, OP_DROP
import random
from test_framework.blocktools import create_block, create_coinbase
from test_framework.messages import BlockTransactions, BlockTransactionsRequest, calculate_shortid, CBlock, CBlockHeader, CInv, COutPoint, CTransaction, CTxIn, CTxOut, FromHex, HeaderAndShortIDs, msg_block, msg_blocktxn, msg_cmpctblock, msg_getblocktxn, msg_getdata, msg_getheaders, msg_headers, msg_inv, msg_sendcmpct, msg_sendheaders, msg_tx, NODE_NETWORK, P2PHeaderAndShortIDs, PrefilledTransaction, ToHex
from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.script import CScript, OP_TRUE, OP_DROP
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, wait_until
# TestP2PConn: A peer we use to send messages to dashd, and store responses.
class TestP2PConn(P2PInterface):

View File

@ -10,18 +10,18 @@ the node should pretend that it does not have it to avoid fingerprinting.
import time
from test_framework.blocktools import (create_block, create_coinbase)
from test_framework.messages import CInv
from test_framework.mininode import (
CInv,
P2PInterface,
msg_headers,
msg_block,
msg_getdata,
msg_getheaders,
wait_until,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
wait_until,
)
class P2PFingerprintTest(BitcoinTestFramework):

View File

@ -3,10 +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.mininode import *
from test_framework.test_framework import DashTestFramework
from test_framework.util import isolate_node, reconnect_isolated_node, assert_equal, \
assert_raises_rpc_error
from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, hash256, hex_str_to_bytes, isolate_node, reconnect_isolated_node
'''
p2p_instantsend.py

View File

@ -13,7 +13,8 @@ re-requested.
import copy
from test_framework.blocktools import create_block, create_coinbase, create_tx_with_script
from test_framework.mininode import P2PDataStore, COIN
from test_framework.messages import COIN
from test_framework.mininode import P2PDataStore
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal

View File

@ -7,7 +7,7 @@
In this test we connect to one node over p2p, and test tx requests."""
from test_framework.blocktools import create_block, create_coinbase, create_tx_with_script
from test_framework.mininode import (
from test_framework.messages import (
COIN,
COutPoint,
CTransaction,

View File

@ -11,9 +11,12 @@ This test connects to a node and sends it a few messages, trying to entice it
into sending us something it shouldn't.
"""
from test_framework.mininode import *
import time
from test_framework.messages import msg_getaddr, msg_ping, msg_verack
from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import wait_until
banscore = 10

View File

@ -8,9 +8,10 @@ Test that nodes are disconnected if they send mempool messages when bloom
filters are not enabled.
"""
from test_framework.mininode import *
from test_framework.messages import msg_mempool
from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal
class P2PMempoolTests(BitcoinTestFramework):
def set_test_params(self):

View File

@ -9,9 +9,9 @@ and that it responds to getdata requests for blocks correctly:
- send a block within 288 + 2 of the tip
- disconnect peers who request blocks older than that."""
from test_framework.messages import CInv, msg_getdata, NODE_BLOOM, NODE_NETWORK_LIMITED, msg_verack
from test_framework.mininode import P2PInterface, wait_until, mininode_lock
from test_framework.mininode import P2PInterface, mininode_lock
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, disconnect_nodes, connect_nodes_bi, sync_blocks
from test_framework.util import assert_equal, disconnect_nodes, connect_nodes_bi, sync_blocks, wait_until
class P2PIgnoreInv(P2PInterface):
firstAddrnServices = 0

View File

@ -86,9 +86,9 @@ e. Announce one more that doesn't connect.
Expect: disconnect.
"""
from test_framework.blocktools import create_block, create_coinbase
from test_framework.messages import CInv
from test_framework.mininode import (
CBlockHeader,
CInv,
P2PInterface,
mininode_lock,
msg_block,

View File

@ -23,9 +23,9 @@
from time import sleep
from test_framework.mininode import *
from test_framework.messages import msg_ping
from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
class TestP2PConn(P2PInterface):
def on_version(self, message):

View File

@ -51,10 +51,12 @@ Node1 is unused in tests 3-7:
work on its chain).
"""
from test_framework.mininode import *
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.blocktools import create_block, create_coinbase, create_tx_with_script
from test_framework.messages import CBlockHeader, CInv, msg_block, msg_headers, msg_inv
from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes
class AcceptBlockTest(BitcoinTestFramework):

View File

@ -6,9 +6,9 @@
import sys
from test_framework.netutil import all_interfaces, addr_to_hex, get_bind_addrs, test_ipv6_local
from test_framework.test_framework import BitcoinTestFramework, SkipTest
from test_framework.util import *
from test_framework.netutil import *
from test_framework.util import assert_equal, assert_raises_rpc_error, get_rpc_proxy, rpc_port, rpc_url
class RPCBindTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -4,9 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test decoding scripts via decodescript RPC command."""
from test_framework.messages import CTransaction
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.mininode import *
from test_framework.util import assert_equal, bytes_to_hex_str, hex_str_to_bytes
from io import BytesIO
class DecodeScriptTest(BitcoinTestFramework):

View File

@ -3,8 +3,11 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from decimal import Decimal
from test_framework.authproxy import JSONRPCException
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, assert_greater_than, connect_nodes_bi
# Create one-input, one-output, no-fee transaction:
class RawTransactionsTest(BitcoinTestFramework):

View File

@ -4,8 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the invalidateblock RPC."""
import time
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, connect_nodes, connect_nodes_bi, wait_until
class InvalidateTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -3,9 +3,10 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.mininode import *
from test_framework.messages import hash256
from test_framework.mininode import P2PInterface
from test_framework.test_framework import DashTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error
from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, hex_str_to_bytes
'''
rpc_mnauth.py

View File

@ -13,10 +13,11 @@ Test the following RPCs:
"""
from collections import OrderedDict
from decimal import Decimal
from io import BytesIO
from test_framework.messages import CTransaction, ToHex
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, connect_nodes_bi, hex_str_to_bytes
class multidict(dict):
"""Dictionary that allows duplicate keys.

View File

@ -5,7 +5,7 @@
"""Test transaction signing using the signrawtransaction* RPCs."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, assert_raises_rpc_error
class SignRawTransactionsTest(BitcoinTestFramework):

View File

@ -4,10 +4,11 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test gettxoutproof and verifytxoutproof RPCs."""
from decimal import Decimal
from test_framework.messages import CMerkleBlock, FromHex, ToHex
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.mininode import FromHex, ToHex
from test_framework.messages import CMerkleBlock
from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes
class MerkleBlockTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -20,9 +20,10 @@ from io import BytesIO
import logging
import struct
import sys
import time
import threading
from test_framework.messages import *
from test_framework.messages import CBlockHeader, MIN_VERSION_SUPPORTED, msg_addr, msg_addrv2, msg_block, msg_blocktxn, msg_clsig, msg_cmpctblock, msg_getaddr, msg_getblocks, msg_getblocktxn, msg_getdata, msg_getheaders, msg_getmnlistd, msg_headers, msg_inv, msg_islock, msg_mempool, msg_mnlistdiff, msg_ping, msg_pong, msg_qdata, msg_qgetdata, msg_reject, msg_sendaddrv2, msg_sendcmpct, msg_sendheaders, msg_tx, msg_verack, msg_version, MY_SUBVERSION, NODE_NETWORK, sha256
from test_framework.util import wait_until
MSG_TX = 1

View File

@ -7,13 +7,12 @@
This file is modified from python-bitcoinlib.
"""
from .mininode import CTransaction, CTxOut, sha256, hash256
from binascii import hexlify
import hashlib
import struct
from .bignum import bn2vch
from .messages import CTransaction, CTxOut, sha256, hash256
MAX_SCRIPT_ELEMENT_SIZE = 520

View File

@ -10,9 +10,10 @@
which are not included in a block and are not currently in the mempool. It has
no effect on transactions which are already abandoned.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, disconnect_nodes
class AbandonConflictTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -30,11 +30,13 @@ confirm 1/2/3/4 balances are same as before.
Shutdown again, restore using importwallet,
and confirm again balances are correct.
"""
from decimal import Decimal
import os
from random import randint
import shutil
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes
class WalletBackupTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -9,7 +9,7 @@
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_raises_rpc_error
class DisableWalletTest (BitcoinTestFramework):
def set_test_params(self):

View File

@ -5,8 +5,7 @@
"""Test wallet group functionality."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.mininode import FromHex, ToHex
from test_framework.messages import CTransaction
from test_framework.messages import CTransaction, FromHex, ToHex
from test_framework.util import (
assert_equal,
)

View File

@ -6,7 +6,7 @@
from test_framework import script
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, bytes_to_hex_str
class ImportMultiTest (BitcoinTestFramework):
def set_test_params(self):

View File

@ -4,8 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the wallet keypool and interaction with wallet encryption/locking."""
import time
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal, assert_raises_rpc_error
class KeyPoolTest(BitcoinTestFramework):
def set_test_params(self):

View File

@ -7,8 +7,11 @@
# Add python-bitcoinrpc to module search path:
import time
from test_framework.authproxy import JSONRPCException
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
from test_framework.util import assert_equal
class KeyPoolTest(BitcoinTestFramework):

View File

@ -6,7 +6,7 @@
from decimal import Decimal
from io import BytesIO
from test_framework.mininode import CTransaction
from test_framework.messages import CTransaction
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_array_result,

View File

@ -30,6 +30,8 @@ export LC_ALL=C
# E306 expected 1 blank line before a nested definition
# E401 multiple imports on one line
# E402 module level import not at top of file
# F403 'from foo_module import *' used; unable to detect undefined names
# F405 foo_function may be undefined, or defined from star imports: bar_module
# E502 the backslash is redundant between brackets
# E701 multiple statements on one line (colon)
# E702 multiple statements on one line (semicolon)
@ -85,4 +87,4 @@ elif PYTHONWARNINGS="ignore" flake8 --version | grep -q "Python 2"; then
exit 0
fi
PYTHONWARNINGS="ignore" git ls-files "*.py" | xargs flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W191,W291,W292,W601,W602,W603,W604,W606 #,E741,W504,W605
PYTHONWARNINGS="ignore" git ls-files "*.py" | xargs flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E742,E743,E901,E902,F401,F402,F403,F404,F405,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W191,W291,W292,W601,W602,W603,W604,W606 #,E741,W504,W605