diff --git a/src/keri/core/serdering.py b/src/keri/core/serdering.py index 63c79bbd9..74f8d0f07 100644 --- a/src/keri/core/serdering.py +++ b/src/keri/core/serdering.py @@ -161,6 +161,14 @@ class Serder: generation and verification in addition to the required fields. Class Attributes: + Dummy (str): dummy character for computing SAIDs + Digests (dict): map of digestive codes. Should be same set of codes as + in coring.DigestCodex coring.DigDex so that .digestive property works. + Use unit tests to ensure codex sets match + Protocol (str): default protocol version type + Proto (str): default CESR protocol genus type + Vrsn (Versionage): default version + Kind (str): default serialization kind one of Serials Fields (dict): nested dict of field labels keyed by protocol, version, and message type (ilk). Felds labels are provided with a Fieldage named tuple (saids, reqs, alls) that governs field type and presence. @@ -218,7 +226,7 @@ class Serder: """ - Dummy = "#" # dummy spaceholder char for said. Must not be a valid Base64 char + Dummy = "#" # dummy spaceholder char for SAID. Must not be a valid Base64 char # should be same set of codes as in coring.DigestCodex coring.DigDex so # .digestive property works. Use unit tests to ensure codex sets match @@ -237,7 +245,7 @@ class Serder: #override in subclass to enforce specific protocol Protocol = None # required protocol, None means any in Protos is ok - Proto = Protos.keri # default protocol type + Proto = Protos.keri # default CESR protocol type Vrsn = Vrsn_1_0 # default protocol version for protocol type Kind = Serials.json # default serialization kind @@ -368,12 +376,6 @@ class Serder: } - # default ilk for each protocol at default version is zeroth ilk in dict - DefaultIlks = dict() - for key, val in Fields.items(): - DefaultIlks[key] = list(list(val.values())[0].keys()) - - def __init__(self, *, raw=b'', sad=None, strip=False, version=Version, smellage=None, verify=True, makify=False, proto=None, vrsn=None, kind=None, ilk=None, saids=None): @@ -646,19 +648,21 @@ def makify(self, sad, *, version=None, if proto is None: proto = sproto if sproto is not None else self.Proto + if proto not in self.Fields: + raise SerializeError(f"Invalid protocol type = {proto}.") + if vrsn is None: vrsn = svrsn if svrsn is not None else self.Vrsn + if vrsn not in self.Fields[proto]: + raise SerializeError(f"Invalid version = {vrsn} for protocol = {proto}.") + if kind is None: kind = skind if skind is not None else self.Kind if ilk is None: - ilk = silk if silk is not None else self.DefaultIlks[proto][0] - - - if proto not in self.Fields: - raise SerializeError(f"Invalid protocol type = {proto}.") - + ilk = (silk if silk is not None else + list(self.Fields[proto][vrsn].keys())[0]) if self.Protocol and proto != self.Protocol: raise SerializeError(f"Expected protocol = {self.Protocol}, got " diff --git a/tests/core/test_serdering.py b/tests/core/test_serdering.py index e0943ce80..72d03aea3 100644 --- a/tests/core/test_serdering.py +++ b/tests/core/test_serdering.py @@ -49,26 +49,6 @@ def test_serder(): assert Serder.Fields - # Version 1.0 ilks - assert Serder.DefaultIlks == {'KERI': ['icp', - 'rot', - 'ixn', - 'dip', - 'drt', - 'rct', - 'qry', - 'rpy', - 'pro', - 'bar', - 'exn', - 'vcp', - 'vrt', - 'iss', - 'rev', - 'bis', - 'brv'], - 'ACDC': [None]} - assert Serder.Fields[kering.Protos.acdc][kering.Vrsn_1_0][None].saids == {'d': 'E'} assert Serder.Fields[kering.Protos.acdc][kering.Vrsn_1_0][None].alls == {'v': '', 'd': '', 'i': '', 's': ''} diff --git a/tests/test_kering.py b/tests/test_kering.py index c1ad3f417..1325c3695 100644 --- a/tests/test_kering.py +++ b/tests/test_kering.py @@ -491,7 +491,7 @@ def test_ilks(): """ assert Ilks == Ilkage(icp='icp', rot='rot', ixn='ixn', dip='dip', drt='drt', rct='rct', qry='qry', rpy='rpy', - exn='exn', pro='pro', bar='bar', + xip='xip', exn='exn', pro='pro', bar='bar', vcp='vcp', vrt='vrt', iss='iss', rev='rev', bis='bis', brv='brv', )