I should prefer testing before pushing

This commit is contained in:
Peter D. Gray 2025-03-14 12:02:13 -04:00
parent ffda830f66
commit e06449f59f
No known key found for this signature in database
GPG Key ID: A2DCD558C2BE5D7C
2 changed files with 6 additions and 14 deletions

View File

@ -59,13 +59,13 @@ def deser_compact_size(f):
nit = struct.unpack("<B", f.read(1))[0]
if nit == 253:
nit = struct.unpack("<H", f.read(2))[0]
assert nit > 253
assert nit >= 253
elif nit == 254:
nit = struct.unpack("<I", f.read(4))[0]
assert nit > 0x1_0000
assert nit >= 0x1_0000
elif nit == 255:
nit = struct.unpack("<Q", f.read(8))[0]
assert nit > 0x1_0000_0000
assert nit >= 0x1_0000_0000
return nit
def deser_string(f):

View File

@ -33,7 +33,6 @@ V = range(1, 16)
for i, v1 in enumerate(V):
for j in range(i+1, len(V)):
M, N = v1, V[j]
print(M, N)
# number of pubkeys times 1 pushdata + 33 pubkey = 34 * N
# +1 M
# +1 N
@ -43,18 +42,11 @@ for i, v1 in enumerate(V):
assert vec == deser_string_vector(BytesIO(ser_string_vector(vec)))
for i in [253, 0x10000, 0x100000000, 0x10000000000000000]:
for i in [253, 0x10000, 0x100000000]:
for j in [-1, 0, 1]:
num = i + j
if i == 0x10000000000000000 and (j != -1):
try:
ser_compact_size(num)
raise RuntimeError
except AssertionError:
continue
else:
x = ser_compact_size(num)
x = ser_compact_size(num)
assert num == deser_compact_size(BytesIO(x))
# EOF
# EOF