Changeset View
Changeset View
Standalone View
Standalone View
test/functional/example_test.py
Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | def custom_method(self): | ||||
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 to two of the nodes | # Create P2P connections will wait for a verack to make sure the connection is fully up | ||||
self.nodes[0].add_p2p_connection(BaseNode()) | self.nodes[0].add_p2p_connection(BaseNode()) | ||||
# wait_for_verack ensures that the P2P connection is fully up. | |||||
self.nodes[0].p2p.wait_for_verack() | |||||
# 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:1]]) | ||||
# 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 | ||||
Show All 38 Lines | def run_test(self): | ||||
self.log.info("Connect node2 and node1") | self.log.info("Connect node2 and node1") | ||||
connect_nodes(self.nodes[1], self.nodes[2]) | connect_nodes(self.nodes[1], self.nodes[2]) | ||||
self.log.info("Add P2P connection to node2") | self.log.info("Add P2P connection to node2") | ||||
self.nodes[0].disconnect_p2ps() | self.nodes[0].disconnect_p2ps() | ||||
self.nodes[2].add_p2p_connection(BaseNode()) | self.nodes[2].add_p2p_connection(BaseNode()) | ||||
self.nodes[2].p2p.wait_for_verack() | |||||
self.log.info( | self.log.info( | ||||
"Wait for node2 reach current tip. Test that it has propagated all the blocks to us") | "Wait for node2 reach current tip. Test that it has propagated all the blocks to us") | ||||
getdata_request = msg_getdata() | getdata_request = msg_getdata() | ||||
for block in blocks: | for block in blocks: | ||||
getdata_request.inv.append(CInv(2, block)) | getdata_request.inv.append(CInv(2, block)) | ||||
self.nodes[2].p2p.send_message(getdata_request) | self.nodes[2].p2p.send_message(getdata_request) | ||||
Show All 17 Lines |