Ejemplo n.º 1
0
    def test_load_peer_addresses_peer_xrd(self):
        """
        Should load peers from peers.xrd AND from config.user.peer_list
        """
        with set_xrd_dir('peers') as tmp_dir:
            self.peer_manager.peers_path = os.path.join(tmp_dir, 'peers.json')

            self.peer_manager.load_peer_addresses()

            # This was in peers.xrd
            self.assertIn(IPMetadata.canonical_full_address('34.208.138.15'), self.peer_manager.known_peer_addresses)
            # config.user.peer_list is all in there too
            for p in config.user.peer_list:
                self.assertIn(IPMetadata.canonical_full_address(p), self.peer_manager.known_peer_addresses)
Ejemplo n.º 2
0
    def test_load_peer_addresses_no_file(self):
        """
        If no peers.xrd exists, use config.user.peer_list
        """
        with set_xrd_dir('no_data') as tmp_dir:
            self.peer_manager.peers_path = os.path.join(tmp_dir, config.dev.peers_filename)

            self.peer_manager.load_peer_addresses()

            # config.user.peer_list is all in there too
            self.assertEqual(len(config.user.peer_list), len(self.peer_manager.known_peer_addresses))
            for p in config.user.peer_list:
                self.assertIn(IPMetadata.canonical_full_address(p), self.peer_manager.known_peer_addresses)