def getaddr_tests(self):
    self.log.info('Test getaddr behavior')
    self.log.info('Check that we send a getaddr message upon connecting to an outbound-full-relay peer')
    full_outbound_peer = self.nodes[0].add_outbound_p2p_connection(GetAddrStore(), p2p_idx=0, connection_type='outbound-full-relay')
    full_outbound_peer.sync_with_ping()
    assert full_outbound_peer.getaddr_received
    self.log.info('Check that we do not send a getaddr message upon connecting to a block-relay-only peer')
    block_relay_peer = self.nodes[0].add_outbound_p2p_connection(GetAddrStore(), p2p_idx=1, connection_type='block-relay-only')
    block_relay_peer.sync_with_ping()
    assert_equal(block_relay_peer.getaddr_received, False)
    self.log.info('Check that we answer getaddr messages only from inbound peers')
    inbound_peer = self.nodes[0].add_p2p_connection(GetAddrStore())
    inbound_peer.sync_with_ping()
    for i in range(1000):
        first_octet = (i >> 8)
        second_octet = (i % 256)
        a = f'{first_octet}.{second_octet}.1.1'
        self.nodes[0].addpeeraddress(a, 8333)
    full_outbound_peer.send_and_ping(msg_getaddr())
    block_relay_peer.send_and_ping(msg_getaddr())
    inbound_peer.send_and_ping(msg_getaddr())
    self.mocktime += (5 * 60)
    self.nodes[0].setmocktime(self.mocktime)
    inbound_peer.wait_until(inbound_peer.addr_received)
    assert_equal(full_outbound_peer.num_ipv4_received, 0)
    assert_equal(block_relay_peer.num_ipv4_received, 0)
    assert (inbound_peer.num_ipv4_received > 100)
    self.nodes[0].disconnect_p2ps()
def getaddr_tests(self):
    self.log.info('Test getaddr behavior')
    self.log.info('Check that we send a getaddr message upon connecting to an outbound-full-relay peer')
    full_outbound_peer = self.nodes[0].add_outbound_p2p_connection(GetAddrStore(), p2p_idx=0, connection_type='outbound-full-relay')
    full_outbound_peer.sync_with_ping()
    assert full_outbound_peer.getaddr_received
    self.log.info('Check that we do not send a getaddr message upon connecting to a block-relay-only peer')
    block_relay_peer = self.nodes[0].add_outbound_p2p_connection(GetAddrStore(), p2p_idx=1, connection_type='block-relay-only')
    block_relay_peer.sync_with_ping()
    assert_equal(block_relay_peer.getaddr_received, False)
    self.log.info('Check that we answer getaddr messages only from inbound peers')
    inbound_peer = self.nodes[0].add_p2p_connection(GetAddrStore())
    inbound_peer.sync_with_ping()
    for i in range(1000):
        first_octet = (i >> 8)
        second_octet = (i % 256)
        a = f'{first_octet}.{second_octet}.1.1'
        self.nodes[0].addpeeraddress(a, 8333)
    full_outbound_peer.send_and_ping(msg_getaddr())
    block_relay_peer.send_and_ping(msg_getaddr())
    inbound_peer.send_and_ping(msg_getaddr())
    self.mocktime += (5 * 60)
    self.nodes[0].setmocktime(self.mocktime)
    inbound_peer.wait_until(inbound_peer.addr_received)
    assert_equal(full_outbound_peer.num_ipv4_received, 0)
    assert_equal(block_relay_peer.num_ipv4_received, 0)
    assert (inbound_peer.num_ipv4_received > 100)
    self.nodes[0].disconnect_p2ps()