Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for querying for AIDs #606

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Loading