mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-18 23:38:18 +00:00
Baseline tests for anonymous storage server announcements
This commit is contained in:
@ -210,7 +210,7 @@ def create_client(basedir=u".", _client_factory=None):
|
||||
return defer.fail()
|
||||
|
||||
|
||||
def create_client_from_config(config, _client_factory=None):
|
||||
def create_client_from_config(config, _client_factory=None, introducer_factory=None):
|
||||
"""
|
||||
Creates a new client instance (a subclass of Node). Most code
|
||||
should probably use `create_client` instead.
|
||||
@ -222,6 +222,9 @@ def create_client_from_config(config, _client_factory=None):
|
||||
|
||||
:param _client_factory: for testing; the class to instantiate
|
||||
instead of _Client
|
||||
|
||||
:param introducer_factory: for testing; the class to instantiate instead
|
||||
of IntroducerClient
|
||||
"""
|
||||
try:
|
||||
if _client_factory is None:
|
||||
@ -239,7 +242,7 @@ def create_client_from_config(config, _client_factory=None):
|
||||
)
|
||||
control_tub = node.create_control_tub()
|
||||
|
||||
introducer_clients = create_introducer_clients(config, main_tub)
|
||||
introducer_clients = create_introducer_clients(config, main_tub, introducer_factory)
|
||||
storage_broker = create_storage_farm_broker(
|
||||
config, default_connection_handlers, foolscap_connection_handlers,
|
||||
tub_options, introducer_clients
|
||||
@ -281,12 +284,18 @@ def _sequencer(config):
|
||||
return seqnum, nonce
|
||||
|
||||
|
||||
def create_introducer_clients(config, main_tub):
|
||||
def create_introducer_clients(config, main_tub, introducer_factory=None):
|
||||
"""
|
||||
Read, validate and parse any 'introducers.yaml' configuration.
|
||||
|
||||
:param introducer_factory: for testing; the class to instantiate instead
|
||||
of IntroducerClient
|
||||
|
||||
:returns: a list of IntroducerClient instances
|
||||
"""
|
||||
if introducer_factory is None:
|
||||
introducer_factory = IntroducerClient
|
||||
|
||||
# we return this list
|
||||
introducer_clients = []
|
||||
|
||||
@ -332,7 +341,7 @@ def create_introducer_clients(config, main_tub):
|
||||
|
||||
for petname, introducer in introducers.items():
|
||||
introducer_cache_filepath = FilePath(config.get_private_path("introducer_{}_cache.yaml".format(petname)))
|
||||
ic = IntroducerClient(
|
||||
ic = introducer_factory(
|
||||
main_tub,
|
||||
introducer['furl'].encode("ascii"),
|
||||
config.nickname,
|
||||
|
Reference in New Issue
Block a user