[tor-commits] [stem/master] Add and test for missing event types

atagar at torproject.org atagar at torproject.org
Sun May 22 01:40:51 UTC 2016


commit 7476dfab9424c35e182fbab44920bb84a12b7470
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat May 21 18:18:16 2016 -0700

    Add and test for missing event types
    
    We didn't quite cover all tor's events. Filling in the blanks and testing for
    this. Our integ tests check that our EventType enum is up to date.
---
 stem/control.py                 | 2 +-
 stem/settings.cfg               | 8 ++++++++
 test/unit/control/controller.py | 8 +++++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index a036144..621aaea 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -486,7 +486,7 @@ def event_description(event):
 
   :returns: str The event description
   """
-  return stem.manual._config().get('event.description.%s' % event.lower(), '')
+  return stem.manual._config().get('event.description.%s' % event.lower(), None)
 
 
 class BaseController(object):
diff --git a/stem/settings.cfg b/stem/settings.cfg
index aafeafd..d08cc6e 100644
--- a/stem/settings.cfg
+++ b/stem/settings.cfg
@@ -375,12 +375,18 @@ event.description.addrmap New address mapping for our DNS cache.
 event.description.authdir_newdescs Indicates we just received a new descriptor. This is only used by directory authorities.
 event.description.buildtimeout_set Indicates the timeout value for a circuit has changed.
 event.description.bw Event emitted every second with the bytes sent and received by tor.
+event.description.cell_stats Event emitted every second with the count of the number of cell types per circuit.
 event.description.circ Indicates that a circuit we've established through the tor network has been created, changed, or closed.
+event.description.circ_bw Event emitted every second with the bytes sent and received on a per-circuit basis.
 event.description.circ_minor Minor changes to our circuits, such as reuse of existing circuits for a different purpose.
 event.description.clients_seen Periodic summary of the countries we've seen users connect from. This is only used by bridge relays.
 event.description.conf_changed Indicates that our torrc configuration has changed. This could be in response to a SETCONF or RELOAD signal.
+event.description.conn_bw Event emitted every second with the byytes sent and received on a per-connection basis.
 event.description.descchanged Indicates that our descriptor has changed.
 event.description.guard Indicates that the set of relays we use for our initial connection into the tor network (guards) have changed.
+event.description.hs_desc Received a hidden service descriptor that wasn't yet cached.
+event.description.hs_desc_content Content of a hidden service descriptor we've fetched.
+event.description.network_liveness Emitted when the network becomes reachable or unreachable.
 event.description.newconsensus Received a new hourly consensus of relays in the tor network.
 event.description.newdesc Indicates that a new descriptor is available.
 event.description.ns Consensus information for an individual relay has changed. This could be due to receiving a new consensus or tor locally decides a relay is up or down.
@@ -391,4 +397,6 @@ event.description.status_general Notification of a change in tor's state.
 event.description.status_server Notification of a change in tor's state as a relay.
 event.description.stream Communication over a circuit we've established. For instance, Firefox making a connection through tor.
 event.description.stream_bw Event emitted every second with the bytes sent and received for a specific stream.
+event.description.tb_empty Statistics for when token buckets are refilled. This is only used when TestingTorNetwork is set.
+event.description.transport_launched Emitted when a pluggable transport is launched.
 
diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py
index afde523..b9870ae 100644
--- a/test/unit/control/controller.py
+++ b/test/unit/control/controller.py
@@ -35,10 +35,16 @@ class TestControl(unittest.TestCase):
       self.controller = Controller(socket)
 
   def test_event_description(self):
-    self.assertEqual('Tor debug logging event.', stem.control.event_description('DEBUG'))
+    self.assertEqual("Logging at the debug runlevel. This is low level, high volume information about tor's internals that generally isn't useful to users.", stem.control.event_description('DEBUG'))
     self.assertEqual('Event emitted every second with the bytes sent and received by tor.', stem.control.event_description('BW'))
     self.assertEqual('Event emitted every second with the bytes sent and received by tor.', stem.control.event_description('bw'))
 
+  def test_event_description_includes_all_events(self):
+    self.assertEqual(None, stem.control.event_description('NO_SUCH_EVENT'))
+
+    for event in stem.control.EventType:
+      self.assertTrue(stem.control.event_description(event) is not None)
+
   @patch('stem.control.Controller.get_info')
   def test_get_version(self, get_info_mock):
     """





More information about the tor-commits mailing list