[tor-commits] [stem/master] Add tests for 'unused' content of CertsCell

atagar at torproject.org atagar at torproject.org
Thu Jul 12 18:53:10 UTC 2018


commit 5f3376a1d0e569a4573d474a6dd13646beb82c8a
Author: Dave Rolek <dmr-x at riseup.net>
Date:   Wed Jul 11 17:59:17 2018 +0000

    Add tests for 'unused' content of CertsCell
    
    This was the only implemented cell type without any tests of 'unused'
    content, so now all have tests. However they don't necessarily test
    non-blank or non-ZERO data yet.
---
 test/unit/client/cell.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/test/unit/client/cell.py b/test/unit/client/cell.py
index ade5d407..d45886f8 100644
--- a/test/unit/client/cell.py
+++ b/test/unit/client/cell.py
@@ -75,9 +75,9 @@ VPADDING_CELLS = {
 }
 
 CERTS_CELLS = {
-  b'\x00\x00\x81\x00\x01\x00': ([], 2),
-  b'\x00\x00\x81\x00\x04\x01\x01\x00\x00': ([Certificate(1, b'')], 2),
-  b'\x00\x00\x81\x00\x05\x01\x01\x00\x01\x08': ([Certificate(1, b'\x08')], 2),
+  b'\x00\x00\x81\x00\x01\x00': ([], b'', 2),
+  b'\x00\x00\x81\x00\x04\x01\x01\x00\x00': ([Certificate(1, b'')], b'', 2),
+  b'\x00\x00\x81\x00\x05\x01\x01\x00\x01\x08': ([Certificate(1, b'\x08')], b'', 2),
 }
 
 AUTH_CHALLENGE_CELLS = {
@@ -297,11 +297,12 @@ class TestCell(unittest.TestCase):
     self.assertRaisesRegexp(ValueError, re.escape('VPaddingCell constructor must specify payload or size'), VPaddingCell)
 
   def test_certs_cell(self):
-    for cell_bytes, (certs, link_protocol) in CERTS_CELLS.items():
+    for cell_bytes, (certs, unused, link_protocol) in CERTS_CELLS.items():
       self.assertEqual(cell_bytes, CertsCell(certs).pack(link_protocol))
 
       cell = Cell.pop(cell_bytes, link_protocol)[0]
       self.assertEqual(certs, cell.certificates)
+      self.assertEqual(unused, cell.unused)
       self.assertEqual(cell_bytes, cell.pack(link_protocol))
 
     # extra bytes after the last certificate should be ignored





More information about the tor-commits mailing list