From d1fd43aa4f0f8723b480924943397f8cea4e92ca Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Wed, 19 Jul 2017 12:09:48 -0500 Subject: [PATCH] tor/i2p: rename create_onion/create_dest to create_config --- src/allmydata/scripts/create_node.py | 4 ++-- src/allmydata/test/cli/test_create.py | 26 ++++++++++++------------- src/allmydata/test/test_i2p_provider.py | 4 ++-- src/allmydata/test/test_tor_provider.py | 6 +++--- src/allmydata/util/i2p_provider.py | 2 +- src/allmydata/util/tor_provider.py | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/allmydata/scripts/create_node.py b/src/allmydata/scripts/create_node.py index 81ab7c1f1..1d71996f0 100644 --- a/src/allmydata/scripts/create_node.py +++ b/src/allmydata/scripts/create_node.py @@ -251,12 +251,12 @@ def write_node_config(c, config): else: if "tor" in listeners: (tor_config, tor_port, tor_location) = \ - yield tor_provider.create_onion(reactor, config) + yield tor_provider.create_config(reactor, config) tub_ports.append(tor_port) tub_locations.append(tor_location) if "i2p" in listeners: (i2p_config, i2p_port, i2p_location) = \ - yield i2p_provider.create_dest(reactor, config) + yield i2p_provider.create_config(reactor, config) tub_ports.append(i2p_port) tub_locations.append(i2p_location) if "tcp" in listeners: diff --git a/src/allmydata/test/cli/test_create.py b/src/allmydata/test/cli/test_create.py index 174a7097e..75162c39e 100644 --- a/src/allmydata/test/cli/test_create.py +++ b/src/allmydata/test/cli/test_create.py @@ -261,7 +261,7 @@ class Config(unittest.TestCase): def test_node_slow_tor(self): basedir = self.mktemp() d = defer.Deferred() - with mock.patch("allmydata.util.tor_provider.create_onion", + with mock.patch("allmydata.util.tor_provider.create_config", return_value=d): d2 = run_cli("create-node", "--listen=tor", basedir) d.callback(({}, "port", "location")) @@ -274,7 +274,7 @@ class Config(unittest.TestCase): def test_node_slow_i2p(self): basedir = self.mktemp() d = defer.Deferred() - with mock.patch("allmydata.util.i2p_provider.create_dest", + with mock.patch("allmydata.util.i2p_provider.create_config", return_value=d): d2 = run_cli("create-node", "--listen=i2p", basedir) d.callback(({}, "port", "location")) @@ -325,9 +325,9 @@ class Tor(unittest.TestCase): tor_config = {"abc": "def"} tor_port = "ghi" tor_location = "jkl" - onion_d = defer.succeed( (tor_config, tor_port, tor_location) ) - with mock.patch("allmydata.util.tor_provider.create_onion", - return_value=onion_d) as co: + config_d = defer.succeed( (tor_config, tor_port, tor_location) ) + with mock.patch("allmydata.util.tor_provider.create_config", + return_value=config_d) as co: rc, out, err = self.successResultOf( run_cli("create-node", "--listen=tor", basedir)) self.assertEqual(len(co.mock_calls), 1) @@ -345,9 +345,9 @@ class Tor(unittest.TestCase): tor_config = {"abc": "def"} tor_port = "ghi" tor_location = "jkl" - onion_d = defer.succeed( (tor_config, tor_port, tor_location) ) - with mock.patch("allmydata.util.tor_provider.create_onion", - return_value=onion_d) as co: + config_d = defer.succeed( (tor_config, tor_port, tor_location) ) + with mock.patch("allmydata.util.tor_provider.create_config", + return_value=config_d) as co: rc, out, err = self.successResultOf( run_cli("create-node", "--listen=tor", "--tor-launch", basedir)) @@ -361,9 +361,9 @@ class Tor(unittest.TestCase): tor_config = {"abc": "def"} tor_port = "ghi" tor_location = "jkl" - onion_d = defer.succeed( (tor_config, tor_port, tor_location) ) - with mock.patch("allmydata.util.tor_provider.create_onion", - return_value=onion_d) as co: + config_d = defer.succeed( (tor_config, tor_port, tor_location) ) + with mock.patch("allmydata.util.tor_provider.create_config", + return_value=config_d) as co: rc, out, err = self.successResultOf( run_cli("create-node", "--listen=tor", "--tor-control-port=mno", basedir)) @@ -400,7 +400,7 @@ class I2P(unittest.TestCase): i2p_port = "ghi" i2p_location = "jkl" dest_d = defer.succeed( (i2p_config, i2p_port, i2p_location) ) - with mock.patch("allmydata.util.i2p_provider.create_dest", + with mock.patch("allmydata.util.i2p_provider.create_config", return_value=dest_d) as co: rc, out, err = self.successResultOf( run_cli("create-node", "--listen=i2p", basedir)) @@ -427,7 +427,7 @@ class I2P(unittest.TestCase): i2p_port = "ghi" i2p_location = "jkl" dest_d = defer.succeed( (i2p_config, i2p_port, i2p_location) ) - with mock.patch("allmydata.util.i2p_provider.create_dest", + with mock.patch("allmydata.util.i2p_provider.create_config", return_value=dest_d) as co: rc, out, err = self.successResultOf( run_cli("create-node", "--listen=i2p", "--i2p-sam-port=mno", diff --git a/src/allmydata/test/test_i2p_provider.py b/src/allmydata/test/test_i2p_provider.py index 242c7c444..fbb24d3f6 100644 --- a/src/allmydata/test/test_i2p_provider.py +++ b/src/allmydata/test/test_i2p_provider.py @@ -124,7 +124,7 @@ class CreateDest(unittest.TestCase): def test_no_txi2p(self): with mock.patch("allmydata.util.i2p_provider._import_txi2p", return_value=None): - d = i2p_provider.create_dest("reactor", "cli_config") + d = i2p_provider.create_config("reactor", "cli_config") f = self.failureResultOf(d) self.assertIsInstance(f.value, ValueError) self.assertEqual(str(f.value), @@ -164,7 +164,7 @@ class CreateDest(unittest.TestCase): connect_to_i2p): with mock.patch("allmydata.util.i2p_provider.clientFromString", return_value=ep) as cfs: - d = i2p_provider.create_dest(reactor, cli_config) + d = i2p_provider.create_config(reactor, cli_config) tahoe_config_i2p, i2p_port, i2p_location = self.successResultOf(d) connect_to_i2p.assert_called_with(reactor, cli_config, txi2p) diff --git a/src/allmydata/test/test_tor_provider.py b/src/allmydata/test/test_tor_provider.py index dbb74e4b2..1ae401bf8 100644 --- a/src/allmydata/test/test_tor_provider.py +++ b/src/allmydata/test/test_tor_provider.py @@ -152,7 +152,7 @@ class CreateOnion(unittest.TestCase): def test_no_txtorcon(self): with mock.patch("allmydata.util.tor_provider._import_txtorcon", return_value=None): - d = tor_provider.create_onion("reactor", "cli_config") + d = tor_provider.create_config("reactor", "cli_config") f = self.failureResultOf(d) self.assertIsInstance(f.value, ValueError) self.assertEqual(str(f.value), @@ -184,7 +184,7 @@ class CreateOnion(unittest.TestCase): launch_tor): with mock.patch("allmydata.util.tor_provider.allocate_tcp_port", return_value=999999): - d = tor_provider.create_onion(reactor, cli_config) + d = tor_provider.create_config(reactor, cli_config) tahoe_config_tor, tor_port, tor_location = self.successResultOf(d) launch_tor.assert_called_with(reactor, executable, @@ -238,7 +238,7 @@ class CreateOnion(unittest.TestCase): connect_to_tor): with mock.patch("allmydata.util.tor_provider.allocate_tcp_port", return_value=999999): - d = tor_provider.create_onion(reactor, cli_config) + d = tor_provider.create_config(reactor, cli_config) tahoe_config_tor, tor_port, tor_location = self.successResultOf(d) connect_to_tor.assert_called_with(reactor, cli_config, txtorcon) diff --git a/src/allmydata/util/i2p_provider.py b/src/allmydata/util/i2p_provider.py index 10777e16a..076bb52b8 100644 --- a/src/allmydata/util/i2p_provider.py +++ b/src/allmydata/util/i2p_provider.py @@ -65,7 +65,7 @@ def _connect_to_i2p(reactor, cli_config, txi2p): raise ValueError("unable to reach any default I2P SAM port") @inlineCallbacks -def create_dest(reactor, cli_config): +def create_config(reactor, cli_config): txi2p = _import_txi2p() if not txi2p: raise ValueError("Cannot create I2P Destination without txi2p. " diff --git a/src/allmydata/util/tor_provider.py b/src/allmydata/util/tor_provider.py index 1c930c14e..28ac4db15 100644 --- a/src/allmydata/util/tor_provider.py +++ b/src/allmydata/util/tor_provider.py @@ -124,7 +124,7 @@ def _connect_to_tor(reactor, cli_config, txtorcon): raise ValueError("unable to reach any default Tor control port") @inlineCallbacks -def create_onion(reactor, cli_config): +def create_config(reactor, cli_config): txtorcon = _import_txtorcon() if not txtorcon: raise ValueError("Cannot create onion without txtorcon. "