Changeset 0b6b4b6 in trunk
- Timestamp:
- 2020-09-22T12:36:39Z (4 years ago)
- Branches:
- master
- Children:
- de48dff
- Parents:
- 58c99d0
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/test/common.py ¶
r58c99d0 r0b6b4b6 782 782 783 783 784 TEST_DATA= "\x02"*(Uploader.URI_LIT_SIZE_THRESHOLD+1)784 TEST_DATA=b"\x02"*(Uploader.URI_LIT_SIZE_THRESHOLD+1) 785 785 786 786 … … 959 959 if sharevernum == 1: 960 960 curval = struct.unpack(">L", data[0x0c+0x18:0x0c+0x18+4])[0] 961 newval = random.randrange(0, max(1, (curval/hashutil.CRYPTO_VAL_SIZE)/ 2))*hashutil.CRYPTO_VAL_SIZE961 newval = random.randrange(0, max(1, (curval/hashutil.CRYPTO_VAL_SIZE)//2))*hashutil.CRYPTO_VAL_SIZE 962 962 newvalstr = struct.pack(">L", newval) 963 963 return data[:0x0c+0x18]+newvalstr+data[0x0c+0x18+4:] 964 964 else: 965 965 curval = struct.unpack(">Q", data[0x0c+0x2c:0x0c+0x2c+8])[0] 966 newval = random.randrange(0, max(1, (curval/hashutil.CRYPTO_VAL_SIZE)/ 2))*hashutil.CRYPTO_VAL_SIZE966 newval = random.randrange(0, max(1, (curval/hashutil.CRYPTO_VAL_SIZE)//2))*hashutil.CRYPTO_VAL_SIZE 967 967 newvalstr = struct.pack(">Q", newval) 968 968 return data[:0x0c+0x2c]+newvalstr+data[0x0c+0x2c+8:] -
TabularUnified src/allmydata/test/common_util.py ¶
r58c99d0 r0b6b4b6 1 from __future__ import absolute_import 2 from __future__ import division 1 3 from __future__ import print_function 4 from __future__ import unicode_literals 5 6 from future.utils import PY2, bord, bchr, binary_type 7 if PY2: 8 from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 9 10 # XXX this is a hack that makes some tests pass on Python3, remove in the future 11 from ..scripts import runner 2 12 3 13 import os … … 10 20 from ..util.assertutil import precondition 11 21 from allmydata.util.encodingutil import get_io_encoding 12 from future.utils import PY213 if PY2: # XXX this is a hack that makes some tests pass on Python3, remove14 # in the future15 from ..scripts import runner16 22 # Imported for backwards compatibility: 17 23 from .common_py3 import ( … … 58 64 59 65 def insecurerandstr(n): 60 return ''.join(map(chr, map(randrange, [0]*n, [256]*n)))66 return b''.join(map(bchr, map(randrange, [0]*n, [256]*n))) 61 67 62 68 def flip_bit(good, which): 69 # TODO Probs need to update with bchr/bord as with flip_one_bit, below. 63 70 # flip the low-order bit of good[which] 64 71 if which == -1: … … 71 78 """ flip one random bit of the string s, in a byte greater than or equal to offset and less 72 79 than offset+size. """ 80 assert isinstance(s, binary_type) 73 81 if size is None: 74 82 size=len(s)-offset 75 83 i = randrange(offset, offset+size) 76 result = s[:i] + chr(ord(s[i])^(0x01<<randrange(0, 8))) + s[i+1:]84 result = s[:i] + bchr(bord(s[i])^(0x01<<randrange(0, 8))) + s[i+1:] 77 85 assert result != s, "Internal error -- flip_one_bit() produced the same string as its input: %s == %s" % (result, s) 78 86 return result -
TabularUnified src/allmydata/test/test_immutable.py ¶
r58c99d0 r0b6b4b6 1 """ 2 This module has been ported to Python 3. 3 """ 4 from __future__ import absolute_import 5 from __future__ import division 6 from __future__ import print_function 7 from __future__ import unicode_literals 8 9 from future.utils import PY2 10 if PY2: 11 from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 1 12 2 13 import random … … 80 91 # another share", then you lose. 81 92 82 rcap = uri.CHKFileURI( 'a'*32,'a'*32, 3, 99, 100)93 rcap = uri.CHKFileURI(b'a'*32, b'a'*32, 3, 99, 100) 83 94 vcap = rcap.get_verify_cap() 84 95 … … 89 100 def __init__(self, buckets): 90 101 self.version = { 91 'http://allmydata.org/tahoe/protocols/storage/v1': {92 "tolerates-immutable-read-overrun": True102 b'http://allmydata.org/tahoe/protocols/storage/v1': { 103 b"tolerates-immutable-read-overrun": True 93 104 } 94 105 } … … 127 138 mockserver2 = MockServer({}) 128 139 mockserver3 = MockServer({3: MockBuckets()}) 129 servers = [ NoNetworkServer( "ms1", mockserver1),130 NoNetworkServer( "ms2", mockserver2),131 NoNetworkServer( "ms3", mockserver3), ]140 servers = [ NoNetworkServer(b"ms1", mockserver1), 141 NoNetworkServer(b"ms2", mockserver2), 142 NoNetworkServer(b"ms3", mockserver3), ] 132 143 mockstoragebroker = MockStorageBroker(servers) 133 144 mockdownloadstatus = MockDownloadStatus() … … 156 167 # set their own value for happy -- the default (7) breaks stuff. 157 168 c1.encoding_params['happy'] = 1 158 d = c1.upload(Data(TEST_DATA, convergence= ""))169 d = c1.upload(Data(TEST_DATA, convergence=b"")) 159 170 def _after_upload(ur): 160 171 self.uri = ur.get_uri() … … 177 188 178 189 def _shuffled(self, num_shnums): 179 shnums = range(10)190 shnums = list(range(10)) 180 191 random.shuffle(shnums) 181 192 return shnums[:num_shnums] -
TabularUnified src/allmydata/util/_python3.py ¶
r58c99d0 r0b6b4b6 80 80 "allmydata.test.test_base62", 81 81 "allmydata.test.test_codec", 82 "allmydata.test.test_common_util", 82 83 "allmydata.test.test_configutil", 83 84 "allmydata.test.test_connection_status", … … 92 93 "allmydata.test.test_hashutil", 93 94 "allmydata.test.test_humanreadable", 95 "allmydata.test.test_immutable", 94 96 "allmydata.test.test_iputil", 95 97 "allmydata.test.test_log",
Note: See TracChangeset
for help on using the changeset viewer.