def run_test(self):
    node = self.nodes[0].add_p2p_connection(P2PIgnoreInv())
    expected_services = (NODE_WITNESS | NODE_NETWORK_LIMITED)
    self.log.info('Check that node has signalled expected services.')
    assert_equal(node.nServices, expected_services)
    self.log.info('Check that the localservices is as expected.')
    assert_equal(int(self.nodes[0].getnetworkinfo()['localservices'], 16), expected_services)
    self.log.info('Mine enough blocks to reach the NODE_NETWORK_LIMITED range.')
    self.connect_nodes(0, 1)
    blocks = self.nodes[1].generatetoaddress(292, self.nodes[1].get_deterministic_priv_key().address)
    self.sync_blocks([self.nodes[0], self.nodes[1]])
    self.log.info('Make sure we can max retrieve block at tip-288.')
    node.send_getdata_for_block(blocks[1])
    node.wait_for_block(int(blocks[1], 16), timeout=3)
    self.log.info('Requesting block at height 2 (tip-289) must fail (ignored).')
    node.send_getdata_for_block(blocks[0])
    node.wait_for_disconnect(5)
    self.log.info('Check local address relay, do a fresh connection.')
    self.nodes[0].disconnect_p2ps()
    node1 = self.nodes[0].add_p2p_connection(P2PIgnoreInv())
    node1.send_message(msg_verack())
    node1.wait_for_addr()
    assert_equal(node1.firstAddrnServices, expected_services)
    self.nodes[0].disconnect_p2ps()
    self.connect_nodes(0, 2)
    try:
        self.sync_blocks([self.nodes[0], self.nodes[2]], timeout=5)
    except:
        pass
    assert_equal(self.nodes[2].getblockheader(self.nodes[2].getbestblockhash())['height'], 0)
    self.connect_nodes(1, 2)
    self.sync_blocks()
    self.disconnect_all()
    self.nodes[0].generatetoaddress(10, self.nodes[0].get_deterministic_priv_key().address)
    self.connect_nodes(0, 1)
    self.sync_blocks([self.nodes[0], self.nodes[1]])
def run_test(self):
    node = self.nodes[0].add_p2p_connection(P2PIgnoreInv())
    expected_services = (NODE_WITNESS | NODE_NETWORK_LIMITED)
    self.log.info('Check that node has signalled expected services.')
    assert_equal(node.nServices, expected_services)
    self.log.info('Check that the localservices is as expected.')
    assert_equal(int(self.nodes[0].getnetworkinfo()['localservices'], 16), expected_services)
    self.log.info('Mine enough blocks to reach the NODE_NETWORK_LIMITED range.')
    self.connect_nodes(0, 1)
    blocks = self.nodes[1].generatetoaddress(292, self.nodes[1].get_deterministic_priv_key().address)
    self.sync_blocks([self.nodes[0], self.nodes[1]])
    self.log.info('Make sure we can max retrieve block at tip-288.')
    node.send_getdata_for_block(blocks[1])
    node.wait_for_block(int(blocks[1], 16), timeout=3)
    self.log.info('Requesting block at height 2 (tip-289) must fail (ignored).')
    node.send_getdata_for_block(blocks[0])
    node.wait_for_disconnect(5)
    self.log.info('Check local address relay, do a fresh connection.')
    self.nodes[0].disconnect_p2ps()
    node1 = self.nodes[0].add_p2p_connection(P2PIgnoreInv())
    node1.send_message(msg_verack())
    node1.wait_for_addr()
    assert_equal(node1.firstAddrnServices, expected_services)
    self.nodes[0].disconnect_p2ps()
    self.connect_nodes(0, 2)
    try:
        self.sync_blocks([self.nodes[0], self.nodes[2]], timeout=5)
    except:
        pass
    assert_equal(self.nodes[2].getblockheader(self.nodes[2].getbestblockhash())['height'], 0)
    self.connect_nodes(1, 2)
    self.sync_blocks()
    self.disconnect_all()
    self.nodes[0].generatetoaddress(10, self.nodes[0].get_deterministic_priv_key().address)
    self.connect_nodes(0, 1)
    self.sync_blocks([self.nodes[0], self.nodes[1]])