Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_compactblocks.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2016 The Bitcoin Core developers | # Copyright (c) 2016 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). | |||||
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 ( | ||||
BlockTransactions, | BlockTransactions, | ||||
BlockTransactionsRequest, | BlockTransactionsRequest, | ||||
calculate_shortid, | calculate_shortid, | ||||
Show All 27 Lines | from test_framework.mininode import ( | ||||
network_thread_start, | 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 | ||||
''' | |||||
CompactBlocksTest -- test compact blocks (BIP 152) | |||||
Only testing Version 1 compact blocks (txids) | |||||
''' | |||||
# TestNode: A peer we use to send messages to bitcoind, and store responses. | # TestNode: A peer we use to send messages to bitcoind, and store responses. | ||||
class TestNode(P2PInterface): | class TestNode(P2PInterface): | ||||
def __init__(self): | def __init__(self): | ||||
super().__init__() | super().__init__() | ||||
self.last_sendcmpct = [] | self.last_sendcmpct = [] | ||||
self.block_announced = False | self.block_announced = False | ||||
▲ Show 20 Lines • Show All 872 Lines • Show Last 20 Lines |