merge bitcoin#19967: Replace (dis)?connect_nodes globals with TestFramework methods

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
Kittywhiskers Van Gogh 2022-09-24 18:06:35 +05:30
parent c4ec55f807
commit e8bf39f2dc
57 changed files with 275 additions and 313 deletions

View File

@ -25,7 +25,6 @@ from test_framework.mininode import (
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
wait_until,
)
@ -116,7 +115,7 @@ class ExampleTest(BitcoinTestFramework):
# In this test, we're not connecting node2 to node0 or node1. Calls to
# sync_all() should not include node2, since we're not expecting it to
# sync.
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_all(self.nodes[0:2])
# Use setup_nodes() to customize the node start behaviour (for example if
@ -184,7 +183,7 @@ class ExampleTest(BitcoinTestFramework):
self.nodes[1].waitforblockheight(11)
self.log.info("Connect node2 and node1")
connect_nodes(self.nodes[1], 2)
self.connect_nodes(1, 2)
self.log.info("Wait for node2 to receive all the blocks from node1")
self.sync_all()

View File

@ -11,7 +11,7 @@
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import wait_until, get_datadir_path, connect_nodes
from test_framework.util import wait_until, get_datadir_path
import os
class AbortNodeTest(BitcoinTestFramework):
@ -35,7 +35,7 @@ class AbortNodeTest(BitcoinTestFramework):
# attempt.
self.nodes[1].generate(3)
with self.nodes[0].assert_debug_log(["Failed to disconnect block"]):
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.nodes[1].generate(1)
# Check that node0 aborted

View File

@ -13,7 +13,7 @@ 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.script import CScript, OP_CHECKSIG, OP_DUP, OP_EQUAL, OP_EQUALVERIFY, OP_HASH160
from test_framework.util import assert_equal, connect_nodes
from test_framework.util import assert_equal
class AddressIndexTest(BitcoinTestFramework):
@ -33,9 +33,9 @@ class AddressIndexTest(BitcoinTestFramework):
# Nodes 2/3 are used for testing
self.start_node(2, ["-addressindex"])
self.start_node(3, ["-addressindex"])
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.connect_nodes(0, 1)
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
self.sync_all()
self.import_deterministic_coinbase_privkeys()
@ -44,12 +44,12 @@ class AddressIndexTest(BitcoinTestFramework):
self.stop_node(1)
self.nodes[1].assert_start_raises_init_error(["-addressindex=0"], "You need to rebuild the database using -reindex to change -addressindex", match=ErrorMatch.PARTIAL_REGEX)
self.start_node(1, ["-addressindex=0", "-reindex"])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_all()
self.stop_node(1)
self.nodes[1].assert_start_raises_init_error(["-addressindex"], "You need to rebuild the database using -reindex to change -addressindex", match=ErrorMatch.PARTIAL_REGEX)
self.start_node(1, ["-addressindex", "-reindex"])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_all()
self.log.info("Mining blocks...")

View File

@ -12,7 +12,7 @@ from decimal import Decimal
from test_framework.blocktools import create_block, create_coinbase, get_masternode_payment
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 assert_equal, connect_nodes, force_finish_mnsync, get_bip9_status, p2p_port
from test_framework.util import assert_equal, force_finish_mnsync, get_bip9_status, p2p_port
class Masternode(object):
pass
@ -43,7 +43,7 @@ class DIP3Test(BitcoinTestFramework):
self.start_node(0, extra_args=self.extra_args)
for node in self.nodes[1:]:
if node is not None and node.process is not None:
connect_nodes(node, 0)
self.connect_nodes(node.index, 0)
def run_test(self):
self.log.info("funding controller node")
@ -269,7 +269,7 @@ class DIP3Test(BitcoinTestFramework):
self.start_node(mn.idx, extra_args = self.extra_args + ['-masternodeblsprivkey=%s' % mn.blsMnkey])
force_finish_mnsync(self.nodes[mn.idx])
mn.node = self.nodes[mn.idx]
connect_nodes(mn.node, 0)
self.connect_nodes(mn.idx, 0)
self.sync_all()
def spend_mn_collateral(self, mn, with_dummy_input_output=False):

View File

@ -13,7 +13,6 @@ from test_framework.util import (
assert_equal,
assert_greater_than,
assert_greater_than_or_equal,
connect_nodes,
satoshi_round,
)
@ -213,9 +212,9 @@ class EstimateFeeTest(BitcoinTestFramework):
# so the estimates would not be affected by the splitting transactions
self.start_node(1)
self.start_node(2)
connect_nodes(self.nodes[1], 0)
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[2], 1)
self.connect_nodes(1, 0)
self.connect_nodes(0, 2)
self.connect_nodes(2, 1)
self.sync_all()

View File

@ -13,7 +13,7 @@ Checks LLMQs based ChainLocks
import time
from test_framework.test_framework import DashTestFramework
from test_framework.util import connect_nodes, force_finish_mnsync, isolate_node, reconnect_isolated_node
from test_framework.util import force_finish_mnsync
class LLMQChainLocksTest(DashTestFramework):
@ -27,7 +27,7 @@ class LLMQChainLocksTest(DashTestFramework):
# Usually node0 is the one that does this, but in this test we isolate it multiple times
for i in range(len(self.nodes)):
if i != 1:
connect_nodes(self.nodes[i], 1)
self.connect_nodes(i, 1)
self.activate_dip8()
@ -53,24 +53,24 @@ class LLMQChainLocksTest(DashTestFramework):
assert block['chainlock']
self.log.info("Isolate node, mine on another, and reconnect")
isolate_node(self.nodes[0])
self.isolate_node(0)
node0_mining_addr = self.nodes[0].getnewaddress()
node0_tip = self.nodes[0].getbestblockhash()
self.nodes[1].generatetoaddress(5, node0_mining_addr)
self.wait_for_chainlocked_block(self.nodes[1], self.nodes[1].getbestblockhash())
assert self.nodes[0].getbestblockhash() == node0_tip
reconnect_isolated_node(self.nodes[0], 1)
self.reconnect_isolated_node(0, 1)
self.nodes[1].generatetoaddress(1, node0_mining_addr)
self.wait_for_chainlocked_block_all_nodes(self.nodes[1].getbestblockhash())
self.log.info("Isolate node, mine on both parts of the network, and reconnect")
isolate_node(self.nodes[0])
self.isolate_node(0)
bad_tip = self.nodes[0].generate(5)[-1]
self.nodes[1].generatetoaddress(1, node0_mining_addr)
good_tip = self.nodes[1].getbestblockhash()
self.wait_for_chainlocked_block(self.nodes[1], good_tip)
assert not self.nodes[0].getblock(self.nodes[0].getbestblockhash())["chainlock"]
reconnect_isolated_node(self.nodes[0], 1)
self.reconnect_isolated_node(0, 1)
self.nodes[1].generatetoaddress(1, node0_mining_addr)
self.wait_for_chainlocked_block_all_nodes(self.nodes[1].getbestblockhash())
assert self.nodes[0].getblock(self.nodes[0].getbestblockhash())["previousblockhash"] == good_tip
@ -90,7 +90,7 @@ class LLMQChainLocksTest(DashTestFramework):
self.log.info("Restart it so that it forgets all the chainlock messages from the past")
self.stop_node(0)
self.start_node(0)
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
assert self.nodes[0].getbestblockhash() == good_tip
self.nodes[0].invalidateblock(good_tip)
self.log.info("Now try to reorg the chain")
@ -129,7 +129,7 @@ class LLMQChainLocksTest(DashTestFramework):
self.log.info("Isolate a node and let it create some transactions which won't get IS locked")
force_finish_mnsync(self.nodes[0])
isolate_node(self.nodes[0])
self.isolate_node(0)
txs = []
for i in range(3):
txs.append(self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1))
@ -155,7 +155,7 @@ class LLMQChainLocksTest(DashTestFramework):
# Enable network on first node again, which will cause the blocks to propagate and IS locks to happen retroactively
# for the mined TXs, which will then allow the network to create a CLSIG
self.log.info("Re-enable network on first node and wait for chainlock")
reconnect_isolated_node(self.nodes[0], 1)
self.reconnect_isolated_node(0, 1)
self.wait_for_chainlocked_block(self.nodes[0], self.nodes[0].getbestblockhash(), timeout=30)
def create_chained_txs(self, node, amount):

View File

@ -13,7 +13,7 @@ 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, Options, wait_until
from test_framework.util import assert_greater_than_or_equal, Options, wait_until
# Probes should age after this many seconds.
# NOTE: mine_quorum() can bump mocktime quite often internally so make sure this number is high enough.
@ -119,7 +119,7 @@ class LLMQConnections(DashTestFramework):
# Also re-connect non-masternode connections
for i in range(1, len(self.nodes)):
connect_nodes(self.nodes[i], 0)
self.connect_nodes(i, 0)
self.nodes[i].ping()
# wait for ping/pong so that we can be sure that spork propagation works
time.sleep(1) # needed to make sure we don't check before the ping is actually sent (fPingQueued might be true but SendMessages still not called)

View File

@ -6,7 +6,7 @@
import time
from test_framework.mininode import logger
from test_framework.test_framework import DashTestFramework
from test_framework.util import force_finish_mnsync, connect_nodes, wait_until
from test_framework.util import force_finish_mnsync, wait_until
'''
feature_llmq_data_recovery.py
@ -29,19 +29,19 @@ class QuorumDataRecoveryTest(DashTestFramework):
self.set_dash_llmq_test_params(4, 3)
def restart_mn(self, mn, reindex=False, qvvec_sync=[], qdata_recovery_enabled=True):
args = self.extra_args[mn.nodeIdx] + ['-masternodeblsprivkey=%s' % mn.keyOperator,
args = self.extra_args[mn.node.index] + ['-masternodeblsprivkey=%s' % mn.keyOperator,
'-llmq-data-recovery=%d' % qdata_recovery_enabled]
for llmq_sync in qvvec_sync:
args.append('-llmq-qvvec-sync=%s:%d' % (llmq_type_strings[llmq_sync[0]], llmq_sync[1]))
if reindex:
args.append('-reindex')
bb_hash = mn.node.getbestblockhash()
self.restart_node(mn.nodeIdx, args)
self.restart_node(mn.node.index, args)
wait_until(lambda: mn.node.getbestblockhash() == bb_hash)
else:
self.restart_node(mn.nodeIdx, args)
self.restart_node(mn.node.index, args)
force_finish_mnsync(mn.node)
connect_nodes(mn.node, 0)
self.connect_nodes(mn.node.index, 0)
if qdata_recovery_enabled:
# trigger recovery threads and wait for them to start
self.nodes[0].generate(1)

View File

@ -6,7 +6,7 @@ import time
from test_framework.messages import CTransaction, FromHex, hash256, ser_compact_size, ser_string
from test_framework.test_framework import DashTestFramework
from test_framework.util import wait_until, connect_nodes
from test_framework.util import wait_until
'''
feature_llmq_is_migration.py
@ -33,7 +33,7 @@ class LLMQISMigrationTest(DashTestFramework):
for i in range(len(self.nodes)):
if i != 1:
connect_nodes(self.nodes[i], 0)
self.connect_nodes(i, 0)
self.activate_dip8()

View File

@ -16,7 +16,7 @@ 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
from test_framework.util import set_node_times
class LLMQ_IS_RetroactiveSigning(DashTestFramework):
@ -69,13 +69,13 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework):
self.wait_for_chainlocked_block_all_nodes(block)
self.log.info("testing normal signing with partially known TX")
isolate_node(self.nodes[3])
self.isolate_node(3)
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
# Make sure nodes 1 and 2 received the TX before we continue,
# otherwise it might announce the TX to node 3 when reconnecting
self.wait_for_tx(txid, self.nodes[1])
self.wait_for_tx(txid, self.nodes[2])
reconnect_isolated_node(self.nodes[3], 0)
self.reconnect_isolated_node(3, 0)
# Make sure nodes actually try re-connecting quorum connections
self.bump_mocktime(30)
self.wait_for_mnauth(self.nodes[3], 2)
@ -88,7 +88,7 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework):
self.wait_for_instantlock(txid, self.nodes[0])
self.log.info("testing retroactive signing with unknown TX")
isolate_node(self.nodes[3])
self.isolate_node(3)
rawtx = self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress(): 1})
rawtx = self.nodes[0].fundrawtransaction(rawtx)['hex']
rawtx = self.nodes[0].signrawtransactionwithwallet(rawtx)['hex']
@ -96,18 +96,18 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework):
# Make node 3 consider the TX as safe
self.bump_mocktime(10 * 60 + 1)
block = self.nodes[3].generatetoaddress(1, self.nodes[0].getnewaddress())[0]
reconnect_isolated_node(self.nodes[3], 0)
self.reconnect_isolated_node(3, 0)
self.wait_for_chainlocked_block_all_nodes(block)
self.nodes[0].setmocktime(self.mocktime)
self.log.info("testing retroactive signing with partially known TX")
isolate_node(self.nodes[3])
self.isolate_node(3)
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
# Make sure nodes 1 and 2 received the TX before we continue,
# otherwise it might announce the TX to node 3 when reconnecting
self.wait_for_tx(txid, self.nodes[1])
self.wait_for_tx(txid, self.nodes[2])
reconnect_isolated_node(self.nodes[3], 0)
self.reconnect_isolated_node(3, 0)
# Make sure nodes actually try re-connecting quorum connections
self.bump_mocktime(30)
self.wait_for_mnauth(self.nodes[3], 2)
@ -136,7 +136,7 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework):
def test_all_nodes_session_timeout(self, do_cycle_llmqs):
set_node_times(self.nodes, self.mocktime)
isolate_node(self.nodes[3])
self.isolate_node(3)
rawtx = self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress(): 1})
rawtx = self.nodes[0].fundrawtransaction(rawtx)['hex']
rawtx = self.nodes[0].signrawtransactionwithwallet(rawtx)['hex']
@ -150,7 +150,7 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework):
# Make the signing session for the IS lock timeout on nodes 1-3
self.bump_mocktime(61)
time.sleep(2) # make sure Cleanup() is called
reconnect_isolated_node(self.nodes[3], 0)
self.reconnect_isolated_node(3, 0)
# Make sure nodes actually try re-connecting quorum connections
self.bump_mocktime(30)
self.wait_for_mnauth(self.nodes[3], 2)
@ -167,7 +167,7 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework):
def test_single_node_session_timeout(self, do_cycle_llmqs):
set_node_times(self.nodes, self.mocktime)
isolate_node(self.nodes[3])
self.isolate_node(3)
rawtx = self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress(): 1})
rawtx = self.nodes[0].fundrawtransaction(rawtx)['hex']
rawtx = self.nodes[0].signrawtransactionwithwallet(rawtx)['hex']
@ -176,7 +176,7 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework):
# Make the signing session for the IS lock timeout on node 3
self.bump_mocktime(61)
time.sleep(2) # make sure Cleanup() is called
reconnect_isolated_node(self.nodes[3], 0)
self.reconnect_isolated_node(3, 0)
# Make sure nodes actually try re-connecting quorum connections
self.bump_mocktime(30)
self.wait_for_mnauth(self.nodes[3], 2)

View File

@ -17,7 +17,6 @@ from test_framework.mininode import P2PInterface
from test_framework.util import (
assert_equal,
assert_greater_than_or_equal,
connect_nodes,
wait_until,
)
@ -67,7 +66,7 @@ class LLMQQuorumRotationTest(DashTestFramework):
for i in range(len(self.nodes)):
if i != 1:
connect_nodes(self.nodes[i], 0)
self.connect_nodes(i, 0)
self.activate_dip8()

View File

@ -13,7 +13,7 @@ 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
from test_framework.util import assert_equal, assert_raises_rpc_error, force_finish_mnsync, hex_str_to_bytes, wait_until
class LLMQSigningTest(DashTestFramework):
@ -184,7 +184,7 @@ class LLMQSigningTest(DashTestFramework):
assert_sigs_nochange(False, False, False, 3)
# Need to re-connect so that it later gets the recovered sig
mn.node.setnetworkactive(True)
connect_nodes(mn.node, 0)
self.connect_nodes(mn.node.index, 0)
force_finish_mnsync(mn.node)
# Make sure intra-quorum connections were also restored
self.bump_mocktime(1) # need this to bypass quorum connection retry timeout

View File

@ -13,7 +13,7 @@ Checks simple PoSe system based on LLMQ commitments
import time
from test_framework.test_framework import DashTestFramework
from test_framework.util import assert_equal, connect_nodes, force_finish_mnsync, p2p_port, wait_until
from test_framework.util import assert_equal, force_finish_mnsync, p2p_port, wait_until
class LLMQSimplePoSeTest(DashTestFramework):
@ -71,18 +71,18 @@ class LLMQSimplePoSeTest(DashTestFramework):
def close_mn_port(self, mn):
self.stop_node(mn.node.index)
self.start_masternode(mn, ["-listen=0", "-nobind"])
connect_nodes(mn.node, 0)
self.connect_nodes(mn.node.index, 0)
# Make sure the to-be-banned node is still connected well via outbound connections
for mn2 in self.mninfo:
if mn2 is not mn:
connect_nodes(mn.node, mn2.node.index)
self.connect_nodes(mn.node.index, mn2.node.index)
self.reset_probe_timeouts()
return False, False
def force_old_mn_proto(self, mn):
self.stop_node(mn.node.index)
self.start_masternode(mn, ["-pushversion=70216"])
connect_nodes(mn.node, 0)
self.connect_nodes(mn.node.index, 0)
self.reset_probe_timeouts()
return False, True
@ -199,7 +199,7 @@ class LLMQSimplePoSeTest(DashTestFramework):
self.start_masternode(mn)
else:
mn.node.setnetworkactive(True)
connect_nodes(mn.node, 0)
self.connect_nodes(mn.node.index, 0)
self.sync_all()
# Isolate and re-connect all MNs (otherwise there might be open connections with no MNAUTH for MNs which were banned before)
@ -208,7 +208,7 @@ class LLMQSimplePoSeTest(DashTestFramework):
wait_until(lambda: mn.node.getconnectioncount() == 0)
mn.node.setnetworkactive(True)
force_finish_mnsync(mn.node)
connect_nodes(mn.node, 0)
self.connect_nodes(mn.node.index, 0)
def reset_probe_timeouts(self):
# Make sure all masternodes will reconnect/re-probe

View File

@ -18,7 +18,7 @@ only succeeds past a given node once its nMinimumChainWork has been exceeded.
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
# 2 hashes required per regtest block (with no difficulty adjustment)
REGTEST_WORK_PER_BLOCK = 2
@ -41,7 +41,7 @@ class MinimumChainWorkTest(BitcoinTestFramework):
# block relay to inbound peers.
self.setup_nodes()
for i in range(self.num_nodes-1):
connect_nodes(self.nodes[i+1], i)
self.connect_nodes(i+1, i)
def run_test(self):
# Start building a chain on node0. node2 shouldn't be able to sync until node1's

View File

@ -5,7 +5,7 @@
import time
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import connect_nodes, wait_until
from test_framework.util import wait_until
'''
feature_multikeysporks.py
@ -66,7 +66,7 @@ class MultiKeySporkTest(BitcoinTestFramework):
# connect nodes at start
for i in range(0, 5):
for j in range(i, 5):
connect_nodes(self.nodes[i], j)
self.connect_nodes(i, j)
def get_test_spork_value(self, node, spork_name):
self.bump_mocktime(5) # advance ProcessTick
@ -95,7 +95,7 @@ class MultiKeySporkTest(BitcoinTestFramework):
# restart again with corect_params, should resync spork parts from other nodes
self.restart_node(0, self.node0_extra_args)
for i in range(1, 5):
connect_nodes(self.nodes[0], i)
self.connect_nodes(0, i)
# third signer set spork value
self.nodes[2].sporkupdate(spork_name, 1)
@ -110,7 +110,7 @@ class MultiKeySporkTest(BitcoinTestFramework):
# restart again with corect_params, should resync sporks from other nodes
self.restart_node(0, self.node0_extra_args)
for i in range(1, 5):
connect_nodes(self.nodes[0], i)
self.connect_nodes(0, i)
wait_until(lambda: self.get_test_spork_value(self.nodes[0], spork_name) == 1, sleep=0.1, timeout=10)

View File

@ -10,7 +10,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
wait_until,
connect_nodes,
)
# Linux allow all characters other than \x00
@ -75,7 +74,7 @@ class NotificationsTest(BitcoinTestFramework):
self.log.info("test -walletnotify after rescan")
# restart node to rescan to force wallet notifications
self.start_node(1)
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10)

View File

@ -14,7 +14,7 @@ from test_framework.blocktools import create_coinbase
from test_framework.messages import CBlock, ToHex
from test_framework.script import CScript, OP_RETURN, OP_NOP
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, connect_nodes, disconnect_nodes, wait_until
from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, wait_until
# Rescans start at the earliest block up to 2 hours before a key timestamp, so
# the manual prune RPC avoids pruning blocks in the same window to be
@ -96,11 +96,11 @@ class PruneTest(BitcoinTestFramework):
self.prunedir = os.path.join(self.nodes[2].datadir, self.chain, 'blocks', '')
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 2)
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
connect_nodes(self.nodes[0], 4)
self.connect_nodes(0, 1)
self.connect_nodes(1, 2)
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
self.connect_nodes(0, 4)
self.sync_blocks(self.nodes[0:5])
def setup_nodes(self):
@ -142,8 +142,8 @@ class PruneTest(BitcoinTestFramework):
for j in range(12):
# Disconnect node 0 so it can mine a longer reorg chain without knowing about node 1's soon-to-be-stale chain
# Node 2 stays connected, so it hears about the stale blocks and then reorg's when node0 reconnects
disconnect_nodes(self.nodes[0], 1)
disconnect_nodes(self.nodes[0], 2)
self.disconnect_nodes(0, 1)
self.disconnect_nodes(0, 2)
# Mine 24 blocks in node 1
mine_large_blocks(self.nodes[1], 24)
@ -151,8 +151,8 @@ class PruneTest(BitcoinTestFramework):
mine_large_blocks(self.nodes[0], 25)
# Create connections in the order so both nodes can see the reorg at the same time
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[0], 2)
self.connect_nodes(0, 1)
self.connect_nodes(0, 2)
self.sync_blocks(self.nodes[0:3])
self.log.info("Usage can be over target because of high stale rate: %d" % calc_usage(self.prunedir))
@ -183,15 +183,15 @@ class PruneTest(BitcoinTestFramework):
# Mine one block to avoid automatic recovery from forks on restart
self.nodes[1].generate(1)
# Disconnect node1 and generate the new chain
disconnect_nodes(self.nodes[0], 1)
disconnect_nodes(self.nodes[1], 2)
self.disconnect_nodes(0, 1)
self.disconnect_nodes(1, 2)
self.log.info("Generating new longer chain of 300 more blocks")
self.nodes[1].generate(299)
self.log.info("Reconnect nodes")
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 2)
self.connect_nodes(0, 1)
self.connect_nodes(1, 2)
self.sync_blocks(self.nodes[0:3], timeout=120)
self.log.info("Verify height on node 2: %d" % self.nodes[2].getblockcount())
@ -342,7 +342,7 @@ class PruneTest(BitcoinTestFramework):
# check that wallet loads successfully when restarting a pruned node after IBD.
# this was reported to fail in #7494.
self.log.info("Syncing node 5 to test wallet")
connect_nodes(self.nodes[0], 5)
self.connect_nodes(0, 5)
nds = [self.nodes[0], self.nodes[5]]
self.sync_blocks(nds, wait=5, timeout=300)
self.stop_node(5, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') # stop and start to trigger rescan

View File

@ -14,7 +14,7 @@ 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
from test_framework.util import assert_equal
class SpentIndexTest(BitcoinTestFramework):
@ -34,9 +34,9 @@ class SpentIndexTest(BitcoinTestFramework):
# Nodes 2/3 are used for testing
self.start_node(2, ["-spentindex"])
self.start_node(3, ["-spentindex", "-txindex"])
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.connect_nodes(0, 1)
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
self.sync_all()
self.import_deterministic_coinbase_privkeys()
@ -45,12 +45,12 @@ class SpentIndexTest(BitcoinTestFramework):
self.stop_node(1)
self.nodes[1].assert_start_raises_init_error(["-spentindex=0"], "You need to rebuild the database using -reindex to change -spentindex", match=ErrorMatch.PARTIAL_REGEX)
self.start_node(1, ["-spentindex=0", "-reindex"])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_all()
self.stop_node(1)
self.nodes[1].assert_start_raises_init_error(["-spentindex"], "You need to rebuild the database using -reindex to change -spentindex", match=ErrorMatch.PARTIAL_REGEX)
self.start_node(1, ["-spentindex", "-reindex"])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_all()
self.log.info("Mining blocks...")

View File

@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import connect_nodes, wait_until
from test_framework.util import wait_until
'''
'''
@ -19,7 +19,7 @@ class SporkTest(BitcoinTestFramework):
self.disable_mocktime()
self.setup_nodes()
# connect only 2 first nodes at start
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
def get_test_spork_state(self, node):
info = node.spork('active')
@ -57,7 +57,7 @@ class SporkTest(BitcoinTestFramework):
self.nodes[1].generate(1)
# connect new node and check spork propagation after restoring from cache
connect_nodes(self.nodes[1], 2)
self.connect_nodes(1, 2)
wait_until(lambda: self.get_test_spork_state(self.nodes[2]), sleep=0.1, timeout=10)
if __name__ == '__main__':

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 assert_equal, connect_nodes
from test_framework.util import assert_equal
class TimestampIndexTest(BitcoinTestFramework):
@ -26,9 +26,9 @@ class TimestampIndexTest(BitcoinTestFramework):
# Nodes 2/3 are used for testing
self.start_node(2)
self.start_node(3, ["-timestampindex"])
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.connect_nodes(0, 1)
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
self.sync_all()
@ -37,12 +37,12 @@ class TimestampIndexTest(BitcoinTestFramework):
self.stop_node(1)
self.nodes[1].assert_start_raises_init_error(["-timestampindex=0"], "You need to rebuild the database using -reindex to change -timestampindex", match=ErrorMatch.PARTIAL_REGEX)
self.start_node(1, ["-timestampindex=0", "-reindex"])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_all()
self.stop_node(1)
self.nodes[1].assert_start_raises_init_error(["-timestampindex"], "You need to rebuild the database using -reindex to change -timestampindex", match=ErrorMatch.PARTIAL_REGEX)
self.start_node(1, ["-timestampindex", "-reindex"])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_all()
self.log.info("Mining 5 blocks...")

View File

@ -12,7 +12,7 @@ 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
from test_framework.util import assert_equal
class TxIndexTest(BitcoinTestFramework):
@ -32,9 +32,9 @@ class TxIndexTest(BitcoinTestFramework):
# Nodes 2/3 are used for testing
self.start_node(2, ["-txindex"])
self.start_node(3, ["-txindex"])
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.connect_nodes(0, 1)
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
self.sync_all()
self.import_deterministic_coinbase_privkeys()

View File

@ -42,7 +42,7 @@ from test_framework.test_framework import BitcoinTestFramework
# from test_framework.mininode import P2PTxInvStore
from test_framework.util import (
assert_equal,
assert_greater_than_or_equal, assert_raises_rpc_error, connect_nodes, disconnect_nodes,
assert_greater_than_or_equal, assert_raises_rpc_error,
)
@ -79,9 +79,9 @@ class MempoolPersistTest(BitcoinTestFramework):
assert_greater_than_or_equal(tx_creation_time_higher, tx_creation_time)
# disconnect nodes & make a txn that remains in the unbroadcast set.
disconnect_nodes(self.nodes[0], 2)
self.disconnect_nodes(0, 2)
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), Decimal("12"))
connect_nodes(self.nodes[0], 2)
self.connect_nodes(0, 2)
self.log.debug("Stop-start the nodes. Verify that node0 has the transactions in its mempool and node1 does not. Verify that node2 calculates its balance correctly after loading wallet transactions.")
self.stop_nodes()
@ -153,7 +153,7 @@ class MempoolPersistTest(BitcoinTestFramework):
node0.generate(1)
# disconnect nodes to make a txn that remains in the unbroadcast set.
disconnect_nodes(node0, 1)
self.disconnect_nodes(0, 1)
node0.sendtoaddress(self.nodes[1].getnewaddress(), Decimal("12"))
# shutdown, then startup with wallet disabled

View File

@ -11,9 +11,7 @@ from test_framework.mininode import P2PTxInvStore
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
create_confirmed_utxos,
disconnect_nodes,
)
@ -35,7 +33,7 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
min_relay_fee = node.getnetworkinfo()["relayfee"]
utxos = create_confirmed_utxos(min_relay_fee, node, 10)
disconnect_nodes(node, 1)
self.disconnect_nodes(0, 1)
self.log.info("Generate transactions that only node 0 knows about")
@ -62,7 +60,7 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
self.restart_node(0)
self.log.info("Reconnect nodes & check if they are sent to node 1")
connect_nodes(node, 1)
self.connect_nodes(0, 1)
# fast forward into the future & ensure that the second node has the txns
node.mockscheduler(15 * 60) # 15 min in seconds
@ -81,8 +79,8 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
def test_txn_removal(self):
self.log.info("Test that transactions removed from mempool are removed from unbroadcast set")
node = self.nodes[0]
disconnect_nodes(node, 1)
node.disconnect_p2ps
self.disconnect_nodes(0, 1)
node.disconnect_p2ps()
# since the node doesn't have any connections, it will not receive
# any GETDATAs & thus the transaction will remain in the unbroadcast set.

View File

@ -25,7 +25,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
connect_nodes,
)
from test_framework.script import CScriptNum
@ -53,8 +52,8 @@ class MiningTest(BitcoinTestFramework):
assert_equal(mining_info['currentblocktx'], 0)
assert_equal(mining_info['currentblocksize'], 1000)
self.restart_node(0)
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 0)
self.connect_nodes(0, 1)
self.connect_nodes(1, 0)
def run_test(self):
self.mine_chain()

View File

@ -22,8 +22,6 @@ from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
disconnect_nodes,
wait_until,
)
@ -62,7 +60,7 @@ class CompactFiltersTest(BitcoinTestFramework):
self.sync_blocks(timeout=600)
# Stale blocks by disconnecting nodes 0 & 1, mining, then reconnecting
disconnect_nodes(self.nodes[0], 1)
self.disconnect_nodes(0, 1)
self.nodes[0].generate(1)
wait_until(lambda: self.nodes[0].getblockcount() == 1000)
@ -91,7 +89,7 @@ class CompactFiltersTest(BitcoinTestFramework):
assert_equal(len(response.headers), 1)
self.log.info("Reorg node 0 to a new chain.")
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_blocks(timeout=600)
main_block_hash = self.nodes[0].getblockhash(1000)

View File

@ -6,7 +6,7 @@
from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, connect_nodes
from test_framework.util import assert_equal
class ConnectDevnetNodes(BitcoinTestFramework):
def set_test_params(self):
@ -18,7 +18,7 @@ class ConnectDevnetNodes(BitcoinTestFramework):
self.add_nodes(self.num_nodes)
self.start_node(0)
self.start_node(1)
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_all()

View File

@ -8,7 +8,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
connect_nodes,
wait_until,
)
@ -19,8 +18,8 @@ class DisconnectBanTest(BitcoinTestFramework):
def run_test(self):
self.log.info("Connect nodes both way")
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 0)
self.connect_nodes(0, 1)
self.connect_nodes(1, 0)
self.log.info("Test setban and listbanned RPCs")
@ -75,8 +74,8 @@ class DisconnectBanTest(BitcoinTestFramework):
# Clear ban lists
self.nodes[1].clearbanned()
self.log.info("Connect nodes both way")
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 0)
self.connect_nodes(0, 1)
self.connect_nodes(1, 0)
self.log.info("Test disconnectnode RPCs")
@ -95,7 +94,7 @@ class DisconnectBanTest(BitcoinTestFramework):
assert not [node for node in self.nodes[0].getpeerinfo() if node['addr'] == address1]
self.log.info("disconnectnode: successfully reconnect node")
connect_nodes(self.nodes[0], 1) # reconnect the node
self.connect_nodes(0, 1) # reconnect the node
assert_equal(len(self.nodes[0].getpeerinfo()), 2)
assert [node for node in self.nodes[0].getpeerinfo() if node['addr'] == address1]

View File

@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.test_framework import DashTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, isolate_node, reconnect_isolated_node
from test_framework.util import assert_equal, assert_raises_rpc_error
'''
p2p_instantsend.py
@ -43,7 +43,7 @@ class InstantSendTest(DashTestFramework):
# create doublespending transaction, but don't relay it
dblspnd_tx = self.create_raw_tx(sender, isolated, 0.5, 1, 100)
# isolate one node from network
isolate_node(isolated)
self.isolate_node(self.isolated_idx)
# instantsend to receiver
receiver_addr = receiver.getnewaddress()
is_id = sender.sendtoaddress(receiver_addr, 0.9)
@ -60,7 +60,7 @@ class InstantSendTest(DashTestFramework):
isolated.generate(1)
wrong_block = isolated.getbestblockhash()
# connect isolated block to network
reconnect_isolated_node(isolated, 0)
self.reconnect_isolated_node(self.isolated_idx, 0)
# check doublespend block is rejected by other nodes
timeout = 10
for idx, node in enumerate(self.nodes):
@ -98,13 +98,13 @@ class InstantSendTest(DashTestFramework):
# create doublespending transaction, but don't relay it
dblspnd_tx = self.create_raw_tx(sender, isolated, 0.5, 1, 100)
# isolate one node from network
isolate_node(isolated)
self.isolate_node(self.isolated_idx)
# send doublespend transaction to isolated node
dblspnd_txid = isolated.sendrawtransaction(dblspnd_tx['hex'])
assert dblspnd_txid in set(isolated.getrawmempool())
# let isolated node rejoin the network
# The previously isolated node should NOT relay the doublespending TX
reconnect_isolated_node(isolated, 0)
self.reconnect_isolated_node(self.isolated_idx, 0)
for node in connected_nodes:
assert_raises_rpc_error(-5, "No such mempool or blockchain transaction", node.getrawtransaction, dblspnd_txid)
# Instantsend to receiver. The previously isolated node won't accept the tx but it should

View File

@ -11,7 +11,7 @@ and that it responds to getdata requests for blocks correctly:
from test_framework.messages import CInv, MSG_BLOCK, msg_getdata, NODE_BLOOM, NODE_NETWORK_LIMITED, NODE_HEADERS_COMPRESSED, msg_verack
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, wait_until
from test_framework.util import assert_equal, wait_until
class P2PIgnoreInv(P2PInterface):
firstAddrnServices = 0
@ -35,9 +35,9 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
self.extra_args = [['-prune=550', '-txindex=0', '-addrmantest'], [], []]
def disconnect_all(self):
disconnect_nodes(self.nodes[0], 1)
disconnect_nodes(self.nodes[0], 2)
disconnect_nodes(self.nodes[1], 2)
self.disconnect_nodes(0, 1)
self.disconnect_nodes(0, 2)
self.disconnect_nodes(1, 2)
def setup_network(self):
self.add_nodes(self.num_nodes, self.extra_args)
@ -55,7 +55,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
assert_equal(int(self.nodes[0].getnetworkinfo()['localservices'], 16), expected_services)
self.log.info("Mine enough blocks to reach the NODE_NETWORK_LIMITED range.")
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
blocks = self.nodes[1].generatetoaddress(292, self.nodes[1].get_deterministic_priv_key().address)
self.sync_blocks([self.nodes[0], self.nodes[1]])
@ -81,7 +81,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
# connect unsynced node 2 with pruned NODE_NETWORK_LIMITED peer
# because node 2 is in IBD and node 0 is a NODE_NETWORK_LIMITED peer, sync must not be possible
connect_nodes(self.nodes[0], 2)
self.connect_nodes(0, 2)
try:
self.sync_blocks([self.nodes[0], self.nodes[2]], timeout=5)
except:
@ -90,7 +90,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
assert_equal(self.nodes[2].getblockheader(self.nodes[2].getbestblockhash())['height'], 0)
# now connect also to node 1 (non pruned)
connect_nodes(self.nodes[1], 2)
self.connect_nodes(1, 2)
# sync must be possible
self.sync_blocks()
@ -102,7 +102,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
self.nodes[0].generatetoaddress(10, self.nodes[0].get_deterministic_priv_key().address)
# connect node1 (non pruned) with node0 (pruned) and check if the can sync
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
# sync must be possible, node 1 is no longer in IBD and should therefore connect to node 0 (NODE_NETWORK_LIMITED)
self.sync_blocks([self.nodes[0], self.nodes[1]])

View File

@ -11,7 +11,6 @@ from test_framework.test_node import ErrorMatch
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
p2p_port,
)
@ -91,7 +90,7 @@ class P2PPermissionsTests(BitcoinTestFramework):
def checkpermission(self, args, expectedPermissions, whitelisted):
self.restart_node(1, args)
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
peerinfo = self.nodes[1].getpeerinfo()[0]
assert_equal(peerinfo['whitelisted'], whitelisted)
assert_equal(len(expectedPermissions), len(peerinfo['permissions']))

View File

@ -14,7 +14,6 @@ from test_framework.test_framework import DashTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
connect_nodes,
force_finish_mnsync,
wait_until,
)
@ -127,12 +126,12 @@ class QuorumDataMessagesTest(DashTestFramework):
self.set_dash_test_params(4, 3, fast_dip3_enforcement=True, extra_args=extra_args)
def restart_mn(self, mn, reindex=False):
args = self.extra_args[mn.nodeIdx] + ['-masternodeblsprivkey=%s' % mn.keyOperator]
args = self.extra_args[mn.node.index] + ['-masternodeblsprivkey=%s' % mn.keyOperator]
if reindex:
args.append('-reindex')
self.restart_node(mn.nodeIdx, args)
self.restart_node(mn.node.index, args)
force_finish_mnsync(mn.node)
connect_nodes(mn.node, 0)
self.connect_nodes(mn.node.index, 0)
self.sync_blocks()
def run_test(self):
@ -371,7 +370,7 @@ class QuorumDataMessagesTest(DashTestFramework):
for extra_args in [[], ["-watchquorums"]]:
self.restart_node(0, self.extra_args[0] + extra_args)
for i in range(self.num_nodes - 1):
connect_nodes(node0, i + 1)
self.connect_nodes(0, i + 1)
p2p_node0 = p2p_connection(node0)
p2p_mn2 = p2p_connection(mn2.node)
id_p2p_node0 = get_mininode_id(node0)

View File

@ -56,7 +56,7 @@ from test_framework.blocktools import create_block, create_coinbase, create_tx_w
from test_framework.messages import CBlockHeader, CInv, MSG_BLOCK, 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
from test_framework.util import assert_equal, assert_raises_rpc_error
class AcceptBlockTest(BitcoinTestFramework):
@ -300,7 +300,7 @@ class AcceptBlockTest(BitcoinTestFramework):
test_node.wait_for_disconnect()
# 9. Connect node1 to node0 and ensure it is able to sync
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_blocks([self.nodes[0], self.nodes[1]])
self.log.info("Successfully synced nodes 1 and 0")

View File

@ -12,7 +12,6 @@ from test_framework.util import (
assert_greater_than,
assert_greater_than_or_equal,
assert_raises_rpc_error,
connect_nodes,
count_bytes,
find_vout_for_address,
)
@ -39,10 +38,10 @@ class RawTransactionsTest(BitcoinTestFramework):
def setup_network(self):
self.setup_nodes()
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 2)
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.connect_nodes(0, 1)
self.connect_nodes(1, 2)
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
def run_test(self):
self.log.info("Connect nodes, set fees, generate blocks, and sync")

View File

@ -7,7 +7,7 @@ from decimal import Decimal
from test_framework.authproxy import JSONRPCException
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_greater_than, connect_nodes
from test_framework.util import assert_equal, assert_greater_than
# Create one-input, one-output, no-fee transaction:
class RawTransactionsTest(BitcoinTestFramework):
@ -22,10 +22,10 @@ class RawTransactionsTest(BitcoinTestFramework):
def setup_network(self):
super().setup_network()
connect_nodes(self.nodes[0],1)
connect_nodes(self.nodes[1],2)
connect_nodes(self.nodes[0],2)
connect_nodes(self.nodes[0],3)
self.connect_nodes(0,1)
self.connect_nodes(1,2)
self.connect_nodes(0,2)
self.connect_nodes(0,3)
def run_test(self):
self.log.info("Mining blocks...")
@ -451,10 +451,10 @@ class RawTransactionsTest(BitcoinTestFramework):
for node in self.nodes:
node.settxfee(min_relay_tx_fee)
connect_nodes(self.nodes[0],1)
connect_nodes(self.nodes[1],2)
connect_nodes(self.nodes[0],2)
connect_nodes(self.nodes[0],3)
self.connect_nodes(0,1)
self.connect_nodes(1,2)
self.connect_nodes(0,2)
self.connect_nodes(0,3)
self.sync_all()
# drain the keypool

View File

@ -7,7 +7,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal, assert_is_hex_string, assert_raises_rpc_error,
connect_nodes, disconnect_nodes
)
FILTER_TYPES = ["basic"]
@ -20,7 +19,7 @@ class GetBlockFilterTest(BitcoinTestFramework):
def run_test(self):
# Create two chains by disconnecting nodes 0 & 1, mining, then reconnecting
disconnect_nodes(self.nodes[0], 1)
self.disconnect_nodes(0, 1)
self.nodes[0].generate(3)
self.nodes[1].generate(4)
@ -29,7 +28,7 @@ class GetBlockFilterTest(BitcoinTestFramework):
chain0_hashes = [self.nodes[0].getblockhash(block_height) for block_height in range(4)]
# Reorg node 0 to a new chain
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_blocks()
assert_equal(self.nodes[0].getblockcount(), 4)

View File

@ -8,7 +8,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR
from test_framework.util import (
assert_equal,
connect_nodes,
wait_until,
)
@ -33,7 +32,7 @@ class InvalidateTest(BitcoinTestFramework):
assert_equal(self.nodes[1].getblockcount(), 6)
self.log.info("Connect nodes to force a reorg")
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_blocks(self.nodes[0:2])
assert_equal(self.nodes[0].getblockcount(), 6)
badhash = self.nodes[1].getblockhash(2)
@ -44,7 +43,7 @@ class InvalidateTest(BitcoinTestFramework):
assert_equal(self.nodes[0].getbestblockhash(), besthash_n0)
self.log.info("Make sure we won't reorg to a lower work chain:")
connect_nodes(self.nodes[ 1], 2)
self.connect_nodes( 1, 2)
self.log.info("Sync node 2 to node 1 so both have 6 blocks")
self.sync_blocks(self.nodes[1:3])
assert_equal(self.nodes[2].getblockcount(), 6)
@ -64,7 +63,7 @@ class InvalidateTest(BitcoinTestFramework):
self.log.info("Make sure ResetBlockFailureFlags does the job correctly")
self.restart_node(0, extra_args=["-checkblocks=5"])
self.restart_node(1, extra_args=["-checkblocks=5"])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.nodes[0].generate(10)
self.sync_blocks(self.nodes[0:2])
newheight = self.nodes[0].getblockcount()
@ -72,7 +71,7 @@ class InvalidateTest(BitcoinTestFramework):
self.restart_node(0, extra_args=["-checkblocks=5"])
tip = self.nodes[0].generate(10)[-1]
self.nodes[1].generate(9)
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_blocks(self.nodes[0:2])
assert_equal(self.nodes[0].getblockcount(), newheight + 10 * (j + 1))
assert_equal(self.nodes[1].getblockcount(), newheight + 10 * (j + 1))

View File

@ -13,7 +13,6 @@ from test_framework.util import (
assert_greater_than_or_equal,
assert_greater_than,
assert_raises_rpc_error,
connect_nodes,
p2p_port,
wait_until,
)
@ -58,8 +57,8 @@ class NetTest(DashTestFramework):
self.nodes[0].ping()
wait_until(lambda: all(['pingtime' in n for n in self.nodes[0].getpeerinfo()]))
self.log.info('Connect nodes both way')
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 0)
self.connect_nodes(0, 1)
self.connect_nodes(1, 0)
self._test_connection_count()
self._test_getnettotals()
@ -117,8 +116,8 @@ class NetTest(DashTestFramework):
self.nodes[0].setnetworkactive(state=True)
self.log.info('Connect nodes both way')
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 0)
self.connect_nodes(0, 1)
self.connect_nodes(1, 0)
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True)
assert_equal(self.nodes[0].getnetworkinfo()['connections'], 2)
@ -129,7 +128,7 @@ class NetTest(DashTestFramework):
assert_net_servicesnames(int(info["localservices"], 16), info["localservicesnames"])
self.log.info('Test extended connections info')
connect_nodes(self.nodes[1], 2)
self.connect_nodes(1, 2)
self.nodes[1].ping()
wait_until(lambda: all(['pingtime' in n for n in self.nodes[1].getpeerinfo()]))
assert_equal(self.nodes[1].getnetworkinfo()['connections'], 3)

View File

@ -7,7 +7,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
)
def unidirectional_node_sync_via_rpc(node_src, node_dest):
@ -61,7 +60,7 @@ class PreciousTest(BitcoinTestFramework):
self.log.info("Connect nodes and check no reorg occurs")
# Submit competing blocks via RPC so any reorg should occur before we proceed (no way to wait on inaction for p2p sync)
node_sync_via_rpc(self.nodes[0:2])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
assert_equal(self.nodes[0].getbestblockhash(), hashC)
assert_equal(self.nodes[1].getbestblockhash(), hashG)
self.log.info("Make Node0 prefer block G")
@ -98,8 +97,8 @@ class PreciousTest(BitcoinTestFramework):
hashL = self.nodes[2].getbestblockhash()
self.log.info("Connect nodes and check no reorg occurs")
node_sync_via_rpc(self.nodes[1:3])
connect_nodes(self.nodes[1], 2)
connect_nodes(self.nodes[0], 2)
self.connect_nodes(1, 2)
self.connect_nodes(0, 2)
assert_equal(self.nodes[0].getbestblockhash(), hashH)
assert_equal(self.nodes[1].getbestblockhash(), hashH)
assert_equal(self.nodes[2].getbestblockhash(), hashL)

View File

@ -5,11 +5,17 @@
"""Test the Partially Signed Transaction RPCs.
"""
import os
import json
from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, find_output
from test_framework.util import (
assert_equal,
assert_greater_than,
assert_raises_rpc_error,
find_output
)
import json
import os
# Create one-input, one-output, no-fee transaction:
class PSBTTest(BitcoinTestFramework):

View File

@ -25,7 +25,7 @@ class RPCMasternodeTest(DashTestFramework):
mn = self.mninfo[idx]
for member in quorum_info["members"]:
if member["proTxHash"] == mn.proTxHash:
assert_equal(member["service"], '127.0.0.1:%d' % p2p_port(mn.nodeIdx))
assert_equal(member["service"], '127.0.0.1:%d' % p2p_port(mn.node.index))
if __name__ == '__main__':
RPCMasternodeTest().main()

View File

@ -20,7 +20,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
connect_nodes,
hex_str_to_bytes,
)
@ -60,7 +59,7 @@ class RawTransactionsTest(BitcoinTestFramework):
def setup_network(self):
super().setup_network()
connect_nodes(self.nodes[0], 2)
self.connect_nodes(0, 2)
def run_test(self):
self.log.info('prepare some coins for multiple *rawtransaction commands')

View File

@ -6,7 +6,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
connect_nodes,
p2p_port
)
@ -18,7 +17,7 @@ class SetBanTests(BitcoinTestFramework):
def run_test(self):
# Node 0 connects to Node 1, check that the noban permission is not granted
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
peerinfo = self.nodes[1].getpeerinfo()[0]
assert not 'noban' in peerinfo['permissions']
@ -32,14 +31,14 @@ class SetBanTests(BitcoinTestFramework):
# However, node 0 should be able to reconnect if it has noban permission
self.restart_node(1, ['-whitelist=127.0.0.1'])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
peerinfo = self.nodes[1].getpeerinfo()[0]
assert 'noban' in peerinfo['permissions']
# If we remove the ban, Node 0 should be able to reconnect even without noban permission
self.nodes[1].setban("127.0.0.1", "remove")
self.restart_node(1, [])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
peerinfo = self.nodes[1].getpeerinfo()[0]
assert not 'noban' in peerinfo['permissions']

View File

@ -8,7 +8,7 @@ from decimal import Decimal
from test_framework.messages import CMerkleBlock, FromHex, ToHex
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes
from test_framework.util import assert_equal, assert_raises_rpc_error
class MerkleBlockTest(BitcoinTestFramework):
def set_test_params(self):
@ -22,9 +22,9 @@ class MerkleBlockTest(BitcoinTestFramework):
def setup_network(self):
self.setup_nodes()
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.connect_nodes(0, 1)
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
self.sync_all()

View File

@ -38,9 +38,7 @@ from .util import (
MAX_NODES,
assert_equal,
check_json_precision,
connect_nodes,
copy_datadir,
disconnect_nodes,
force_finish_mnsync,
get_datadir_path,
hex_str_to_bytes,
@ -517,10 +515,57 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
self.nodes[i].process.wait(timeout)
def connect_nodes(self, a, b):
connect_nodes(self.nodes[a], b)
def connect_nodes_helper(from_connection, node_num):
ip_port = "127.0.0.1:" + str(p2p_port(node_num))
from_connection.addnode(ip_port, "onetry")
# poll until version handshake complete to avoid race conditions
# with transaction relaying
# See comments in net_processing:
# * Must have a version message before anything else
# * Must have a verack message before anything else
wait_until(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
wait_until(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
connect_nodes_helper(self.nodes[a], b)
def disconnect_nodes(self, a, b):
disconnect_nodes(self.nodes[a], b)
def disconnect_nodes_helper(from_connection, node_num):
def get_peer_ids():
result = []
for peer in from_connection.getpeerinfo():
if "testnode{}".format(node_num) in peer['subver']:
result.append(peer['id'])
return result
peer_ids = get_peer_ids()
if not peer_ids:
self.log.warning("disconnect_nodes: {} and {} were not connected".format(
from_connection.index,
node_num,
))
return
for peer_id in peer_ids:
try:
from_connection.disconnectnode(nodeid=peer_id)
except JSONRPCException as e:
# If this node is disconnected between calculating the peer id
# and issuing the disconnect, don't worry about it.
# This avoids a race condition if we're mass-disconnecting peers.
if e.error['code'] != -29: # RPC_CLIENT_NODE_NOT_CONNECTED
raise
# wait to disconnect
wait_until(lambda: not get_peer_ids(), timeout=5)
disconnect_nodes_helper(self.nodes[a], b)
def isolate_node(self, node_num, timeout=5):
self.nodes[node_num].setnetworkactive(False)
wait_until(lambda: self.nodes[node_num].getconnectioncount() == 0, timeout=timeout)
def reconnect_isolated_node(self, a, b):
self.nodes[a].setnetworkactive(True)
self.connect_nodes(a, b)
def split_network(self):
"""
@ -888,7 +933,7 @@ class DashTestFramework(BitcoinTestFramework):
self.start_node(idx)
self.nodes[idx].createwallet(self.default_wallet_name)
for i in range(0, idx):
connect_nodes(self.nodes[i], idx)
self.connect_nodes(i, idx)
def prepare_masternodes(self):
self.log.info("Preparing %d masternodes" % self.mn_count)
@ -988,7 +1033,7 @@ class DashTestFramework(BitcoinTestFramework):
def do_connect(idx):
# Connect to the control node only, masternodes should take care of intra-quorum connections themselves
connect_nodes(self.mninfo[idx].node, 0)
self.connect_nodes(self.mninfo[idx].nodeIdx, 0)
jobs = []
@ -1050,7 +1095,7 @@ class DashTestFramework(BitcoinTestFramework):
# non-masternodes where disconnected from the control node during prepare_datadirs,
# let's reconnect them back to make sure they receive updates
for i in range(0, num_simple_nodes):
connect_nodes(self.nodes[i+1], 0)
self.connect_nodes(i+1, 0)
self.bump_mocktime(1)
self.nodes[0].generate(1)

View File

@ -443,59 +443,6 @@ def set_node_times(nodes, t):
node.mocktime = t
node.setmocktime(t)
def disconnect_nodes(from_connection, node_num):
def get_peer_ids():
result = []
for peer in from_connection.getpeerinfo():
if "testnode{}".format(node_num) in peer['subver']:
result.append(peer['id'])
return result
peer_ids = get_peer_ids()
if not peer_ids:
logger.warning("disconnect_nodes: {} and {} were not connected".format(
from_connection.index,
node_num
))
return
for peer_id in peer_ids:
try:
from_connection.disconnectnode(nodeid=peer_id)
except JSONRPCException as e:
# If this node is disconnected between calculating the peer id
# and issuing the disconnect, don't worry about it.
# This avoids a race condition if we're mass-disconnecting peers.
if e.error['code'] != -29: # RPC_CLIENT_NODE_NOT_CONNECTED
raise
# wait to disconnect
wait_until(lambda: not get_peer_ids(), timeout=5)
def connect_nodes(from_connection, node_num):
ip_port = "127.0.0.1:" + str(p2p_port(node_num))
from_connection.addnode(ip_port, "onetry")
# poll until version handshake complete to avoid race conditions
# with transaction relaying
# See comments in net_processing:
# * Must have a version message before anything else
# * Must have a verack message before anything else
wait_until(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
wait_until(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
def isolate_node(node, timeout=5):
node.setnetworkactive(False)
timeout *= Options.timeout_scale
stop_time = time.time() + timeout
while time.time() < stop_time:
if node.getconnectioncount() == 0:
return
time.sleep(0.5)
raise AssertionError("disconnect_node timed out")
def reconnect_isolated_node(node, node_num):
node.setnetworkactive(True)
connect_nodes(node, node_num)
def force_finish_mnsync(node):
"""
Masternodes won't accept incoming connections while IsSynced is false.

View File

@ -16,8 +16,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
connect_nodes,
disconnect_nodes,
)
@ -50,7 +48,7 @@ class AbandonConflictTest(BitcoinTestFramework):
balance = newbalance
# Disconnect nodes so node0's transactions don't get into node1's mempool
disconnect_nodes(self.nodes[0], 1)
self.disconnect_nodes(0, 1)
# Identify the 10btc outputs
nA = next(tx_out["vout"] for tx_out in self.nodes[0].gettransaction(txA)["details"] if tx_out["amount"] == Decimal("10"))
@ -173,7 +171,7 @@ class AbandonConflictTest(BitcoinTestFramework):
self.nodes[1].sendrawtransaction(signed["hex"])
self.nodes[1].generate(1)
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_blocks()
tx_list = self.nodes[0].listtransactions()

View File

@ -8,7 +8,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
connect_nodes,
)
# TODO: Copied from wallet_groups.py -- should perhaps move into util.py
@ -102,7 +101,7 @@ class AvoidReuseTest(BitcoinTestFramework):
# Stop and restart node 1
self.stop_node(1)
self.start_node(1)
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
# Flags should still be node1.avoid_reuse=false, node2.avoid_reuse=true
assert_equal(self.nodes[0].getwalletinfo()["avoid_reuse"], False)

View File

@ -36,7 +36,7 @@ from random import randint
import shutil
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes
from test_framework.util import assert_equal, assert_raises_rpc_error
class WalletBackupTest(BitcoinTestFramework):
def set_test_params(self):
@ -57,10 +57,10 @@ class WalletBackupTest(BitcoinTestFramework):
def setup_network(self):
self.setup_nodes()
connect_nodes(self.nodes[0], 3)
connect_nodes(self.nodes[1], 3)
connect_nodes(self.nodes[2], 3)
connect_nodes(self.nodes[2], 0)
self.connect_nodes(0, 3)
self.connect_nodes(1, 3)
self.connect_nodes(2, 3)
self.connect_nodes(2, 0)
self.sync_all()
def one_send(self, from_node, to_address):
@ -91,10 +91,10 @@ class WalletBackupTest(BitcoinTestFramework):
self.start_node(0)
self.start_node(1)
self.start_node(2)
connect_nodes(self.nodes[0], 3)
connect_nodes(self.nodes[1], 3)
connect_nodes(self.nodes[2], 3)
connect_nodes(self.nodes[2], 0)
self.connect_nodes(0, 3)
self.connect_nodes(1, 3)
self.connect_nodes(2, 3)
self.connect_nodes(2, 0)
def stop_three(self):
self.stop_node(0)

View File

@ -11,7 +11,6 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
connect_nodes,
)
@ -200,8 +199,8 @@ class WalletTest(BitcoinTestFramework):
# Now confirm tx_orig
self.restart_node(1, ['-persistmempool=0', '-checklevel=0'])
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 0)
self.connect_nodes(0, 1)
self.connect_nodes(1, 0)
self.sync_blocks()
self.nodes[1].sendrawtransaction(tx_orig)
self.nodes[1].generatetoaddress(1, ADDRESS_WATCHONLY)

View File

@ -11,7 +11,6 @@ from test_framework.util import (
assert_equal,
assert_fee_amount,
assert_raises_rpc_error,
connect_nodes,
count_bytes,
wait_until,
)
@ -34,9 +33,9 @@ class WalletTest(BitcoinTestFramework):
self.setup_nodes()
# Only need nodes 0-2 running at start of test
self.stop_node(3)
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 2)
connect_nodes(self.nodes[0], 2)
self.connect_nodes(0, 1)
self.connect_nodes(1, 2)
self.connect_nodes(0, 2)
self.sync_all(self.nodes[0:3])
def check_fee_amount(self, curr_balance, balance_with_fee, fee_per_byte, tx_size):
@ -216,7 +215,7 @@ class WalletTest(BitcoinTestFramework):
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('100'), fee_per_byte, count_bytes(self.nodes[2].gettransaction(txid)['hex']))
self.start_node(3)
connect_nodes(self.nodes[0], 3)
self.connect_nodes(0, 3)
self.sync_all()
# check if we can list zero value tx as available coins
@ -251,9 +250,9 @@ class WalletTest(BitcoinTestFramework):
self.start_node(0, ["-walletbroadcast=0"])
self.start_node(1, ["-walletbroadcast=0"])
self.start_node(2, ["-walletbroadcast=0"])
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 2)
connect_nodes(self.nodes[0], 2)
self.connect_nodes(0, 1)
self.connect_nodes(1, 2)
self.connect_nodes(0, 2)
self.sync_all(self.nodes[0:3])
txid_not_broadcast = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
@ -278,9 +277,9 @@ class WalletTest(BitcoinTestFramework):
self.start_node(0)
self.start_node(1)
self.start_node(2)
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[1], 2)
connect_nodes(self.nodes[0], 2)
self.connect_nodes(0, 1)
self.connect_nodes(1, 2)
self.connect_nodes(0, 2)
self.sync_blocks(self.nodes[0:3])
self.nodes[0].generate(1)

View File

@ -10,7 +10,6 @@ import os
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
)
class WalletHDTest(BitcoinTestFramework):
@ -32,7 +31,7 @@ class WalletHDTest(BitcoinTestFramework):
self.stop_node(1)
self.nodes[1].assert_start_raises_init_error(['-usehd=0'], "Error: Error loading : You can't disable HD on an already existing HD wallet")
self.start_node(1)
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
# Make sure we use hd, keep chainid
chainid = self.nodes[1].getwalletinfo()['hdchainid']
@ -96,7 +95,7 @@ class WalletHDTest(BitcoinTestFramework):
assert_equal(hd_info_2["hdkeypath"], "m/44'/1'/0'/0/"+str(i))
assert_equal(hd_info_2["hdchainid"], chainid)
assert_equal(hd_add, hd_add_2)
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_all()
# Needs rescan
@ -115,7 +114,7 @@ class WalletHDTest(BitcoinTestFramework):
os.path.join(self.nodes[1].datadir, self.chain, "wallets", self.default_wallet_name, self.wallet_data_filename),
)
self.start_node(1, extra_args=self.extra_args[1])
connect_nodes(self.nodes[0], 1)
self.connect_nodes(0, 1)
self.sync_all()
# Wallet automatically scans blocks older than key on startup
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1)

View File

@ -21,7 +21,6 @@ happened previously.
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
connect_nodes,
assert_equal,
set_node_times,
)
@ -141,7 +140,7 @@ class ImportRescanTest(BitcoinTestFramework):
self.start_nodes()
for i in range(1, self.num_nodes):
connect_nodes(self.nodes[i], 0)
self.connect_nodes(i, 0)
def run_test(self):
# Create one transaction on node 0 with a unique amount for

View File

@ -16,7 +16,6 @@ import shutil
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
)
@ -38,9 +37,9 @@ class KeypoolRestoreTest(BitcoinTestFramework):
self.stop_node(1)
shutil.copyfile(wallet_path, wallet_backup_path)
self.start_node(1, self.extra_args[1])
connect_nodes(self.nodes[0], 1)
connect_nodes(self.nodes[0], 2)
connect_nodes(self.nodes[0], 3)
self.connect_nodes(0, 1)
self.connect_nodes(0, 2)
self.connect_nodes(0, 3)
for i, output_type in enumerate(["legacy"]):
@ -67,7 +66,7 @@ class KeypoolRestoreTest(BitcoinTestFramework):
self.stop_node(idx)
shutil.copyfile(wallet_backup_path, wallet_path)
self.start_node(idx, self.extra_args[idx])
connect_nodes(self.nodes[0], idx)
self.connect_nodes(0, idx)
self.sync_all()
self.log.info("Verify keypool is restored and balance is correct")

View File

@ -10,9 +10,6 @@ from test_framework.util import (
assert_array_result,
assert_equal,
assert_raises_rpc_error,
connect_nodes,
isolate_node,
reconnect_isolated_node,
)
from decimal import Decimal
@ -28,7 +25,7 @@ class ListSinceBlockTest(BitcoinTestFramework):
def run_test(self):
# All nodes are in IBD from genesis, so they'll need the miner (node2) to be an outbound connection, or have
# only one connection. (See fPreferredDownload in net_processing)
connect_nodes(self.nodes[1], 2)
self.connect_nodes(1, 2)
self.nodes[2].generate(101)
self.sync_all()
@ -312,7 +309,7 @@ class ListSinceBlockTest(BitcoinTestFramework):
[tx_input], {dest_address: tx_input["amount"] - Decimal("0.00052000"),
spending_node.getrawchangeaddress(): Decimal("0.00050000")})
isolate_node(double_spending_node)
self.isolate_node(3)
signedtx = spending_node.signrawtransactionwithwallet(rawtx)
orig_tx_id = spending_node.sendrawtransaction(signedtx["hex"])
@ -323,7 +320,7 @@ class ListSinceBlockTest(BitcoinTestFramework):
double_tx = double_spending_node.getrawtransaction(dbl_tx_id, 1)
lastblockhash = double_spending_node.generate(1)[0]
reconnect_isolated_node(double_spending_node, 2)
self.reconnect_isolated_node(3, 2)
self.sync_all()
spending_node.invalidateblock(lastblockhash)

View File

@ -20,8 +20,6 @@ import shutil
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
disconnect_nodes,
)
class ReorgsRestoreTest(BitcoinTestFramework):
@ -38,9 +36,9 @@ class ReorgsRestoreTest(BitcoinTestFramework):
self.sync_blocks()
# Disconnect node1 from others to reorg its chain later
disconnect_nodes(self.nodes[0], 1)
disconnect_nodes(self.nodes[1], 2)
connect_nodes(self.nodes[0], 2)
self.disconnect_nodes(0, 1)
self.disconnect_nodes(1, 2)
self.connect_nodes(0, 2)
# Send a tx to be unconfirmed later
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), Decimal("10"))
@ -50,7 +48,7 @@ class ReorgsRestoreTest(BitcoinTestFramework):
assert_equal(tx_before_reorg["confirmations"], 4)
# Disconnect node0 from node2 to broadcast a conflict on their respective chains
disconnect_nodes(self.nodes[0], 2)
self.disconnect_nodes(0, 2)
nA = next(tx_out["vout"] for tx_out in self.nodes[0].gettransaction(txid_conflict_from)["details"] if tx_out["amount"] == Decimal("10"))
inputs = []
inputs.append({"txid": txid_conflict_from, "vout": nA})
@ -69,7 +67,7 @@ class ReorgsRestoreTest(BitcoinTestFramework):
self.nodes[2].generate(9)
# Reconnect node0 and node2 and check that conflicted_txid is effectively conflicted
connect_nodes(self.nodes[0], 2)
self.connect_nodes(0, 2)
self.sync_blocks([self.nodes[0], self.nodes[2]])
conflicted = self.nodes[0].gettransaction(conflicted_txid)
conflicting = self.nodes[0].gettransaction(conflicting_txid)

View File

@ -8,8 +8,6 @@ import io
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
disconnect_nodes,
)
from test_framework.messages import CTransaction, COIN
@ -28,7 +26,7 @@ class TxnMallTest(BitcoinTestFramework):
def setup_network(self):
# Start with split network:
super(TxnMallTest, self).setup_network()
disconnect_nodes(self.nodes[1], 2)
self.disconnect_nodes(1, 2)
def run_test(self):
# All nodes should start with 12,500 DASH:
@ -107,7 +105,7 @@ class TxnMallTest(BitcoinTestFramework):
self.nodes[2].generate(1)
# Reconnect the split network, and sync chain:
connect_nodes(self.nodes[1], 2)
self.connect_nodes(1, 2)
self.nodes[2].sendrawtransaction(node0_tx2["hex"])
self.nodes[2].sendrawtransaction(tx2["hex"])
self.nodes[2].generate(1) # Mine another block to make sure we sync

View File

@ -8,8 +8,6 @@ from decimal import Decimal
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
disconnect_nodes,
find_output,
)
@ -28,7 +26,7 @@ class TxnMallTest(BitcoinTestFramework):
def setup_network(self):
# Start with split network:
super().setup_network()
disconnect_nodes(self.nodes[1], 2)
self.disconnect_nodes(1, 2)
def run_test(self):
# All nodes should start with 12,500 DASH:
@ -116,7 +114,7 @@ class TxnMallTest(BitcoinTestFramework):
self.nodes[2].generate(1)
# Reconnect the split network, and sync chain:
connect_nodes(self.nodes[1], 2)
self.connect_nodes(1, 2)
self.nodes[2].generate(1) # Mine another block to make sure we sync
self.sync_blocks()
assert_equal(self.nodes[0].gettransaction(doublespend_txid)["confirmations"], 2)