[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Add note and tests for Cell types that always have empty unused content



commit dc7be2c5faa9675279a3e9da263f2975e78ef762
Author: Dave Rolek <dmr-x@xxxxxxxxxx>
Date:   Mon Jul 9 19:24:26 2018 +0000

    Add note and tests for Cell types that always have empty unused content
---
 stem/client/cell.py      | 5 +++++
 test/unit/client/cell.py | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/stem/client/cell.py b/stem/client/cell.py
index d04c387e..948201fd 100644
--- a/stem/client/cell.py
+++ b/stem/client/cell.py
@@ -80,6 +80,11 @@ class Cell(object):
   Unused padding are **not** used in equality checks or hashing. If two cells
   differ only in their *unused* attribute they are functionally equal.
 
+  The following cell types explicitly don't have *unused* content:
+    * PaddingCell (we consider all content part of payload)
+    * VersionsCell (all content is unpacked and treated as a version specification)
+    * VPaddingCell (we consider all content part of payload)
+
   :var bytes unused: unused filler that padded the cell to the expected size
   """
 
diff --git a/test/unit/client/cell.py b/test/unit/client/cell.py
index bf2b9275..c7eb6f00 100644
--- a/test/unit/client/cell.py
+++ b/test/unit/client/cell.py
@@ -180,6 +180,7 @@ class TestCell(unittest.TestCase):
 
       cell = Cell.pop(cell_bytes, 2)[0]
       self.assertEqual(payload, cell.payload)
+      self.assertEqual(b'', cell.unused)  # always empty
       self.assertEqual(cell_bytes, cell.pack(2))
 
   def test_relay_cell(self):
@@ -264,6 +265,7 @@ class TestCell(unittest.TestCase):
 
       cell = Cell.pop(cell_bytes, link_protocol)[0]
       self.assertEqual(versions, cell.versions)
+      self.assertEqual(b'', cell.unused)  # always empty
       self.assertEqual(cell_bytes, cell.pack(link_protocol))
 
   def test_netinfo_cell(self):
@@ -283,6 +285,7 @@ class TestCell(unittest.TestCase):
 
       cell = Cell.pop(cell_bytes, 2)[0]
       self.assertEqual(payload, cell.payload)
+      self.assertEqual(b'', cell.unused)  # always empty
       self.assertEqual(cell_bytes, cell.pack(2))
 
     empty_constructed_cell = VPaddingCell(size = 0)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits