Skip to content

Commit ca75e74

Browse files
committed
test: make EOS vector field boundaries auditable
1 parent 5f2a962 commit ca75e74

1 file changed

Lines changed: 29 additions & 11 deletions

File tree

tests/unit/test_eos_updateauth_vector.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,36 @@
1111
pub = bytes.fromhex("037eca30dbc22ecc6d38d95a7e4b49f6b77fa87be608250319b75e2564ccb60143")
1212

1313
def name(s):
14-
alphabet='.12345abcdefghijklmnopqrstuvwxyz';value=0
15-
for x in range(13):value=(value << (5 if x<12 else 4)) | (alphabet.index(s[x]) if x<len(s) else 0)
16-
return struct.pack('<Q',value)
14+
alphabet = '.12345abcdefghijklmnopqrstuvwxyz'
15+
value = 0
16+
for x in range(13):
17+
width = 5 if x < 12 else 4
18+
symbol = alphabet.index(s[x]) if x < len(s) else 0
19+
value = (value << width) | symbol
20+
return struct.pack('<Q', value)
21+
22+
1723
def var(x):
18-
b=bytearray()
19-
while x>=128:b.append((x&127)|128);x>>=7
20-
b.append(x);return bytes(b)
21-
auth=struct.pack('<I',1)+b'\x01\x01'+pub+struct.pack('<H',1)+b'\x01'+name('memememememe')+name('active')+struct.pack('<H',1)+b'\0'
22-
prefix=name('memememememe')+name('active')+name('momomomomom')
23-
header=struct.pack('<IHI',1544644800,0,0)+b'\0\0'+var(13337)+b'\0\x01'
24-
common=name('eosio')+name('updateauth')+b'\x01'+name('eosio')+name('owner')
25-
chain=bytes.fromhex('aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906')
24+
b = bytearray()
25+
while x >= 128:
26+
b.append((x & 127) | 128)
27+
x >>= 7
28+
b.append(x)
29+
return bytes(b)
30+
31+
32+
auth = (
33+
struct.pack('<I', 1) # threshold
34+
+ b'\x01\x01' + pub + struct.pack('<H', 1) # one K1 key, weight 1
35+
+ b'\x01' + name('memememememe') + name('active')
36+
+ struct.pack('<H', 1) # one permission-level account, weight 1
37+
+ b'\0' # zero waits
38+
)
39+
prefix = name('memememememe') + name('active') + name('momomomomom')
40+
header = struct.pack('<IHI', 1544644800, 0, 0) + b'\0\0' + var(13337) + b'\0\x01'
41+
common = name('eosio') + name('updateauth') + b'\x01' + name('eosio') + name('owner')
42+
chain = bytes.fromhex('aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906')
43+
2644

2745
class UpdateAuthVector(unittest.TestCase):
2846
def test_zero_waits(self):

0 commit comments

Comments
 (0)