diff --git a/test/functional/feature_assumevalid.py b/test/functional/feature_assumevalid.py --- a/test/functional/feature_assumevalid.py +++ b/test/functional/feature_assumevalid.py @@ -33,20 +33,24 @@ from test_framework.blocktools import (create_block, create_coinbase) from test_framework.key import CECKey -from test_framework.mininode import (CBlockHeader, - COutPoint, - CTransaction, - CTxIn, - CTxOut, - network_thread_join, - network_thread_start, - P2PInterface, - msg_block, - msg_headers) +from test_framework.messages import ( + CBlockHeader, + COutPoint, + CTransaction, + CTxIn, + CTxOut, + msg_block, + msg_headers, +) +from test_framework.mininode import ( + network_thread_join, + network_thread_start, + P2PInterface, +) from test_framework.script import (CScript, OP_TRUE) from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal from test_framework.txtools import pad_tx +from test_framework.util import assert_equal class BaseNode(P2PInterface): diff --git a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py --- a/test/functional/feature_bip68_sequence.py +++ b/test/functional/feature_bip68_sequence.py @@ -7,12 +7,33 @@ # Test BIP68 implementation # +import time + +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.script import * -from test_framework.mininode import * -from test_framework.blocktools import * from test_framework.txtools import pad_tx +from test_framework.util import ( + assert_equal, + assert_greater_than, + assert_raises_rpc_error, + connect_nodes, + disconnect_nodes, + satoshi_round, + sync_blocks, +) SEQUENCE_LOCKTIME_DISABLE_FLAG = (1 << 31) SEQUENCE_LOCKTIME_TYPE_FLAG = (1 << 22) # this means use time (0 means height) diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py --- a/test/functional/feature_block.py +++ b/test/functional/feature_block.py @@ -4,16 +4,58 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import ComparisonTestFramework -from test_framework.util import * -from test_framework.comptool import TestManager, TestInstance, RejectResult -from test_framework.blocktools import * +import copy +import struct import time + +from test_framework.blocktools import ( + create_block, + create_coinbase, + create_transaction, + get_legacy_sigopcount_block, + make_conform_to_ctor, +) +from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE, MAX_BLOCK_SIGOPS_PER_MB +from test_framework.comptool import RejectResult, TestInstance, TestManager from test_framework.key import CECKey -from test_framework.script import * +from test_framework.messages import ( + CBlock, + CBlockHeader, + COIN, + COutPoint, + CTransaction, + CTxIn, + CTxOut, + ser_uint256, + uint256_from_compact, + uint256_from_str, +) from test_framework.mininode import network_thread_start -import struct -from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE, MAX_BLOCK_SIGOPS_PER_MB +from test_framework.script import ( + CScript, + hash160, + MAX_SCRIPT_ELEMENT_SIZE, + OP_2DUP, + OP_CHECKMULTISIG, + OP_CHECKMULTISIGVERIFY, + OP_CHECKSIG, + OP_CHECKSIGVERIFY, + OP_ELSE, + OP_ENDIF, + OP_EQUAL, + OP_FALSE, + OP_HASH160, + OP_IF, + OP_INVALIDOPCODE, + OP_RETURN, + OP_TRUE, + SIGHASH_ALL, + SIGHASH_FORKID, + SignatureHashForkId, +) +from test_framework.test_framework import ComparisonTestFramework +from test_framework.txtools import pad_tx +from test_framework.util import assert_equal class PreviousSpendableOutput(): diff --git a/test/functional/feature_cltv.py b/test/functional/feature_cltv.py --- a/test/functional/feature_cltv.py +++ b/test/functional/feature_cltv.py @@ -8,12 +8,30 @@ 1351. """ +from test_framework.blocktools import create_block, create_coinbase +from test_framework.messages import ( + CTransaction, + FromHex, + msg_block, + msg_tx, + ToHex, +) +from test_framework.mininode import ( + mininode_lock, + network_thread_start, + P2PInterface, +) +from test_framework.script import ( + CScript, + CScriptNum, + OP_1NEGATE, + OP_CHECKLOCKTIMEVERIFY, + OP_DROP, + OP_TRUE, +) 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 -from test_framework.script import CScript, CScriptNum, OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP, OP_TRUE from test_framework.txtools import pad_tx +from test_framework.util import assert_equal, wait_until CLTV_HEIGHT = 1351 diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.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. """Test various command line arguments and configuration file parameters.""" -import time import os +import time from test_framework.test_framework import BitcoinTestFramework from test_framework.util import get_datadir_path diff --git a/test/functional/feature_csv_activation.py b/test/functional/feature_csv_activation.py --- a/test/functional/feature_csv_activation.py +++ b/test/functional/feature_csv_activation.py @@ -40,14 +40,26 @@ bip112tx_special - test negative argument to OP_CSV """ -from test_framework.test_framework import ComparisonTestFramework -from test_framework.util import * -from test_framework.mininode import ToHex, FromHex, CTransaction, network_thread_start, COIN -from test_framework.blocktools import create_coinbase, create_block, make_conform_to_ctor -from test_framework.comptool import TestInstance, TestManager -from test_framework.script import * +from decimal import Decimal import time +from test_framework.blocktools import ( + create_block, + create_coinbase, + make_conform_to_ctor, +) +from test_framework.comptool import TestInstance, TestManager +from test_framework.messages import COIN, CTransaction, FromHex, ToHex +from test_framework.mininode import network_thread_start +from test_framework.script import ( + CScript, + OP_CHECKSEQUENCEVERIFY, + OP_DROP, + OP_TRUE, +) +from test_framework.test_framework import ComparisonTestFramework +from test_framework.util import assert_equal + base_relative_locktime = 10 seq_disable_flag = 1 << 31 seq_random_high_bit = 1 << 25 diff --git a/test/functional/feature_dbcrash.py b/test/functional/feature_dbcrash.py --- a/test/functional/feature_dbcrash.py +++ b/test/functional/feature_dbcrash.py @@ -31,11 +31,17 @@ import sys import time -from test_framework.mininode import * -from test_framework.script import * -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import * from test_framework.blocktools import create_confirmed_utxos +from test_framework.messages import ( + COIN, + COutPoint, + CTransaction, + CTxIn, + CTxOut, + ToHex, +) +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_equal, hex_str_to_bytes HTTP_DISCONNECT_ERRORS = [http.client.CannotSendRequest] try: diff --git a/test/functional/feature_dersig.py b/test/functional/feature_dersig.py --- a/test/functional/feature_dersig.py +++ b/test/functional/feature_dersig.py @@ -7,11 +7,16 @@ 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 +from test_framework.blocktools import create_block, create_coinbase +from test_framework.messages import CTransaction, FromHex, msg_block +from test_framework.mininode import ( + mininode_lock, + network_thread_start, + P2PInterface, +) from test_framework.script import CScript +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_equal, wait_until DERSIG_HEIGHT = 1251 diff --git a/test/functional/feature_maxuploadtarget.py b/test/functional/feature_maxuploadtarget.py --- a/test/functional/feature_maxuploadtarget.py +++ b/test/functional/feature_maxuploadtarget.py @@ -15,11 +15,12 @@ from collections import defaultdict import time -from test_framework.mininode import * -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import * from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE from test_framework.blocktools import mine_big_block +from test_framework.messages import CInv, msg_getdata +from test_framework.mininode import network_thread_start, P2PInterface +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_equal class TestNode(P2PInterface): diff --git a/test/functional/feature_minchainwork.py b/test/functional/feature_minchainwork.py --- a/test/functional/feature_minchainwork.py +++ b/test/functional/feature_minchainwork.py @@ -18,7 +18,7 @@ import time from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import connect_nodes, assert_equal +from test_framework.util import assert_equal, connect_nodes # 2 hashes required per regtest block (with no difficulty adjustment) REGTEST_WORK_PER_BLOCK = 2 diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py --- a/test/functional/feature_notifications.py +++ b/test/functional/feature_notifications.py @@ -7,7 +7,7 @@ import os from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, wait_until, connect_nodes_bi +from test_framework.util import assert_equal, connect_nodes_bi, wait_until FORK_WARNING_MESSAGE = "Warning: Large-work fork detected, forking after block {}\n" diff --git a/test/functional/feature_nulldummy.py b/test/functional/feature_nulldummy.py --- a/test/functional/feature_nulldummy.py +++ b/test/functional/feature_nulldummy.py @@ -3,14 +3,15 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import * -from test_framework.messages import FromHex, ToHex -from test_framework.mininode import CTransaction, network_thread_start -from test_framework.blocktools import create_coinbase, create_block -from test_framework.script import CScript import time +from test_framework.blocktools import create_block, create_coinbase +from test_framework.messages import CTransaction, FromHex, ToHex +from test_framework.mininode import network_thread_start +from test_framework.script import CScript +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_equal, assert_raises_rpc_error + NULLDUMMY_ERROR = "64: non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)" diff --git a/test/functional/feature_proxy.py b/test/functional/feature_proxy.py --- a/test/functional/feature_proxy.py +++ b/test/functional/feature_proxy.py @@ -27,17 +27,22 @@ addnode connect to generic DNS name ''' -import socket import os +import socket -from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType +from test_framework.netutil import test_ipv6_local +from test_framework.socks5 import ( + AddressType, + Socks5Command, + Socks5Configuration, + Socks5Server, +) from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( + assert_equal, PORT_MIN, PORT_RANGE, - assert_equal, ) -from test_framework.netutil import test_ipv6_local RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE # Start after p2p and rpc ports diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -11,13 +11,20 @@ # 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.blocktools import mine_big_block - import time import os +from test_framework.blocktools import mine_big_block +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import ( + assert_equal, + assert_greater_than, + assert_raises_rpc_error, + connect_nodes, + sync_blocks, +) + + MIN_BLOCKS_TO_KEEP = 288 # Rescans start at the earliest block up to 2 hours before a key timestamp, so diff --git a/test/functional/feature_reindex.py b/test/functional/feature_reindex.py --- a/test/functional/feature_reindex.py +++ b/test/functional/feature_reindex.py @@ -6,9 +6,10 @@ # # Test -reindex and -reindex-chainstate with CheckBlockIndex # +import time + from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal -import time class ReindexTest(BitcoinTestFramework):