mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 14:52:26 +00:00
Switch to non-deprecated API.
This commit is contained in:
parent
3cf03a5c33
commit
ffecdf8c77
@ -94,16 +94,16 @@ class LaunchTor(unittest.TestCase):
|
||||
reactor = object()
|
||||
private_dir = "private"
|
||||
txtorcon = mock.Mock()
|
||||
tpp = mock.Mock
|
||||
tpp.tor_protocol = mock.Mock()
|
||||
txtorcon.launch_tor = mock.Mock(return_value=tpp)
|
||||
tor = mock.Mock
|
||||
tor.protocol = mock.Mock()
|
||||
txtorcon.launch = mock.Mock(return_value=tor)
|
||||
|
||||
with mock.patch("allmydata.util.tor_provider.allocate_tcp_port",
|
||||
return_value=999999):
|
||||
d = tor_provider._launch_tor(reactor, tor_executable, private_dir,
|
||||
txtorcon)
|
||||
tor_control_endpoint, tor_control_proto = self.successResultOf(d)
|
||||
self.assertIs(tor_control_proto, tpp.tor_protocol)
|
||||
self.assertIs(tor_control_proto, tor.protocol)
|
||||
|
||||
def test_launch(self):
|
||||
return self._do_test_launch(None)
|
||||
|
@ -100,18 +100,16 @@ def _launch_tor(reactor, tor_executable, private_dir, txtorcon):
|
||||
# us against one Tor being on $PATH at create-node time, but then a
|
||||
# different Tor being present at node startup. OTOH, maybe we don't
|
||||
# need to worry about it.
|
||||
tor_config = txtorcon.TorConfig()
|
||||
tor_config.DataDirectory = data_directory(private_dir)
|
||||
|
||||
# unix-domain control socket
|
||||
tor_config.ControlPort = "unix:" + os.path.join(private_dir, "tor.control")
|
||||
tor_control_endpoint_desc = tor_config.ControlPort
|
||||
tor_control_endpoint_desc = "unix:" + os.path.join(private_dir, "tor.control")
|
||||
|
||||
tor_config.SOCKSPort = allocate_tcp_port()
|
||||
|
||||
tpp = yield txtorcon.launch_tor(
|
||||
tor_config, reactor,
|
||||
tor = yield txtorcon.launch(
|
||||
reactor,
|
||||
control_port=tor_control_endpoint_desc,
|
||||
data_directory=data_directory(private_dir),
|
||||
tor_binary=tor_executable,
|
||||
socks_port=allocate_tcp_port(),
|
||||
# can be useful when debugging; mirror Tor's output to ours
|
||||
# stdout=sys.stdout,
|
||||
# stderr=sys.stderr,
|
||||
@ -119,7 +117,7 @@ def _launch_tor(reactor, tor_executable, private_dir, txtorcon):
|
||||
|
||||
# now tor is launched and ready to be spoken to
|
||||
# as a side effect, we've got an ITorControlProtocol ready to go
|
||||
tor_control_proto = tpp.tor_protocol
|
||||
tor_control_proto = tor.protocol
|
||||
|
||||
# How/when to shut down the new process? for normal usage, the child
|
||||
# tor will exit when it notices its parent (us) quit. Unit tests will
|
||||
|
Loading…
Reference in New Issue
Block a user