From 02cb451a6b97a992f11b8edaed1103eb2749646d Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Thu, 17 Sep 2020 16:06:26 -0400 Subject: [PATCH] Fix failing tests. --- src/allmydata/test/test_storage.py | 18 +++++++++--------- src/allmydata/util/hashutil.py | 6 ++++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py index 1f5f91844..b9e3d00c6 100644 --- a/src/allmydata/test/test_storage.py +++ b/src/allmydata/test/test_storage.py @@ -366,21 +366,21 @@ class Server(unittest.TestCase): def test_declares_fixed_1528(self): ss = self.create("test_declares_fixed_1528") ver = ss.remote_get_version() - sv1 = ver['http://allmydata.org/tahoe/protocols/storage/v1'] - self.failUnless(sv1.get('prevents-read-past-end-of-share-data'), sv1) + sv1 = ver[b'http://allmydata.org/tahoe/protocols/storage/v1'] + self.failUnless(sv1.get(b'prevents-read-past-end-of-share-data'), sv1) def test_declares_maximum_share_sizes(self): ss = self.create("test_declares_maximum_share_sizes") ver = ss.remote_get_version() - sv1 = ver['http://allmydata.org/tahoe/protocols/storage/v1'] - self.failUnlessIn('maximum-immutable-share-size', sv1) - self.failUnlessIn('maximum-mutable-share-size', sv1) + sv1 = ver[b'http://allmydata.org/tahoe/protocols/storage/v1'] + self.failUnlessIn(b'maximum-immutable-share-size', sv1) + self.failUnlessIn(b'maximum-mutable-share-size', sv1) def test_declares_available_space(self): ss = self.create("test_declares_available_space") ver = ss.remote_get_version() - sv1 = ver['http://allmydata.org/tahoe/protocols/storage/v1'] - self.failUnlessIn('available-space', sv1) + sv1 = ver[b'http://allmydata.org/tahoe/protocols/storage/v1'] + self.failUnlessIn(b'available-space', sv1) def allocate(self, ss, storage_index, sharenums, size, canary=None): renew_secret = hashutil.tagged_hash(b"blah", b"%d" % next(self._lease_secret)) @@ -980,8 +980,8 @@ class MutableServer(unittest.TestCase): # Also see if the server explicitly declares that it supports this # feature. ver = ss.remote_get_version() - storage_v1_ver = ver["http://allmydata.org/tahoe/protocols/storage/v1"] - self.failUnless(storage_v1_ver.get("fills-holes-with-zero-bytes")) + storage_v1_ver = ver[b"http://allmydata.org/tahoe/protocols/storage/v1"] + self.failUnless(storage_v1_ver.get(b"fills-holes-with-zero-bytes")) # If the size is dropped to zero the share is deleted. answer = rstaraw(b"si1", secrets, diff --git a/src/allmydata/util/hashutil.py b/src/allmydata/util/hashutil.py index 46f361287..ebb2f12af 100644 --- a/src/allmydata/util/hashutil.py +++ b/src/allmydata/util/hashutil.py @@ -11,7 +11,9 @@ from __future__ import unicode_literals from future.utils import PY2 if PY2: # Don't import bytes to prevent leaking future's bytes. - from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, dict, list, object, range, str, max, min # noqa: F401 + from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, dict, list, object, range, str, max, min, bytes as future_bytes # noqa: F401 +else: + future_bytes = bytes from past.builtins import chr as byteschr @@ -214,7 +216,7 @@ def bucket_cancel_secret_hash(file_cancel_secret, peerid): def _xor(a, b): - return b"".join([byteschr(c ^ b) for c in a]) + return b"".join([byteschr(c ^ b) for c in future_bytes(a)]) def hmac(tag, data):