diff --git a/test/functional/abc-cmdline.py b/test/functional/abc-cmdline.py --- a/test/functional/abc-cmdline.py +++ b/test/functional/abc-cmdline.py @@ -10,9 +10,10 @@ """ import re + +from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal -from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE MAX_GENERATED_BLOCK_SIZE_ERROR = ( 'Max generated block size (blockmaxsize) cannot exceed the excessive block size (excessiveblocksize)') diff --git a/test/functional/abc-finalize-block.py b/test/functional/abc-finalize-block.py --- a/test/functional/abc-finalize-block.py +++ b/test/functional/abc-finalize-block.py @@ -3,10 +3,16 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test the finalizeblock RPC calls.""" + import time from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, wait_until, set_node_times +from test_framework.util import ( + assert_equal, + assert_raises_rpc_error, + set_node_times, + wait_until, +) RPC_FINALIZE_INVALID_BLOCK_ERROR = 'finalize-invalid-block' RPC_FORK_PRIOR_FINALIZED_ERROR = 'bad-fork-prior-finalized' diff --git a/test/functional/abc-high_priority_transaction.py b/test/functional/abc-high_priority_transaction.py --- a/test/functional/abc-high_priority_transaction.py +++ b/test/functional/abc-high_priority_transaction.py @@ -7,10 +7,10 @@ # Test HighPriorityTransaction code # -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import * -from test_framework.mininode import COIN from test_framework.blocktools import create_confirmed_utxos +from test_framework.messages import COIN +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_equal, gen_return_txouts, satoshi_round class HighPriorityTransactionTest(BitcoinTestFramework): diff --git a/test/functional/abc-invalid-message.py b/test/functional/abc-invalid-message.py --- a/test/functional/abc-invalid-message.py +++ b/test/functional/abc-invalid-message.py @@ -9,15 +9,16 @@ """ import struct + +from test_framework.messages import NODE_NETWORK, msg_version from test_framework.mininode import ( - P2PInterface, - msg_ping, - mininode_lock, MAGIC_BYTES, + mininode_lock, + msg_ping, network_thread_start, + P2PInterface, ) from test_framework.test_framework import BitcoinTestFramework -from test_framework.messages import NODE_NETWORK, msg_version from test_framework.util import wait_until diff --git a/test/functional/abc-magnetic-anomaly-mining.py b/test/functional/abc-magnetic-anomaly-mining.py --- a/test/functional/abc-magnetic-anomaly-mining.py +++ b/test/functional/abc-magnetic-anomaly-mining.py @@ -7,9 +7,9 @@ the Nov 2018 protocol upgrade which engages canonical transaction ordering """ -import time -import random import decimal +import random +import time from test_framework.test_framework import BitcoinTestFramework diff --git a/test/functional/abc-mempool-accept-txn.py b/test/functional/abc-mempool-accept-txn.py --- a/test/functional/abc-mempool-accept-txn.py +++ b/test/functional/abc-mempool-accept-txn.py @@ -8,14 +8,39 @@ It is derived from the much more complex p2p-fullblocktest. """ -from test_framework.test_framework import ComparisonTestFramework -from test_framework.util import (assert_raises_rpc_error, assert_equal) -from test_framework.comptool import TestManager, TestInstance -from test_framework.blocktools import * import time -from test_framework.key import CECKey -from test_framework.script import * + +from test_framework.blocktools import ( + create_block, + create_coinbase, + create_transaction, +) from test_framework.cdefs import MAX_STANDARD_TX_SIGOPS +from test_framework.comptool import TestInstance, TestManager +from test_framework.key import CECKey +from test_framework.messages import ( + COutPoint, + CTransaction, + CTxIn, + CTxOut, + ToHex, +) +from test_framework.mininode import network_thread_start +from test_framework.script import ( + CScript, + hash160, + OP_2DUP, + OP_CHECKSIG, + OP_CHECKSIGVERIFY, + OP_EQUAL, + OP_HASH160, + OP_TRUE, + SIGHASH_ALL, + SIGHASH_FORKID, + SignatureHashForkId, +) +from test_framework.test_framework import ComparisonTestFramework +from test_framework.util import assert_equal, assert_raises_rpc_error # Error for too many sigops in one TX TXNS_TOO_MANY_SIGOPS_ERROR = b'bad-txns-too-many-sigops' diff --git a/test/functional/abc-mempool-coherence-on-activations.py b/test/functional/abc-mempool-coherence-on-activations.py --- a/test/functional/abc-mempool-coherence-on-activations.py +++ b/test/functional/abc-mempool-coherence-on-activations.py @@ -19,12 +19,33 @@ confirmed on the shorter chain) are kept or reincluded in the mempool. """ +from test_framework.blocktools import ( + create_block, + create_coinbase, + create_transaction, + make_conform_to_ctor, +) +from test_framework.comptool import TestInstance, TestManager +from test_framework.key import CECKey +from test_framework.messages import ( + COIN, + COutPoint, + CTransaction, + CTxIn, + CTxOut, + ToHex, +) +from test_framework.mininode import network_thread_start +from test_framework.script import ( + CScript, + OP_CHECKSIG, + OP_TRUE, + SIGHASH_ALL, + SIGHASH_FORKID, + SignatureHashForkId, +) from test_framework.test_framework import ComparisonTestFramework from test_framework.util import assert_equal, assert_raises_rpc_error -from test_framework.comptool import TestManager, TestInstance -from test_framework.blocktools import * -from test_framework.key import CECKey -from test_framework.script import * # ---Code specific to the activation used for this test--- diff --git a/test/functional/abc-p2p-compactblocks.py b/test/functional/abc-p2p-compactblocks.py --- a/test/functional/abc-p2p-compactblocks.py +++ b/test/functional/abc-p2p-compactblocks.py @@ -11,14 +11,38 @@ (e.g. sigops limits). """ -from test_framework.test_framework import ComparisonTestFramework -from test_framework.util import * -from test_framework.comptool import TestManager, TestInstance -from test_framework.blocktools import * +from collections import deque +import random import time -from test_framework.script import * + +from test_framework.blocktools import ( + create_block, + create_coinbase, + create_transaction, + make_conform_to_ctor, +) +from test_framework.comptool import TestInstance, TestManager from test_framework.cdefs import ONE_MEGABYTE -from collections import deque +from test_framework.messages import ( + COutPoint, + CTransaction, + CTxIn, + CTxOut, + HeaderAndShortIDs, + msg_cmpctblock, + msg_sendcmpct, + ser_compact_size, +) +from test_framework.mininode import ( + mininode_lock, + network_thread_start, + network_thread_join, + P2PInterface, +) +from test_framework.script import CScript, OP_RETURN, OP_TRUE +from test_framework.test_framework import ComparisonTestFramework +from test_framework.txtools import pad_tx +from test_framework.util import assert_equal, wait_until class PreviousSpendableOutput(): diff --git a/test/functional/abc-p2p-fullblocktest.py b/test/functional/abc-p2p-fullblocktest.py --- a/test/functional/abc-p2p-fullblocktest.py +++ b/test/functional/abc-p2p-fullblocktest.py @@ -11,16 +11,48 @@ (e.g. sigops limits). """ -from test_framework.test_framework import ComparisonTestFramework -from test_framework.util import assert_equal -from test_framework.comptool import TestManager, TestInstance, RejectResult -from test_framework.blocktools import * +from collections import deque +import random import time + +from test_framework.blocktools import ( + create_block, + create_coinbase, + create_transaction, + make_conform_to_ctor, +) +from test_framework.cdefs import ( + MAX_BLOCK_SIGOPS_PER_MB, + MAX_TX_SIGOPS_COUNT, + ONE_MEGABYTE, +) +from test_framework.comptool import RejectResult, TestInstance, TestManager from test_framework.key import CECKey -from test_framework.script import * -from test_framework.cdefs import (ONE_MEGABYTE, MAX_BLOCK_SIGOPS_PER_MB, - MAX_TX_SIGOPS_COUNT) -from collections import deque +from test_framework.messages import ( + COutPoint, + CTransaction, + CTxIn, + CTxOut, + ser_compact_size, + ToHex, +) +from test_framework.mininode import network_thread_start +from test_framework.script import ( + CScript, + hash160, + OP_2DUP, + OP_CHECKSIG, + OP_CHECKSIGVERIFY, + OP_EQUAL, + OP_HASH160, + OP_RETURN, + OP_TRUE, + SIGHASH_ALL, + SIGHASH_FORKID, + SignatureHashForkId, +) +from test_framework.test_framework import ComparisonTestFramework +from test_framework.util import assert_equal REPLAY_PROTECTION_START_TIME = 2000000000 diff --git a/test/functional/abc-replay-protection.py b/test/functional/abc-replay-protection.py --- a/test/functional/abc-replay-protection.py +++ b/test/functional/abc-replay-protection.py @@ -9,13 +9,35 @@ It is derived from the much more complex p2p-fullblocktest. """ -from test_framework.test_framework import ComparisonTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error -from test_framework.comptool import TestManager, TestInstance, RejectResult -from test_framework.blocktools import * import time + +from test_framework.blocktools import ( + create_block, + create_coinbase, + create_transaction, + make_conform_to_ctor, +) +from test_framework.comptool import RejectResult, TestInstance, TestManager from test_framework.key import CECKey -from test_framework.script import * +from test_framework.messages import ( + COIN, + COutPoint, + CTransaction, + CTxIn, + CTxOut, + ToHex, +) +from test_framework.mininode import network_thread_start +from test_framework.script import ( + CScript, + OP_CHECKSIG, + OP_TRUE, + SIGHASH_ALL, + SIGHASH_FORKID, + SignatureHashForkId, +) +from test_framework.test_framework import ComparisonTestFramework +from test_framework.util import assert_equal, assert_raises_rpc_error # far into the future REPLAY_PROTECTION_START_TIME = 2000000000 diff --git a/test/functional/abc-rpc.py b/test/functional/abc-rpc.py --- a/test/functional/abc-rpc.py +++ b/test/functional/abc-rpc.py @@ -6,11 +6,14 @@ # Exercise the Bitcoin ABC RPC calls. import re + +from test_framework.cdefs import ( + DEFAULT_MAX_BLOCK_SIZE, + LEGACY_MAX_BLOCK_SIZE, + ONE_MEGABYTE, +) from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import (assert_equal, assert_raises_rpc_error) -from test_framework.cdefs import (ONE_MEGABYTE, - LEGACY_MAX_BLOCK_SIZE, - DEFAULT_MAX_BLOCK_SIZE) +from test_framework.util import assert_equal, assert_raises_rpc_error class ABC_RPC_Test (BitcoinTestFramework): diff --git a/test/functional/abc-schnorr-activation.py b/test/functional/abc-schnorr-activation.py --- a/test/functional/abc-schnorr-activation.py +++ b/test/functional/abc-schnorr-activation.py @@ -18,13 +18,41 @@ abc-segwit-recovery-activation.py. """ -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, sync_blocks -from test_framework.comptool import TestManager, TestInstance, RejectResult -from test_framework.blocktools import * +from test_framework.blocktools import ( + create_block, + create_coinbase, + create_transaction, + make_conform_to_ctor, +) +from test_framework.comptool import RejectResult, TestInstance, TestManager from test_framework.key import CECKey +from test_framework.messages import ( + COIN, + COutPoint, + CTransaction, + CTxIn, + CTxOut, + msg_tx, + ToHex, +) +from test_framework.mininode import ( + mininode_lock, + network_thread_start, + P2PInterface, +) from test_framework import schnorr -from test_framework.script import * +from test_framework.script import ( + CScript, + OP_1, + OP_CHECKMULTISIG, + OP_CHECKSIG, + OP_TRUE, + SIGHASH_ALL, + SIGHASH_FORKID, + SignatureHashForkId, +) +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_equal, assert_raises_rpc_error, sync_blocks # far into the future GREAT_WALL_START_TIME = 2000000000 diff --git a/test/functional/abc-segwit-recovery-activation.py b/test/functional/abc-segwit-recovery-activation.py --- a/test/functional/abc-segwit-recovery-activation.py +++ b/test/functional/abc-segwit-recovery-activation.py @@ -7,11 +7,39 @@ This test checks activation of the SCRIPT_ALLOW_SEGWIT_RECOVERY flag """ +from test_framework.blocktools import ( + create_block, + create_coinbase, + make_conform_to_ctor, +) +from test_framework.comptool import RejectResult, TestInstance, TestManager +from test_framework.messages import ( + COIN, + COutPoint, + CTransaction, + CTxIn, + CTxOut, + msg_tx, + ToHex, +) +from test_framework.mininode import ( + mininode_lock, + network_thread_start, + P2PInterface, +) +from test_framework.script import ( + CScript, + hash160, + OP_EQUAL, + OP_HASH160, + OP_TRUE, +) from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, sync_blocks -from test_framework.comptool import TestManager, TestInstance, RejectResult -from test_framework.blocktools import * -from test_framework.script import * +from test_framework.util import ( + assert_equal, + assert_raises_rpc_error, + sync_blocks, +) # far into the future GREAT_WALL_START_TIME = 2000000000 diff --git a/test/functional/abc-sync-chain.py b/test/functional/abc-sync-chain.py --- a/test/functional/abc-sync-chain.py +++ b/test/functional/abc-sync-chain.py @@ -12,13 +12,10 @@ import random from test_framework.blocktools import create_block, create_coinbase -from test_framework.mininode import (CBlockHeader, - network_thread_start, - P2PInterface, - msg_block, - msg_headers) +from test_framework.messages import CBlockHeader, msg_block, msg_headers +from test_framework.mininode import network_thread_start, P2PInterface from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import wait_until, p2p_port +from test_framework.util import p2p_port, wait_until NUM_IBD_BLOCKS = 50 diff --git a/test/functional/abc-transaction-ordering.py b/test/functional/abc-transaction-ordering.py --- a/test/functional/abc-transaction-ordering.py +++ b/test/functional/abc-transaction-ordering.py @@ -7,13 +7,30 @@ non topological order once the feature is activated. """ +from collections import deque +import random +import time + +from test_framework.blocktools import ( + create_block, + create_coinbase, + make_conform_to_ctor, +) +from test_framework.comptool import RejectResult, TestInstance, TestManager +from test_framework.messages import ( + COutPoint, + CTransaction, + CTxIn, + CTxOut, +) +from test_framework.mininode import network_thread_start +from test_framework.script import ( + CScript, + OP_RETURN, + OP_TRUE, +) from test_framework.test_framework import ComparisonTestFramework from test_framework.util import assert_equal -from test_framework.comptool import TestManager, TestInstance, RejectResult -from test_framework.blocktools import * -import time -from test_framework.script import * -from collections import deque # far into the future REPLAY_PROTECTION_START_TIME = 2000000000