Skip to content

Commit

Permalink
Fix for querying for AIDs (#606)
Browse files Browse the repository at this point in the history
* Fix to sequence and anchor queriers to allow for querying for an AID you've never seen before.

Signed-off-by: pfeairheller <[email protected]>

* Replace exception (that was never being caught) with a log message to indicate a missing receipt.

Signed-off-by: pfeairheller <[email protected]>

---------

Signed-off-by: pfeairheller <[email protected]>
  • Loading branch information
pfeairheller authored Nov 21, 2023
1 parent 44a1fa7 commit fb4809b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/keri/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def receipt(self, pre, sn=None):
coring.Counter(qb64b=rct, strip=True)
rcts[wit] = rct
else:
raise kering.ValidationError(f"invalid response {rep.status} from witnesses {wit}")
logger.error(f"invalid response {rep.status} from witnesses {wit}")

for wit in rcts.keys():
ewits = [w for w in rcts.keys() if w != wit]
Expand Down
6 changes: 6 additions & 0 deletions src/keri/app/querying.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def recur(self, tyme, deeds=None):
Usage:
add result of doify on this method to doers list
"""
if self.pre not in self.hab.kevers:
return False

kever = self.hab.kevers[self.pre]
if kever.sn >= self.sn:
self.remove([self.witq])
Expand All @@ -130,6 +133,9 @@ def recur(self, tyme, deeds=None):
Usage:
add result of doify on this method to doers list
"""
if self.pre not in self.hab.kevers:
return False

kever = self.hab.kevers[self.pre]
if self.hby.db.findAnchoringEvent(self.pre, anchor=self.anchor):
self.remove([self.witq])
Expand Down
3 changes: 0 additions & 3 deletions src/keri/core/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,11 +1106,8 @@ def msgParsator(self, ims=None, framed=True, pipeline=False,
exc.processEvent(tsgs=tsgs, **args)

except AttributeError as e:
print(e)
raise kering.ValidationError("No Exchange to process so dropped msg"
"= {}.".format(serder.pretty()))
except Exception as e:
print(e)

elif ilk in (Ilks.vcp, Ilks.vrt, Ilks.iss, Ilks.rev, Ilks.bis, Ilks.brv):
# TEL msg
Expand Down
57 changes: 56 additions & 1 deletion tests/app/test_querying.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from hio.base import doing

from keri.app import habbing
from keri.app.querying import QueryDoer, KeyStateNoticer, LogQuerier
from keri.app.querying import QueryDoer, KeyStateNoticer, LogQuerier, SeqNoQuerier, AnchorQuerier
from keri.core import parsing, eventing


Expand Down Expand Up @@ -86,3 +86,58 @@ def test_querying():
doist.recur(deeds=deeds)

assert qdoer.done is True

# Test sequence querier
sdoer = SeqNoQuerier(hby=hby, hab=inqHab, pre=subHab.pre, sn=5)
assert len(sdoer.witq.msgs) == 1

tock = 0.03125
limit = 1.0
doist = doing.Doist(limit=limit, tock=tock, real=True)
deeds = doist.enter(doers=[sdoer])
doist.recur(deeds=deeds)
assert len(sdoer.witq.msgs) == 0

sdoer = SeqNoQuerier(hby=hby, hab=inqHab, pre=subHab.pre, sn=1)
assert len(sdoer.witq.msgs) == 1

tock = 0.03125
limit = 1.0
doist = doing.Doist(limit=limit, tock=tock, real=True)
deeds = doist.enter(doers=[sdoer])
doist.recur(deeds=deeds)
assert len(sdoer.witq.msgs) == 1

# Test with originally unknown AID
sdoer = SeqNoQuerier(hby=hby, hab=inqHab, pre="ExxCHAI9bkl50F5SCKl2AWQbFGKeJtz0uxM2diTMxMQA", sn=1)
assert len(sdoer.witq.msgs) == 1

tock = 0.03125
limit = 1.0
doist = doing.Doist(limit=limit, tock=tock, real=True)
deeds = doist.enter(doers=[sdoer])
doist.recur(deeds=deeds)
assert len(sdoer.witq.msgs) == 1

# Test anchor querier
adoer = AnchorQuerier(hby=hby, hab=inqHab, pre=subHab.pre, anchor={'s': 5})
assert len(adoer.witq.msgs) == 1

tock = 0.03125
limit = 1.0
doist = doing.Doist(limit=limit, tock=tock, real=True)
deeds = doist.enter(doers=[adoer])
doist.recur(deeds=deeds)
assert len(sdoer.witq.msgs) == 1

# Test with originally unknown AID
adoer = AnchorQuerier(hby=hby, hab=inqHab, pre="ExxCHAI9bkl50F5SCKl2AWQbFGKeJtz0uxM2diTMxMQA", anchor={'s': 5})
assert len(adoer.witq.msgs) == 1

tock = 0.03125
limit = 1.0
doist = doing.Doist(limit=limit, tock=tock, real=True)
deeds = doist.enter(doers=[adoer])
doist.recur(deeds=deeds)
assert len(adoer.witq.msgs) == 1

0 comments on commit fb4809b

Please sign in to comment.