From 6d0a836682cda10098e5fc4546a39faca0b9b478 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Sat, 16 Dec 2023 16:35:00 -0700 Subject: [PATCH 1/2] removed digers and digs so all consistent with ndigers and ndigs and ntholder --- src/keri/app/cli/commands/multisig/rotate.py | 4 +- src/keri/app/habbing.py | 8 ++-- src/keri/core/eventing.py | 26 ++++++------ src/keri/core/serdering.py | 26 +----------- src/keri/db/basing.py | 2 +- tests/app/test_grouping.py | 44 ++++++++++---------- tests/app/test_signify.py | 4 +- tests/core/test_eventing.py | 28 ++++++------- tests/db/test_basing.py | 2 +- 9 files changed, 61 insertions(+), 83 deletions(-) diff --git a/src/keri/app/cli/commands/multisig/rotate.py b/src/keri/app/cli/commands/multisig/rotate.py index 04fcc3056..668a78267 100644 --- a/src/keri/app/cli/commands/multisig/rotate.py +++ b/src/keri/app/cli/commands/multisig/rotate.py @@ -176,7 +176,7 @@ def rotateDo(self, tymth, tock=0.0, **opts): raise kering.ConfigurationError(f"unknown rotation member {mid}") mkever = self.hby.kevers[mid] # get key state for given member - migers.append(mkever.digers[0]) + migers.append(mkever.ndigers[0]) rmids.append(mid) case [mid, sn]: @@ -192,7 +192,7 @@ def rotateDo(self, tymth, tock=0.0, **opts): if not serder.estive: raise kering.ConfigurationError(f"invalid event {sn} for rotation member {mid}") - migers.append(serder.digers[0]) + migers.append(serder.ndigers[0]) rmids.append(mid) case _: diff --git a/src/keri/app/habbing.py b/src/keri/app/habbing.py index 7a76fa8df..73ac47bea 100644 --- a/src/keri/app/habbing.py +++ b/src/keri/app/habbing.py @@ -713,7 +713,7 @@ def extractMerfersMigers(self, smids, rmids=None): for mid in rmids: kever = self.kevers[mid] - digers = kever.digers + digers = kever.ndigers if digers: # abandoned id may have empty next digers migers.append(digers[0]) if len(digers) > 1: @@ -1231,7 +1231,7 @@ def rotate(self, *, verfers=None, digers=None, isith=None, nsith=None, toad=None keys = [verfer.qb64 for verfer in verfers] indices = [] - for idx, diger in enumerate(kever.digers): + for idx, diger in enumerate(kever.ndigers): pdigs = [coring.Diger(ser=verfer.qb64b, code=diger.code).qb64 for verfer in verfers] if diger.qb64 in pdigs: indices.append(idx) @@ -2329,7 +2329,7 @@ def rotate(self, *, isith=None, nsith=None, ncount=None, toad=None, cuts=None, a kever = self.kever # before rotation kever is prior next if ncount is None: - ncount = len(kever.digers) # use len of prior next digers as default + ncount = len(kever.ndigers) # use len of prior next digers as default try: verfers, digers = self.mgr.replay(pre=self.pre) @@ -2804,7 +2804,7 @@ def sign(self, ser, verfers=None, indexed=True, rotated=False, indices=None, ond migers = self.mhab.kever.fetchPriorDigers(sn=sn - 1) if migers: # not None or not empty mig = migers[0].qb64 # always use first prior dig of mhab - digs = [diger.qb64 for diger in self.kever.digers] # group habs prior digs + digs = [diger.qb64 for diger in self.kever.ndigers] # group habs prior digs try: pni = digs.index(mig) # find mhab dig index in group hab digs except ValueError: # not found diff --git a/src/keri/core/eventing.py b/src/keri/core/eventing.py index 85b45f4ea..3aa549668 100644 --- a/src/keri/core/eventing.py +++ b/src/keri/core/eventing.py @@ -1580,7 +1580,7 @@ class Kever: ilk (str): from Ilks for current event type tholder (Tholder): instance for event signing threshold verfers (list): of Verfer instances for current event state set of signing keys - digers (list): of Diger instances for current event state set of + ndigers (list): of Diger instances for current event state set of next (rotation) key digests ntholder (Tholder): instance for next (rotation) threshold from serder.ntholder @@ -1602,7 +1602,7 @@ class Kever: Properties: sn (int): sequence number property that returns .sner.num fn (int): first seen ordinal number property the returns .fner.num - digs (list): of digests qb64 of .digers + ndigs (list): of digests qb64 of .digers kevers (dict): reference to self.db.kevers transferable (bool): True if .digers is not empty and pre is transferable @@ -1745,12 +1745,12 @@ def fn(self): @property - def digs(self): + def ndigs(self): """ Returns: (list): digs of digers """ - return [diger.qb64 for diger in self.digers] + return [diger.qb64 for diger in self.ndigers] @property @@ -1769,7 +1769,7 @@ def transferable(self): and .nextor is not None False otherwise """ - return True if self.digers and self.prefixer.transferable else False + return True if self.ndigers and self.prefixer.transferable else False def reload(self, state): @@ -1789,7 +1789,7 @@ def reload(self, state): self.tholder = Tholder(sith=state.kt) self.ntholder = Tholder(sith=state.nt) self.verfers = [Verfer(qb64=key) for key in state.k] - self.digers = [Diger(qb64=dig) for dig in state.n] + self.ndigers = [Diger(qb64=dig) for dig in state.n] self.toader = Number(numh=state.bt) # auto converts from hex num self.wits = state.b self.cuts = state.ee.br @@ -1856,7 +1856,7 @@ def incept(self, serder, estOnly=None): raise ValidationError("Invalid inception nxt not empty for " "non-transferable prefix = {} for evt = {}." "".format(self.prefixer.qb64, ked)) - self.digers = serder.digers + self.ndigers = serder.ndigers self.ntholder = serder.ntholder self.cuts = [] # always empty at inception since no prev event @@ -2020,7 +2020,7 @@ def update(self, serder, sigers, wigers=None, delseqner=None, delsaider=None, self.ilk = ilk self.tholder = tholder self.verfers = serder.verfers - self.digers = serder.digers + self.ndigers = serder.ndigers self.ntholder = serder.ntholder self.toader = toader @@ -2156,7 +2156,7 @@ def rotate(self, serder, sner): "".format(dig, self.serder.said, ked)) # check derivation code of pre for non-transferable - if not self.digers: # prior next list is empty so rotations not allowed + if not self.ndigers: # prior next list is empty so rotations not allowed raise ValidationError("Attempted rotation for nontransferable" " prefix = {} for evt = {}." "".format(self.prefixer.qb64, ked)) @@ -2342,7 +2342,7 @@ def exposeds(self, sigers): odxs = [] for siger in sigers: try: - diger = self.digers[siger.ondex] + diger = self.ndigers[siger.ondex] except TypeError as ex: # ondex may be None continue except IndexError as ex: @@ -2500,7 +2500,7 @@ def logEvent(self, serder, sigers=None, wigers=None, wits=None, first=False, val = (coring.Prefixer(qb64b=serder.preb), coring.Seqner(sn=serder.sn)) for verfer in (serder.verfers if serder.verfers is not None else []): self.db.pubs.add(keys=(verfer.qb64,), val=val) - for diger in (serder.digers if serder.digers is not None else []): + for diger in (serder.ndigers if serder.ndigers is not None else []): self.db.digs.add(keys=(diger.qb64,), val=val) if first: # append event dig to first seen database in order if seqner and saider: # authorized delegated or issued event @@ -2622,7 +2622,7 @@ def state(self): eevt=eevt, sith=self.tholder.sith, nsith=self.ntholder.sith if self.ntholder else '0', - ndigs=[diger.qb64 for diger in self.digers], + ndigs=[diger.qb64 for diger in self.ndigers], toad=self.toader.num, wits=self.wits, cnfg=cnfg, @@ -2661,7 +2661,7 @@ def fetchPriorDigers(self, sn: int | None = None) -> list | None: raw = self.db.getEvt(dgkey) serder = serdering.SerderKERI(raw=bytes(raw)) if serder.estive: # establishment event - return serder.digers + return serder.ndigers return None diff --git a/src/keri/core/serdering.py b/src/keri/core/serdering.py index 945751dc7..88f5335ae 100644 --- a/src/keri/core/serdering.py +++ b/src/keri/core/serdering.py @@ -1267,16 +1267,6 @@ def ndigs(self): return self._sad.get("n") - - @property - def digs(self): - """ - Returns: - (list): digs - """ - return self.ndigs - - @property def ndigers(self): """NDigers property getter @@ -1292,18 +1282,6 @@ def ndigers(self): return [Diger(qb64=dig) for dig in digs] if digs is not None else None - @property - def digers(self): - """Digers property getter, alias of .ndigers - - Returns: - digers (list[Diger]): instance as converted from ._sad['n']. - One for each next key digests. - """ - return self.ndigers - - - @property def bner(self): """ @@ -1657,7 +1635,7 @@ def edge(self): Returns: edge (dict | str): from ._sad["e"] """ - return self._sad.get("e") or {} + return self._sad.get("e") or {} # need to fix logic so can remove or since optional @property @@ -1667,6 +1645,6 @@ def rule(self): Returns: rule (dict | str): from ._sad["r"] """ - return self._sad.get("r") or {} + return self._sad.get("r") or {} # need to fix logic so can remove or since optional # ToDo Schemer property getter. Schemer object diff --git a/src/keri/db/basing.py b/src/keri/db/basing.py index 96ba3053e..3a52e7d0e 100644 --- a/src/keri/db/basing.py +++ b/src/keri/db/basing.py @@ -1380,7 +1380,7 @@ def rotationMembers(self, pre: str): return members kever = self.kevers[pre] - for diger in kever.digers: + for diger in kever.ndigers: if (couples := self.digs.get(keys=(diger.qb64,))) is None: continue diff --git a/tests/app/test_grouping.py b/tests/app/test_grouping.py index 5337fe780..5df6a805b 100644 --- a/tests/app/test_grouping.py +++ b/tests/app/test_grouping.py @@ -81,7 +81,7 @@ def test_counselor(): hab1.rotate() hab2.rotate() merfers = [hab1.kever.verfers[0], hab2.kever.verfers[0]] - migers = [hab1.kever.digers[0], hab2.kever.digers[0]] + migers = [hab1.kever.ndigers[0], hab2.kever.ndigers[0]] prefixer = coring.Prefixer(qb64=ghab.pre) seqner = coring.Seqner(sn=ghab.kever.sn + 1) rot = ghab.rotate(isith="2", nsith="2", toad=0, cuts=list(), adds=list(), verfers=merfers, digers=migers) @@ -126,17 +126,17 @@ def test_counselor(): # Validate successful partial rotation nkeys = [hab1.kever.verfers[0].qb64, hab2.kever.verfers[0].qb64] - ndigs = [hab1.kever.digers[0].qb64, hab2.kever.digers[0].qb64] + ndigs = [hab1.kever.ndigers[0].qb64, hab2.kever.ndigers[0].qb64] assert ghab.kever.sn == 1 assert [verfer.qb64 for verfer in ghab.kever.verfers] == nkeys - assert [diger.qb64 for diger in ghab.kever.digers] == ndigs + assert [diger.qb64 for diger in ghab.kever.ndigers] == ndigs # Second Partial Rotation hab1.rotate() hab2.rotate() merfers = [hab1.kever.verfers[0], hab2.kever.verfers[0]] - migers = [hab1.kever.digers[0], hab2.kever.digers[0], hab3.kever.digers[0]] + migers = [hab1.kever.ndigers[0], hab2.kever.ndigers[0], hab3.kever.ndigers[0]] prefixer = coring.Prefixer(qb64=ghab.pre) seqner = coring.Seqner(sn=ghab.kever.sn + 1) rot = ghab.rotate(isith="2", nsith="2", toad=0, cuts=list(), adds=list(), verfers=merfers, digers=migers) @@ -183,16 +183,16 @@ def test_counselor(): # Validate successful partial rotation nkeys = [hab1.kever.verfers[0].qb64, hab2.kever.verfers[0].qb64] - ndigs = [hab1.kever.digers[0].qb64, hab2.kever.digers[0].qb64, hab3.kever.digers[0].qb64] + ndigs = [hab1.kever.ndigers[0].qb64, hab2.kever.ndigers[0].qb64, hab3.kever.ndigers[0].qb64] assert ghab.kever.sn == 2 assert [verfer.qb64 for verfer in ghab.kever.verfers] == nkeys - assert [diger.qb64 for diger in ghab.kever.digers] == ndigs + assert [diger.qb64 for diger in ghab.kever.ndigers] == ndigs # Third Partial Rotation with Recovery hab1.rotate() hab3.rotate() merfers = [hab1.kever.verfers[0], hab3.kever.verfers[0]] - migers = [hab1.kever.digers[0], hab3.kever.digers[0]] + migers = [hab1.kever.ndigers[0], hab3.kever.ndigers[0]] prefixer = coring.Prefixer(qb64=ghab.pre) seqner = coring.Seqner(sn=ghab.kever.sn + 1) rot = ghab.rotate(isith="2", nsith="2", toad=0, cuts=list(), adds=list(), verfers=merfers, digers=migers) @@ -372,8 +372,8 @@ def test_the_seven(): hab2.rotate() hab3.rotate() merfers = [hab1.kever.verfers[0], hab2.kever.verfers[0], hab3.kever.verfers[0]] - migers = [hab1.kever.digers[0], hab2.kever.digers[0], hab3.kever.digers[0], hab4.kever.digers[0], - hab5.kever.digers[0], hab6.kever.digers[0], hab7.kever.digers[0]] + migers = [hab1.kever.ndigers[0], hab2.kever.ndigers[0], hab3.kever.ndigers[0], hab4.kever.ndigers[0], + hab5.kever.ndigers[0], hab6.kever.ndigers[0], hab7.kever.ndigers[0]] prefixer = coring.Prefixer(qb64=ghab.pre) seqner = coring.Seqner(sn=ghab.kever.sn + 1) rot = ghab.rotate(isith='["1/3", "1/3", "1/3"]', nsith='["1/3", "1/3", "1/3", "1/3", "1/3", "1/3", "1/3"]', @@ -424,20 +424,20 @@ def test_the_seven(): assert counselor.complete(prefixer=prefixer, seqner=seqner, saider=saider) # Validate successful partial rotation nkeys = [hab1.kever.verfers[0].qb64, hab2.kever.verfers[0].qb64, hab3.kever.verfers[0].qb64] - ndigs = [hab1.kever.digers[0].qb64, hab2.kever.digers[0].qb64, hab3.kever.digers[0].qb64, - hab4.kever.digers[0].qb64, hab5.kever.digers[0].qb64, hab6.kever.digers[0].qb64, - hab7.kever.digers[0].qb64] + ndigs = [hab1.kever.ndigers[0].qb64, hab2.kever.ndigers[0].qb64, hab3.kever.ndigers[0].qb64, + hab4.kever.ndigers[0].qb64, hab5.kever.ndigers[0].qb64, hab6.kever.ndigers[0].qb64, + hab7.kever.ndigers[0].qb64] assert ghab.kever.sn == 1 assert [verfer.qb64 for verfer in ghab.kever.verfers] == nkeys - assert [diger.qb64 for diger in ghab.kever.digers] == ndigs + assert [diger.qb64 for diger in ghab.kever.ndigers] == ndigs # Second Partial Rotation hab1.rotate() hab2.rotate() hab3.rotate() merfers = [hab1.kever.verfers[0], hab2.kever.verfers[0], hab3.kever.verfers[0]] - migers = [hab1.kever.digers[0], hab2.kever.digers[0], hab3.kever.digers[0], hab4.kever.digers[0], - hab5.kever.digers[0], hab6.kever.digers[0], hab7.kever.digers[0]] + migers = [hab1.kever.ndigers[0], hab2.kever.ndigers[0], hab3.kever.ndigers[0], hab4.kever.ndigers[0], + hab5.kever.ndigers[0], hab6.kever.ndigers[0], hab7.kever.ndigers[0]] prefixer = coring.Prefixer(qb64=ghab.pre) seqner = coring.Seqner(sn=ghab.kever.sn + 1) rot = ghab.rotate(isith='["1/3", "1/3", "1/3"]', nsith='["1/3", "1/3", "1/3", "1/3", "1/3", "1/3", "1/3"]', @@ -489,13 +489,13 @@ def test_the_seven(): assert counselor.complete(prefixer=prefixer, seqner=seqner, saider=saider) # Validate successful partial rotation nkeys = [hab1.kever.verfers[0].qb64, hab2.kever.verfers[0].qb64, hab3.kever.verfers[0].qb64] - ndigs = [hab1.kever.digers[0].qb64, hab2.kever.digers[0].qb64, hab3.kever.digers[0].qb64, - hab4.kever.digers[0].qb64, hab5.kever.digers[0].qb64, hab6.kever.digers[0].qb64, - hab7.kever.digers[0].qb64] + ndigs = [hab1.kever.ndigers[0].qb64, hab2.kever.ndigers[0].qb64, hab3.kever.ndigers[0].qb64, + hab4.kever.ndigers[0].qb64, hab5.kever.ndigers[0].qb64, hab6.kever.ndigers[0].qb64, + hab7.kever.ndigers[0].qb64] assert ghab.kever.sn == 2 assert [verfer.qb64 for verfer in ghab.kever.verfers] == nkeys - assert [diger.qb64 for diger in ghab.kever.digers] == ndigs + assert [diger.qb64 for diger in ghab.kever.ndigers] == ndigs # Third Partial Rotation with Recovery (using 4 members not involved in previous rotations) # First we have to do a replay of all multisig AID and member AID events and get members 4 - 7 up to date @@ -516,7 +516,7 @@ def test_the_seven(): hab5.rotate() hab6.rotate() merfers = [hab4.kever.verfers[0], hab5.kever.verfers[0], hab6.kever.verfers[0]] - migers = [hab4.kever.digers[0], hab5.kever.digers[0], hab6.kever.digers[0]] + migers = [hab4.kever.ndigers[0], hab5.kever.ndigers[0], hab6.kever.ndigers[0]] prefixer = coring.Prefixer(qb64=ghab.pre) seqner = coring.Seqner(sn=ghab.kever.sn + 1) rot = ghab4.rotate(isith='["1/3", "1/3", "1/3"]', nsith='["1/3", "1/3", "1/3"]', @@ -565,10 +565,10 @@ def test_the_seven(): # Validate successful partial rotation nkeys = [hab4.kever.verfers[0].qb64, hab5.kever.verfers[0].qb64, hab6.kever.verfers[0].qb64] - ndigs = [hab4.kever.digers[0].qb64, hab5.kever.digers[0].qb64, hab6.kever.digers[0].qb64] + ndigs = [hab4.kever.ndigers[0].qb64, hab5.kever.ndigers[0].qb64, hab6.kever.ndigers[0].qb64] assert ghab4.kever.sn == 3 assert [verfer.qb64 for verfer in ghab4.kever.verfers] == nkeys - assert [diger.qb64 for diger in ghab4.kever.digers] == ndigs + assert [diger.qb64 for diger in ghab4.kever.ndigers] == ndigs @contextmanager diff --git a/tests/app/test_signify.py b/tests/app/test_signify.py index 0fe7eda58..4afaa4647 100644 --- a/tests/app/test_signify.py +++ b/tests/app/test_signify.py @@ -69,7 +69,7 @@ def test_remote_salty_hab(): assert kever.serder.said == lhab.kever.serder.said assert kever.ilk == coring.Ilks.icp assert [verfer.qb64 for verfer in kever.verfers] == keys - assert [diger.qb64 for diger in kever.digers] == nxt + assert [diger.qb64 for diger in kever.ndigers] == nxt habord = remote.db.habs.get(name) assert habord.hid == "EHeU-ldGfJhxceV9BTq38HdFUoasoWEcYATiyZCcDH7N" @@ -111,7 +111,7 @@ def test_remote_salty_hab(): assert kever.serder.said == lhab.kever.serder.said assert kever.ilk == coring.Ilks.rot assert [verfer.qb64 for verfer in kever.verfers] == keys1 - assert [diger.qb64 for diger in kever.digers] == nxt1 + assert [diger.qb64 for diger in kever.ndigers] == nxt1 habord = remote.db.habs.get(name) assert habord.hid == "EHeU-ldGfJhxceV9BTq38HdFUoasoWEcYATiyZCcDH7N" diff --git a/tests/core/test_eventing.py b/tests/core/test_eventing.py index 14426dc91..20cb09cd2 100644 --- a/tests/core/test_eventing.py +++ b/tests/core/test_eventing.py @@ -2122,7 +2122,7 @@ def test_kever(mockHelpingNowUTC): assert kever.sner.num == 0 assert kever.sn == kever.sner.num # sn property assert [verfer.qb64 for verfer in kever.verfers] == [skp0.verfer.qb64] - assert kever.digs == nxt + assert kever.ndigs == nxt state = kever.db.states.get(keys=kever.prefixer.qb64) assert state.s == kever.sner.numh == '0' feqner = kever.db.fons.get(keys=(kever.prefixer.qb64, kever.serder.said)) @@ -2161,7 +2161,7 @@ def test_kever(mockHelpingNowUTC): digers.reverse() - kever.digers = digers # Monkey patch for test + kever.ndigers = digers # Monkey patch for test ondices = kever.exposeds(sigers=sigers) assert ondices ==[2, 1, 0] @@ -2180,7 +2180,7 @@ def test_kever(mockHelpingNowUTC): sigers = [siger0, siger1, siger2] digers = [diger0, diger1] - kever.digers = digers # Monkey patch for test + kever.ndigers = digers # Monkey patch for test ondices = kever.exposeds(sigers=sigers) assert ondices ==[0, 1] @@ -2200,7 +2200,7 @@ def test_kever(mockHelpingNowUTC): sigers = [siger0, siger1, siger2] digers = [diger0, diger1] - kever.digers = digers # Monkey patch for test + kever.ndigers = digers # Monkey patch for test ondices = kever.exposeds(sigers=sigers) assert ondices ==[1] @@ -2490,7 +2490,7 @@ def test_keyeventsequence_0(): assert kever.ilk == Ilks.icp assert kever.tholder.thold == 1 assert [verfer.qb64 for verfer in kever.verfers] == keys0 - assert kever.digs == nxt1 + assert kever.ndigs == nxt1 assert kever.estOnly is False assert kever.transferable is True @@ -2522,7 +2522,7 @@ def test_keyeventsequence_0(): assert kever.serder.said == serder1.said assert kever.ilk == Ilks.rot assert [verfer.qb64 for verfer in kever.verfers] == keys1 - assert kever.digs == nxt2 + assert kever.ndigs == nxt2 pigers = kever.fetchPriorDigers() # digs from inception before rotation assert pigers is not None @@ -2552,7 +2552,7 @@ def test_keyeventsequence_0(): assert kever.serder.said == serder2.said assert kever.ilk == Ilks.rot assert [verfer.qb64 for verfer in kever.verfers] == keys2 - assert kever.digs == nxt3 + assert kever.ndigs == nxt3 pigers = kever.fetchPriorDigers() # digs from rotation before rotation assert pigers is not None @@ -2575,7 +2575,7 @@ def test_keyeventsequence_0(): assert kever.serder.said == serder3.said assert kever.ilk == Ilks.ixn assert [verfer.qb64 for verfer in kever.verfers] == keys2 # no change - assert kever.digs == nxt3 # no change + assert kever.ndigs == nxt3 # no change pigers = kever.fetchPriorDigers() assert pigers is not None @@ -2598,7 +2598,7 @@ def test_keyeventsequence_0(): assert kever.serder.said == serder4.said assert kever.ilk == Ilks.ixn assert [verfer.qb64 for verfer in kever.verfers] == keys2 # no change - assert kever.digs == nxt3 # no change + assert kever.ndigs == nxt3 # no change pigers = kever.fetchPriorDigers() # digs from rot before rot before ixn ixn assert pigers is not None @@ -2627,7 +2627,7 @@ def test_keyeventsequence_0(): assert kever.serder.said == serder5.said assert kever.ilk == Ilks.rot assert [verfer.qb64 for verfer in kever.verfers] == keys3 - assert kever.digs == nxt4 + assert kever.ndigs == nxt4 pigers = kever.fetchPriorDigers() # digs from rot before ixn ixn before rot assert pigers is not None @@ -2650,7 +2650,7 @@ def test_keyeventsequence_0(): assert kever.serder.said == serder6.said assert kever.ilk == Ilks.ixn assert [verfer.qb64 for verfer in kever.verfers] == keys3 # no change - assert kever.digs == nxt4 # no change + assert kever.ndigs == nxt4 # no change # Event 7 Rotation to null NonTransferable Abandon serder7 = rotate(pre=pre, keys=keys4, dig=serder6.said, sn=7) @@ -2671,7 +2671,7 @@ def test_keyeventsequence_0(): assert kever.serder.said == serder7.said assert kever.ilk == Ilks.rot assert [verfer.qb64 for verfer in kever.verfers] == keys4 - assert kever.digs == [] + assert kever.ndigs == [] assert not kever.transferable # Event 8 Interaction @@ -2760,7 +2760,7 @@ def test_keyeventsequence_1(): assert kever.ilk == Ilks.icp assert kever.tholder.thold == 1 assert [verfer.qb64 for verfer in kever.verfers] == keys0 - assert kever.digs == nxt1 + assert kever.ndigs == nxt1 assert kever.estOnly is True assert kever.transferable is True @@ -2799,7 +2799,7 @@ def test_keyeventsequence_1(): assert kever.serder.said == serder2.said assert kever.ilk == Ilks.rot assert [verfer.qb64 for verfer in kever.verfers] == keys1 - assert kever.digs == nxt2 + assert kever.ndigs == nxt2 db_digs = [bytes(val).decode("utf-8") for val in kever.db.getKelIter(pre)] assert db_digs == event_digs diff --git a/tests/db/test_basing.py b/tests/db/test_basing.py index 8b74ca45f..e25d4b60f 100644 --- a/tests/db/test_basing.py +++ b/tests/db/test_basing.py @@ -1741,7 +1741,7 @@ def test_clean_baser(): dig=natHab.kever.serder.said, sn=natHab.kever.sn+1, isith='2', - ndigs=[diger.qb64 for diger in natHab.kever.digers]) + ndigs=[diger.qb64 for diger in natHab.kever.ndigers]) fn, dts = natHab.kever.logEvent(serder=badsrdr, first=True) natHab.db.states.pin(keys=natHab.pre, val=datify(KeyStateRecord, From a237e3542f6403362a3308f7ec5ab6c5845a6916 Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Sat, 16 Dec 2023 16:54:13 -0700 Subject: [PATCH 2/2] reverted SerderACDC so missing top level field properties return None when missing. Fixes logic to account for None --- src/keri/app/cli/commands/vc/export.py | 4 ++-- src/keri/core/serdering.py | 33 ++++++++++++++------------ src/keri/vdr/verifying.py | 2 +- src/keri/vdr/viring.py | 4 ++-- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/keri/app/cli/commands/vc/export.py b/src/keri/app/cli/commands/vc/export.py index 6f361d8a2..92a561cac 100644 --- a/src/keri/app/cli/commands/vc/export.py +++ b/src/keri/app/cli/commands/vc/export.py @@ -43,7 +43,7 @@ def export_credentials(args): """ tels = args.tels kels = args.kels - chains = args.edge + chains = args.edge if args.edge is not None else {} if args.full: tels = kels = chains = True @@ -108,7 +108,7 @@ def outputCred(self, said): self.outputTEL(creder.said) if self.chains: - chains = creder.edge + chains = creder.edge if creder.edge is not None else {} saids = [] for key, source in chains.items(): if key == 'd': diff --git a/src/keri/core/serdering.py b/src/keri/core/serdering.py index 88f5335ae..1bc5a0f1a 100644 --- a/src/keri/core/serdering.py +++ b/src/keri/core/serdering.py @@ -1520,7 +1520,7 @@ def _verify(self, **kwa): @property def uuid(self): """uuid property getter - + Optional fields return None when not present Returns: uuid (str | None): qb64 of .sad["u"] salty nonce """ @@ -1530,7 +1530,7 @@ def uuid(self): @property def uuidb(self): """uuid property getter (uuid bytes) - + Optional fields return None when not present Returns: uuidb (bytes | None): qb64b of .sad["u"] salty nonce as bytes """ @@ -1540,7 +1540,7 @@ def uuidb(self): @property def issuer(self): """issuer property getter (issuer AID) - + Optional fields return None when not present Returns: issuer (str | None): qb64 of .sad["i"] issuer AID """ @@ -1550,7 +1550,7 @@ def issuer(self): @property def issuerb(self): """issuerb property getter (issuer AID bytes) - + Optional fields return None when not present Returns: issuerb (bytes | None): qb64b of .issuer AID as bytes """ @@ -1560,7 +1560,7 @@ def issuerb(self): @property def regi(self): """regi property getter (registry identifier SAID) - + Optional fields return None when not present Returns: regi (str | None): qb64 of .sad["ri"] registry SAID """ @@ -1570,6 +1570,7 @@ def regi(self): @property def regib(self): """regib property getter (registry identifier SAID bytes) + Optional fields return None when not present Returns: regib (bytes | None): qb64b of .issuer AID as bytes """ @@ -1579,7 +1580,7 @@ def regib(self): @property def schema(self): """schema block or SAID property getter - + Optional fields return None when not present Returns: schema (dict | str | None): from ._sad["s"] """ @@ -1589,7 +1590,7 @@ def schema(self): @property def attrib(self): """attrib block or SAID property getter (attribute) - + Optional fields return None when not present Returns: attrib (dict | str | None): from ._sad["a"] """ @@ -1599,7 +1600,7 @@ def attrib(self): @property def issuee(self): """ise property getter (issuee AID) - + Optional fields return None when not present Returns: issuee (str | None): qb64 of .sad["a"]["i"] issuee AID """ @@ -1612,6 +1613,7 @@ def issuee(self): @property def issueeb(self): """isrb property getter (issuee AID bytes) + Optional fields return None when not present Returns: issueeb (bytes | None): qb64b of .issuee AID as bytes """ @@ -1620,8 +1622,8 @@ def issueeb(self): @property def attagg(self): - """attagg block property getter (attribute aggregate) - + """Attagg block property getter (attribute aggregate) + Optional fields return None when not present Returns: attagg (dict | str): from ._sad["A"] """ @@ -1630,21 +1632,22 @@ def attagg(self): @property def edge(self): - """edge block property getter - + """Edge block property getter + Optional fields return None when not present Returns: edge (dict | str): from ._sad["e"] """ - return self._sad.get("e") or {} # need to fix logic so can remove or since optional + return self._sad.get("e") @property def rule(self): - """rule block property getter + """Rule block property getter + Optional fields return None when not present Returns: rule (dict | str): from ._sad["r"] """ - return self._sad.get("r") or {} # need to fix logic so can remove or since optional + return self._sad.get("r") # or {} # need to fix logic so can remove or since optional # ToDo Schemer property getter. Schemer object diff --git a/src/keri/vdr/verifying.py b/src/keri/vdr/verifying.py index 5d8a61a5c..870e50f0c 100644 --- a/src/keri/vdr/verifying.py +++ b/src/keri/vdr/verifying.py @@ -102,7 +102,7 @@ def processCredential(self, creder, prefixer, seqner, saider): regk = creder.regi vcid = creder.said schema = creder.schema - prov = creder.edge + prov = creder.edge if creder.edge is not None else {} if regk not in self.tevers: # registry event not found yet if self.escrowMRE(creder, prefixer, seqner, saider): diff --git a/src/keri/vdr/viring.py b/src/keri/vdr/viring.py index f55925634..4f60e9e6c 100644 --- a/src/keri/vdr/viring.py +++ b/src/keri/vdr/viring.py @@ -409,7 +409,7 @@ def cloneCreds(self, saids, db): del iss[0:iserder.size] chainSaids = [] - for k, p in creder.edge.items(): + for k, p in (creder.edge.items() if creder.edge is not None else {}): if k == "d": continue @@ -558,7 +558,7 @@ def sources(self, db, creder): list: credential sources as resolved from `e` in creder.crd """ - chains = creder.edge + chains = creder.edge if creder.edge is not None else {} saids = [] for key, source in chains.items(): if key == 'd':