Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_compactblocks.py
Show All 36 Lines | from test_framework.messages import ( | ||||
msg_tx, | msg_tx, | ||||
NODE_NETWORK, | NODE_NETWORK, | ||||
P2PHeaderAndShortIDs, | P2PHeaderAndShortIDs, | ||||
PrefilledTransaction, | PrefilledTransaction, | ||||
ToHex, | ToHex, | ||||
) | ) | ||||
from test_framework.mininode import ( | from test_framework.mininode import ( | ||||
mininode_lock, | mininode_lock, | ||||
network_thread_start, | |||||
P2PInterface, | P2PInterface, | ||||
) | ) | ||||
from test_framework.script import CScript, OP_TRUE | from test_framework.script import CScript, OP_TRUE | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.txtools import pad_tx | from test_framework.txtools import pad_tx | ||||
from test_framework.util import assert_equal, sync_blocks, wait_until | from test_framework.util import assert_equal, sync_blocks, wait_until | ||||
# TestP2PConn: A peer we use to send messages to bitcoind, and store responses. | # TestP2PConn: A peer we use to send messages to bitcoind, and store responses. | ||||
▲ Show 20 Lines • Show All 776 Lines • ▼ Show 20 Lines | def test_compactblock_reconstruction_multiple_peers(self, node, stalling_peer, delivery_peer): | ||||
msg = msg_blocktxn() | msg = msg_blocktxn() | ||||
msg.block_transactions.blockhash = block.sha256 | msg.block_transactions.blockhash = block.sha256 | ||||
msg.block_transactions.transactions = block.vtx[1:] | msg.block_transactions.transactions = block.vtx[1:] | ||||
stalling_peer.send_and_ping(msg) | stalling_peer.send_and_ping(msg) | ||||
assert_equal(int(node.getbestblockhash(), 16), block.sha256) | assert_equal(int(node.getbestblockhash(), 16), block.sha256) | ||||
def run_test(self): | def run_test(self): | ||||
# Setup the p2p connections and start up the network thread. | # Setup the p2p connections | ||||
self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn()) | self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn()) | ||||
self.ex_softfork_node = self.nodes[1].add_p2p_connection( | self.ex_softfork_node = self.nodes[1].add_p2p_connection( | ||||
TestP2PConn(), services=NODE_NETWORK) | TestP2PConn(), services=NODE_NETWORK) | ||||
self.old_node = self.nodes[1].add_p2p_connection( | self.old_node = self.nodes[1].add_p2p_connection( | ||||
TestP2PConn(), services=NODE_NETWORK) | TestP2PConn(), services=NODE_NETWORK) | ||||
network_thread_start() | |||||
self.test_node.wait_for_verack() | self.test_node.wait_for_verack() | ||||
# We will need UTXOs to construct transactions in later tests. | # We will need UTXOs to construct transactions in later tests. | ||||
self.make_utxos() | self.make_utxos() | ||||
self.log.info("Running tests:") | self.log.info("Running tests:") | ||||
self.log.info("\tTesting SENDCMPCT p2p message... ") | self.log.info("\tTesting SENDCMPCT p2p message... ") | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |