Changeset View
Changeset View
Standalone View
Standalone View
test/functional/example_test.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2017-2019 The Bitcoin Core developers | # Copyright (c) 2017-2019 The Bitcoin Core 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. | ||||
"""An example functional test | """An example functional test | ||||
The module-level docstring should include a high-level description of | The module-level docstring should include a high-level description of | ||||
what the test is doing. It's the first thing people see when they open | what the test is doing. It's the first thing people see when they open | ||||
the file and should give the reader information about *what* the test | the file and should give the reader information about *what* the test | ||||
is testing and *how* it's being tested | is testing and *how* it's being tested | ||||
""" | """ | ||||
# Imports should be in PEP8 ordering (std library first, then third party | # Imports should be in PEP8 ordering (std library first, then third party | ||||
# libraries then local imports). | # libraries then local imports). | ||||
from collections import defaultdict | from collections import defaultdict | ||||
# Avoid wildcard * imports if possible | # Avoid wildcard * imports if possible | ||||
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, CInv, msg_block, msg_getdata | ||||
CInv, | from test_framework.p2p import P2PInterface, p2p_lock | ||||
MSG_BLOCK, | |||||
msg_block, | |||||
msg_getdata | |||||
) | |||||
from test_framework.p2p import ( | |||||
P2PInterface, | |||||
p2p_lock, | |||||
) | |||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import assert_equal, connect_nodes, wait_until | ||||
assert_equal, | |||||
connect_nodes, | |||||
wait_until, | |||||
) | |||||
# P2PInterface is a class containing callbacks to be executed when a P2P | # P2PInterface is a class containing callbacks to be executed when a P2P | ||||
# message is received from the node-under-test. Subclass P2PInterface and | # message is received from the node-under-test. Subclass P2PInterface and | ||||
# override the on_*() methods if you need custom behaviour. | # override the on_*() methods if you need custom behaviour. | ||||
class BaseNode(P2PInterface): | class BaseNode(P2PInterface): | ||||
def __init__(self): | def __init__(self): | ||||
▲ Show 20 Lines • Show All 193 Lines • Show Last 20 Lines |