mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 15:16:41 +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()
|
reactor = object()
|
||||||
private_dir = "private"
|
private_dir = "private"
|
||||||
txtorcon = mock.Mock()
|
txtorcon = mock.Mock()
|
||||||
tpp = mock.Mock
|
tor = mock.Mock
|
||||||
tpp.tor_protocol = mock.Mock()
|
tor.protocol = mock.Mock()
|
||||||
txtorcon.launch_tor = mock.Mock(return_value=tpp)
|
txtorcon.launch = mock.Mock(return_value=tor)
|
||||||
|
|
||||||
with mock.patch("allmydata.util.tor_provider.allocate_tcp_port",
|
with mock.patch("allmydata.util.tor_provider.allocate_tcp_port",
|
||||||
return_value=999999):
|
return_value=999999):
|
||||||
d = tor_provider._launch_tor(reactor, tor_executable, private_dir,
|
d = tor_provider._launch_tor(reactor, tor_executable, private_dir,
|
||||||
txtorcon)
|
txtorcon)
|
||||||
tor_control_endpoint, tor_control_proto = self.successResultOf(d)
|
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):
|
def test_launch(self):
|
||||||
return self._do_test_launch(None)
|
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
|
# 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
|
# different Tor being present at node startup. OTOH, maybe we don't
|
||||||
# need to worry about it.
|
# need to worry about it.
|
||||||
tor_config = txtorcon.TorConfig()
|
|
||||||
tor_config.DataDirectory = data_directory(private_dir)
|
|
||||||
|
|
||||||
# unix-domain control socket
|
# unix-domain control socket
|
||||||
tor_config.ControlPort = "unix:" + os.path.join(private_dir, "tor.control")
|
tor_control_endpoint_desc = "unix:" + os.path.join(private_dir, "tor.control")
|
||||||
tor_control_endpoint_desc = tor_config.ControlPort
|
|
||||||
|
|
||||||
tor_config.SOCKSPort = allocate_tcp_port()
|
tor = yield txtorcon.launch(
|
||||||
|
reactor,
|
||||||
tpp = yield txtorcon.launch_tor(
|
control_port=tor_control_endpoint_desc,
|
||||||
tor_config, reactor,
|
data_directory=data_directory(private_dir),
|
||||||
tor_binary=tor_executable,
|
tor_binary=tor_executable,
|
||||||
|
socks_port=allocate_tcp_port(),
|
||||||
# can be useful when debugging; mirror Tor's output to ours
|
# can be useful when debugging; mirror Tor's output to ours
|
||||||
# stdout=sys.stdout,
|
# stdout=sys.stdout,
|
||||||
# stderr=sys.stderr,
|
# 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
|
# now tor is launched and ready to be spoken to
|
||||||
# as a side effect, we've got an ITorControlProtocol ready to go
|
# 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
|
# 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
|
# tor will exit when it notices its parent (us) quit. Unit tests will
|
||||||
|
Loading…
Reference in New Issue
Block a user