Changeset View
Changeset View
Standalone View
Standalone View
test/functional/example_test.py
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | def setup_network(self): | ||||
them to self.nodes, connect them and then sync.""" | them to self.nodes, connect them and then sync.""" | ||||
self.setup_nodes() | self.setup_nodes() | ||||
# In this test, we're not connecting node2 to node0 or node1. Calls to | # In this test, we're not connecting node2 to node0 or node1. Calls to | ||||
# sync_all() should not include node2, since we're not expecting it to | # sync_all() should not include node2, since we're not expecting it to | ||||
# sync. | # sync. | ||||
connect_nodes(self.nodes[0], self.nodes[1]) | connect_nodes(self.nodes[0], self.nodes[1]) | ||||
self.sync_all([self.nodes[0:1]]) | self.sync_all([self.nodes[0:2]]) | ||||
# Use setup_nodes() to customize the node start behaviour (for example if | # Use setup_nodes() to customize the node start behaviour (for example if | ||||
# you don't want to start all nodes at the start of the test). | # you don't want to start all nodes at the start of the test). | ||||
# def setup_nodes(): | # def setup_nodes(): | ||||
# pass | # pass | ||||
def custom_method(self): | def custom_method(self): | ||||
"""Do some custom behaviour for this test | """Do some custom behaviour for this test | ||||
Define it in a method here because you're going to use it repeatedly. | Define it in a method here because you're going to use it repeatedly. | ||||
If you think it's useful in general, consider moving it to the base | If you think it's useful in general, consider moving it to the base | ||||
BitcoinTestFramework class so other tests can use it.""" | BitcoinTestFramework class so other tests can use it.""" | ||||
self.log.info("Running custom_method") | self.log.info("Running custom_method") | ||||
def run_test(self): | def run_test(self): | ||||
"""Main test logic""" | """Main test logic""" | ||||
# Create P2P connections will wait for a verack to make sure the | # Create P2P connections will wait for a verack to make sure the | ||||
# connection is fully up | # connection is fully up | ||||
self.nodes[0].add_p2p_connection(BaseNode()) | self.nodes[0].add_p2p_connection(BaseNode()) | ||||
# Generating a block on one of the nodes will get us out of IBD | # Generating a block on one of the nodes will get us out of IBD | ||||
blocks = [int(self.nodes[0].generate(nblocks=1)[0], 16)] | blocks = [int(self.nodes[0].generate(nblocks=1)[0], 16)] | ||||
self.sync_all([self.nodes[0:1]]) | self.sync_all([self.nodes[0:2]]) | ||||
# Notice above how we called an RPC by calling a method with the same | # Notice above how we called an RPC by calling a method with the same | ||||
# name on the node object. Notice also how we used a keyword argument | # name on the node object. Notice also how we used a keyword argument | ||||
# to specify a named RPC argument. Neither of those are defined on the | # to specify a named RPC argument. Neither of those are defined on the | ||||
# node object. Instead there's some __getattr__() magic going on under | # node object. Instead there's some __getattr__() magic going on under | ||||
# the covers to dispatch unrecognised attribute calls to the RPC | # the covers to dispatch unrecognised attribute calls to the RPC | ||||
# interface. | # interface. | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |