Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_compactblocks.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2016-2019 The Bitcoin Core developers | # Copyright (c) 2016-2019 The Bitcoin Core developers | ||||
# Copyright (c) 2017 The Bitcoin developers | # Copyright (c) 2017 The Bitcoin developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test compact blocks (BIP 152). | """Test compact blocks (BIP 152). | ||||
Only testing Version 1 compact blocks (txids) | Only testing Version 1 compact blocks (txids) | ||||
""" | """ | ||||
import random | import random | ||||
from test_framework.blocktools import create_block, create_coinbase | from test_framework.blocktools import create_block, create_coinbase | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
MSG_BLOCK, | |||||
MSG_CMPCT_BLOCK, | |||||
NODE_NETWORK, | |||||
BlockTransactions, | BlockTransactions, | ||||
BlockTransactionsRequest, | BlockTransactionsRequest, | ||||
calculate_shortid, | |||||
CBlock, | CBlock, | ||||
CBlockHeader, | CBlockHeader, | ||||
CInv, | CInv, | ||||
COutPoint, | COutPoint, | ||||
CTransaction, | CTransaction, | ||||
CTxIn, | CTxIn, | ||||
CTxOut, | CTxOut, | ||||
FromHex, | FromHex, | ||||
HeaderAndShortIDs, | HeaderAndShortIDs, | ||||
MSG_BLOCK, | P2PHeaderAndShortIDs, | ||||
MSG_CMPCT_BLOCK, | PrefilledTransaction, | ||||
ToHex, | |||||
calculate_shortid, | |||||
msg_block, | msg_block, | ||||
msg_blocktxn, | msg_blocktxn, | ||||
msg_cmpctblock, | msg_cmpctblock, | ||||
msg_getblocktxn, | msg_getblocktxn, | ||||
msg_getdata, | msg_getdata, | ||||
msg_getheaders, | msg_getheaders, | ||||
msg_headers, | msg_headers, | ||||
msg_inv, | msg_inv, | ||||
msg_sendcmpct, | msg_sendcmpct, | ||||
msg_sendheaders, | msg_sendheaders, | ||||
msg_tx, | msg_tx, | ||||
NODE_NETWORK, | |||||
P2PHeaderAndShortIDs, | |||||
PrefilledTransaction, | |||||
ToHex, | |||||
) | ) | ||||
from test_framework.p2p import ( | from test_framework.p2p import P2PInterface, p2p_lock | ||||
p2p_lock, | from test_framework.script import OP_TRUE, CScript | ||||
P2PInterface, | |||||
) | |||||
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 ( | from test_framework.util import assert_equal, wait_until | ||||
assert_equal, | |||||
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. | ||||
class TestP2PConn(P2PInterface): | class TestP2PConn(P2PInterface): | ||||
def __init__(self): | def __init__(self): | ||||
super().__init__() | super().__init__() | ||||
self.last_sendcmpct = [] | self.last_sendcmpct = [] | ||||
▲ Show 20 Lines • Show All 865 Lines • Show Last 20 Lines |