Skip to content
This repository was archived by the owner on Mar 2, 2022. It is now read-only.

Commit dc4b00e

Browse files
committed
Rename TorState object to tor_state
1 parent 20bbadc commit dc4b00e

6 files changed

Lines changed: 22 additions & 22 deletions

File tree

test/template.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ class TorTestCase(unittest.TestCase):
1212

1313
@defer.inlineCallbacks
1414
def setUp(self):
15-
self.tor = yield connect_to_tor(
15+
self.tor_state = yield connect_to_tor(
1616
launch_tor=False,
1717
circuit_build_timeout=30,
1818
circuit_idle_timeout=30,
1919
control_port=int(os.environ.get('CHUTNEY_CONTROL_PORT')))
2020

21-
self.attacher = SOCKSClientStreamAttacher(self.tor)
22-
yield self.tor.set_attacher(self.attacher, reactor)
21+
self.attacher = SOCKSClientStreamAttacher(self.tor_state)
22+
yield self.tor_state.set_attacher(self.attacher, reactor)
2323

2424
@property
2525
def routers(self):
26-
return list(set(self.tor.routers.values()))
26+
return list(set(self.tor_state.routers.values()))
2727

2828
@property
2929
def exits(self):
@@ -35,7 +35,7 @@ def random_path(self):
3535

3636
@defer.inlineCallbacks
3737
def tearDown(self):
38-
yield self.tor.set_attacher(None, reactor)
39-
yield self.tor.protocol.quit()
38+
yield self.tor_state.set_attacher(None, reactor)
39+
yield self.tor_state.protocol.quit()
4040
# seems to leave dirty reactor otherwise?
41-
yield self.tor.protocol.transport.loseConnection()
41+
yield self.tor_state.protocol.transport.loseConnection()

test/test_attacher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class TestSOCKSClientStreamAttacher(TorTestCase):
5454
def setUp(self):
5555
yield super(TestSOCKSClientStreamAttacher, self).setUp()
5656
# do not attach circuits automatically
57-
yield self.tor.set_attacher(None, reactor)
57+
yield self.tor_state.set_attacher(None, reactor)
5858

5959
@defer.inlineCallbacks
6060
def test_create_circuit(self):

test/test_circuit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def test_exit_scan(self):
88
all_exits = set(self.exits)
99
num_circuits = 0
1010
seen = set()
11-
for circuit in ExitScan(self.tor):
11+
for circuit in ExitScan(self.tor_state):
1212
assert len(circuit) == 3
1313
assert 'exit' in circuit[-1].flags
1414
seen.add(circuit[-1])
@@ -20,7 +20,7 @@ def test_two_hop(self):
2020
all_r = set(self.routers)
2121
num_circuits = 0
2222
seen = set()
23-
for circuit in TwoHop(self.tor):
23+
for circuit in TwoHop(self.tor_state):
2424
assert len(circuit) == 2
2525
assert 'exit' in circuit[-1].flags
2626
num_circuits = num_circuits + 1

test/test_fetcher.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ class TestOnionRoutedTCPClientEndpoint(TorTestCase):
3232
def test_connect_tcp(self):
3333
endpoint = random.choice(self.routers)
3434
# Connect to a routers OR port as a general TCP connection test
35-
ore = OnionRoutedTCPClientEndpoint(endpoint.ip, int(endpoint.or_port),
36-
self.tor, self.random_path())
35+
ore = OnionRoutedTCPClientEndpoint(str(endpoint.ip), int(endpoint.or_port),
36+
self.tor_state, self.random_path())
3737
proto = yield ore.connect(MockProtocol())
3838
self.failUnlessIsInstance(proto, MockProtocol)
3939

4040
@defer.inlineCallbacks
4141
def test_connect_tcp_fail(self):
4242
ore = OnionRoutedTCPClientEndpoint('127.0.0.1', 3,
43-
self.tor, self.random_path())
43+
self.tor_state, self.random_path())
4444
with self.assertRaises(ConnectionRefused):
4545
yield ore.connect(MockProtocol())
4646

@@ -63,7 +63,7 @@ def render_GET(self, request):
6363
@defer.inlineCallbacks
6464
def test_do_request(self):
6565
agent = OnionRoutedAgent(reactor, path=self.random_path(),
66-
state=self.tor)
66+
state=self.tor_state)
6767
url = "http://127.0.0.1:{}".format(self.port)
6868
request = yield agent.request("GET", url)
6969
body = yield readBody(request)
@@ -72,7 +72,7 @@ def test_do_request(self):
7272
@defer.inlineCallbacks
7373
def test_do_failing_request(self):
7474
agent = OnionRoutedAgent(reactor, path=self.random_path(),
75-
state=self.tor)
75+
state=self.tor_state)
7676

7777
url = "http://127.0.0.1:{}".format(3)
7878
with self.assertRaises(ConnectionRefused):

test/test_listener.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class TestCircuitEventListener(TorTestCase):
3131
@defer.inlineCallbacks
3232
def setUp(self):
3333
yield super(TestCircuitEventListener, self).setUp()
34-
self.circuit_event_listener = CircuitEventListener(self.tor)
35-
self.tor.add_circuit_listener(self.circuit_event_listener)
34+
self.circuit_event_listener = CircuitEventListener(self.tor_state)
35+
self.tor_state.add_circuit_listener(self.circuit_event_listener)
3636

3737
@defer.inlineCallbacks
3838
def test_circuit_lifecycle(self):
@@ -44,7 +44,7 @@ def test_circuit_lifecycle(self):
4444
# XXX argh, we haven't gotten all the events from Tor yet...
4545
# hax to block until we've made Tor do something...
4646
yield circ.close(ifUnused=False)
47-
yield self.tor.protocol.get_info('version')
47+
yield self.tor_state.protocol.get_info('version')
4848
expected_states = ['circuit_new', 'circuit_launched', 'circuit_extend',
4949
'circuit_extend', 'circuit_extend', 'circuit_built',
5050
'circuit_closed']
@@ -59,7 +59,7 @@ class TestStreamBandwidthListener(TorTestCase):
5959
def setUp(self):
6060
yield super(TestStreamBandwidthListener, self).setUp()
6161
self.fetch_size = 8*2**20 # 8MB
62-
self.stream_bandwidth_listener = yield StreamBandwidthListener(self.tor)
62+
self.stream_bandwidth_listener = yield StreamBandwidthListener(self.tor_state)
6363

6464
class DummyResource(Resource):
6565
isLeaf = True
@@ -132,12 +132,12 @@ def test_circ_avg_bw(self):
132132
def do_fetch(self):
133133
time_start = time.time()
134134
path = self.random_path()
135-
agent = OnionRoutedAgent(reactor, path=path, state=self.tor)
135+
agent = OnionRoutedAgent(reactor, path=path, state=self.tor_state)
136136
url = "http://127.0.0.1:{}".format(self.port)
137137
request = yield agent.request("GET", url)
138138
body = yield readBody(request)
139139
assert len(body) == self.fetch_size
140-
circ = [c for c in self.tor.circuits.values() if c.path == path][0]
140+
circ = [c for c in self.tor_state.circuits.values() if c.path == path][0]
141141
assert isinstance(circ, Circuit)
142142

143143
# XXX: Wait for circuit to close, then I think we can be sure that

test/test_measurement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def render_GET(self, request):
3636
def test_scan_chutney(self):
3737
# check that each run is producing the same input set!
3838
self.tmp = mkdtemp()
39-
scan = BwScan(self.tor, reactor, self.tmp)
39+
scan = BwScan(self.tor_state, reactor, self.tmp)
4040
scan.baseurl = 'http://127.0.0.1:{}'.format(self.port)
4141

4242
def check_all_routers_measured(measurement_dir):

0 commit comments

Comments
 (0)