Skip to content

Commit

Permalink
added test vector for xs
Browse files Browse the repository at this point in the history
  • Loading branch information
SmithSamuelM committed Jul 27, 2024
1 parent db1ec09 commit de5c84a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
27 changes: 14 additions & 13 deletions src/keri/core/coring.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,11 +849,11 @@ class Matter:
'0G': Sizage(hs=2, ss=0, xs=0, fs=88, ls=0),
'0H': Sizage(hs=2, ss=0, xs=0, fs=8, ls=0),
'0I': Sizage(hs=2, ss=0, xs=0, fs=88, ls=0),
'0J': Sizage(hs=2, ss=2, xs=0, fs=4, ls=0),
'0J': Sizage(hs=2, ss=2, xs=1, fs=4, ls=0),
'0K': Sizage(hs=2, ss=2, xs=0, fs=4, ls=0),
'0L': Sizage(hs=2, ss=6, xs=0, fs=8, ls=0),
'0L': Sizage(hs=2, ss=6, xs=1, fs=8, ls=0),
'0M': Sizage(hs=2, ss=6, xs=0, fs=8, ls=0),
'0N': Sizage(hs=2, ss=10, xs=0, fs=12, ls=0),
'0N': Sizage(hs=2, ss=10, xs=1, fs=12, ls=0),
'0O': Sizage(hs=2, ss=10, xs=0, fs=12, ls=0),
'1AAA': Sizage(hs=4, ss=0, xs=0, fs=48, ls=0),
'1AAB': Sizage(hs=4, ss=0, xs=0, fs=48, ls=0),
Expand All @@ -871,7 +871,7 @@ class Matter:
'1AAN': Sizage(hs=4, ss=8, xs=0, fs=12, ls=0),
'1__-': Sizage(hs=4, ss=2, xs=0, fs=12, ls=0),
'1___': Sizage(hs=4, ss=0, xs=0, fs=8, ls=0),
'2__-': Sizage(hs=4, ss=2, xs=0, fs=12, ls=1),
'2__-': Sizage(hs=4, ss=2, xs=1, fs=12, ls=1),
'2___': Sizage(hs=4, ss=0, xs=0, fs=8, ls=1),
'3__-': Sizage(hs=4, ss=2, xs=0, fs=12, ls=2),
'3___': Sizage(hs=4, ss=0, xs=0, fs=8, ls=2),
Expand Down Expand Up @@ -2164,10 +2164,11 @@ def __init__(self, tag='', soft='', code=None, **kwa):
if l > len(codes):
raise InvalidSoftError("Oversized tag={soft}.")
code = codes[l-1] # get code for for tag of len where (index = len - 1)
if code in PadTagDex:
soft = self.Pad + tag # pre pad for those that need it
else:
soft = tag
#if code in PadTagDex:
#soft = self.Pad + tag # pre pad for those that need it
#else:
#soft = tag
soft = tag


super(Tagger, self).__init__(soft=soft, code=code, **kwa)
Expand All @@ -2182,11 +2183,11 @@ def tag(self):
"""
tag = self.soft
if self.code in PadTagDex:
pad = self.soft[0]
tag = self.soft[1:]
if pad != self.Pad:
raise InvalidSoftError("Invaid pre {pad=} for {tag=}.")
#if self.code in PadTagDex:
#pad = self.soft[0]
#tag = self.soft[1:]
#if pad != self.Pad:
#raise InvalidSoftError("Invaid pre {pad=} for {tag=}.")

return tag

Expand Down
31 changes: 15 additions & 16 deletions tests/core/test_coring.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,11 @@ def test_matter_class():
'0G': Sizage(hs=2, ss=0, xs=0, fs=88, ls=0),
'0H': Sizage(hs=2, ss=0, xs=0, fs=8, ls=0),
'0I': Sizage(hs=2, ss=0, xs=0, fs=88, ls=0),
'0J': Sizage(hs=2, ss=2, xs=0, fs=4, ls=0),
'0J': Sizage(hs=2, ss=2, xs=1, fs=4, ls=0),
'0K': Sizage(hs=2, ss=2, xs=0, fs=4, ls=0),
'0L': Sizage(hs=2, ss=6, xs=0, fs=8, ls=0),
'0L': Sizage(hs=2, ss=6, xs=1, fs=8, ls=0),
'0M': Sizage(hs=2, ss=6, xs=0, fs=8, ls=0),
'0N': Sizage(hs=2, ss=10, xs=0, fs=12, ls=0),
'0N': Sizage(hs=2, ss=10, xs=1, fs=12, ls=0),
'0O': Sizage(hs=2, ss=10, xs=0, fs=12, ls=0),
'1AAA': Sizage(hs=4, ss=0, xs=0, fs=48, ls=0),
'1AAB': Sizage(hs=4, ss=0, xs=0, fs=48, ls=0),
Expand All @@ -471,7 +471,7 @@ def test_matter_class():
'1AAN': Sizage(hs=4, ss=8, xs=0, fs=12, ls=0),
'1__-': Sizage(hs=4, ss=2, xs=0, fs=12, ls=0),
'1___': Sizage(hs=4, ss=0, xs=0, fs=8, ls=0),
'2__-': Sizage(hs=4, ss=2, xs=0, fs=12, ls=1),
'2__-': Sizage(hs=4, ss=2, xs=1, fs=12, ls=1),
'2___': Sizage(hs=4, ss=0, xs=0, fs=8, ls=1),
'3__-': Sizage(hs=4, ss=2, xs=0, fs=12, ls=2),
'3___': Sizage(hs=4, ss=0, xs=0, fs=8, ls=2),
Expand Down Expand Up @@ -1985,7 +1985,7 @@ def test_matter_special():

# Test TBD0S '1__-'
# soft special but valid non-empty raw as part of primitive
code = MtrDex.TBD0S # sizes '1__-': Sizage(hs=4, ss=2, fs=12, ls=0),
code = MtrDex.TBD0S # sizes '1__-': Sizage(hs=4, ss=2, xs=0, fs=12, ls=0),
rs = Matter._rawSize(code) # raw size
soft = 'TG'
qb64 = '1__-TGB1dnd4'
Expand Down Expand Up @@ -2046,11 +2046,11 @@ def test_matter_special():

# Test TBD1S '2__-'
# soft special but valid non-empty raw as part of primitive
code = MtrDex.TBD1S # sizes '2__-': Sizage(hs=4, ss=2, fs=12, ls=1),
code = MtrDex.TBD1S # sizes '2__-': Sizage(hs=4, ss=2, xs=1, fs=12, ls=1),
rs = Matter._rawSize(code) # raw size
soft = 'TG'
qb64 = '2__-TGAAdXZ3' # see lead byte
qb2 = b'\xdb\xff\xfeL`\x00uvw'
soft = 'T'
qb64 = '2__-_TAAdXZ3' # see prepad and see lead byte
qb2 = b'\xdb\xff\xfe\xfd0\x00uvw'
raw = b'uvw'

assert rs == 3
Expand Down Expand Up @@ -2087,8 +2087,8 @@ def test_matter_special():

# Same as above but raw all zeros

qb64 = '2__-TGAAAAAA'
qb2 = b'\xdb\xff\xfeL`\x00\x00\x00\x00'
qb64 = '2__-_TAAAAAA'
qb2 = b'\xdb\xff\xfe\xfd0\x00\x00\x00\x00'
raw = b'\x00\x00\x00'

assert rs == 3
Expand Down Expand Up @@ -3367,15 +3367,14 @@ def test_tagger():
# Tag1
tag = 'v'
code = MtrDex.Tag1
soft = '_v'
qb64 = '0J_v'
qb64b = qb64.encode("utf-8")
qb2 = decodeB64(qb64b)
raw = b''

tagger = Tagger(tag=tag) # defaults
assert tagger.code == tagger.hard == code
assert tagger.soft == soft
assert tagger.soft == tag
assert tagger.raw == raw
assert tagger.qb64 == qb64
assert tagger.qb2 == qb2
Expand All @@ -3385,7 +3384,7 @@ def test_tagger():

tagger = Tagger(qb2=qb2)
assert tagger.code == tagger.hard == code
assert tagger.soft == soft
assert tagger.soft == tag
assert tagger.raw == raw
assert tagger.qb64 == qb64
assert tagger.qb2 == qb2
Expand All @@ -3395,7 +3394,7 @@ def test_tagger():

tagger = Tagger(qb64=qb64)
assert tagger.code == tagger.hard == code
assert tagger.soft == soft
assert tagger.soft == tag
assert tagger.raw == raw
assert tagger.qb64 == qb64
assert tagger.qb2 == qb2
Expand All @@ -3405,7 +3404,7 @@ def test_tagger():

tagger = Tagger(qb64b=qb64b)
assert tagger.code == tagger.hard == code
assert tagger.soft == soft
assert tagger.soft == tag
assert tagger.raw == raw
assert tagger.qb64 == qb64
assert tagger.qb2 == qb2
Expand Down

0 comments on commit de5c84a

Please sign in to comment.