Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-segwit-recovery.py
Show All 18 Lines | from test_framework.messages import ( | ||||
COIN, | COIN, | ||||
COutPoint, | COutPoint, | ||||
CTransaction, | CTransaction, | ||||
CTxIn, | CTxIn, | ||||
CTxOut, | CTxOut, | ||||
ToHex, | ToHex, | ||||
) | ) | ||||
from test_framework.mininode import ( | from test_framework.mininode import ( | ||||
network_thread_join, | |||||
network_thread_start, | |||||
P2PDataStore, | P2PDataStore, | ||||
) | ) | ||||
from test_framework.script import ( | from test_framework.script import ( | ||||
CScript, | CScript, | ||||
hash160, | hash160, | ||||
OP_EQUAL, | OP_EQUAL, | ||||
OP_HASH160, | OP_HASH160, | ||||
OP_TRUE, | OP_TRUE, | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | class SegwitRecoveryTest(BitcoinTestFramework): | ||||
def bootstrap_p2p(self, *, num_connections=1): | def bootstrap_p2p(self, *, num_connections=1): | ||||
"""Add a P2P connection to the node. | """Add a P2P connection to the node. | ||||
Helper to connect and wait for version handshake.""" | Helper to connect and wait for version handshake.""" | ||||
for node in self.nodes: | for node in self.nodes: | ||||
for _ in range(num_connections): | for _ in range(num_connections): | ||||
node.add_p2p_connection(P2PDataStore()) | node.add_p2p_connection(P2PDataStore()) | ||||
network_thread_start() | |||||
for node in self.nodes: | for node in self.nodes: | ||||
node.p2p.wait_for_verack() | node.p2p.wait_for_verack() | ||||
def reconnect_p2p(self, **kwargs): | def reconnect_p2p(self, **kwargs): | ||||
"""Tear down and bootstrap the P2P connection to the node. | """Tear down and bootstrap the P2P connection to the node. | ||||
The node gets disconnected several times in this test. This helper | The node gets disconnected several times in this test. This helper | ||||
method reconnects the p2p and restarts the network thread.""" | method reconnects the p2p and restarts the network thread.""" | ||||
for node in self.nodes: | for node in self.nodes: | ||||
node.disconnect_p2ps() | node.disconnect_p2ps() | ||||
network_thread_join() | |||||
self.bootstrap_p2p(**kwargs) | self.bootstrap_p2p(**kwargs) | ||||
def run_test(self): | def run_test(self): | ||||
self.bootstrap_p2p() | self.bootstrap_p2p() | ||||
self.genesis_hash = int(self.nodes[0].getbestblockhash(), 16) | self.genesis_hash = int(self.nodes[0].getbestblockhash(), 16) | ||||
self.block_heights[self.genesis_hash] = 0 | self.block_heights[self.genesis_hash] = 0 | ||||
spendable_outputs = [] | spendable_outputs = [] | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |