Skip to content

Commit

Permalink
Update references to Seq No to use hex string instead of int (#169)
Browse files Browse the repository at this point in the history
* Update references to Seq No to use hex string instead of int

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

* Unit test for query by sequence number

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

---------

Signed-off-by: pfeairheller <[email protected]>
  • Loading branch information
pfeairheller authored Jan 16, 2024
1 parent d8cb7fc commit cc3f2f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ def recur(self, tyme, deeds=None):
pre = msg["pre"]

if "sn" in msg:
seqNoDo = querying.SeqNoQuerier(hby=self.hby, hab=self.agentHab, pre=pre, sn=msg["sn"])
sn = int(msg['sn'], 16)
seqNoDo = querying.SeqNoQuerier(hby=self.hby, hab=self.agentHab, pre=pre, sn=sn)
self.extend([seqNoDo])
elif "anchor" in msg:
pass
Expand Down
5 changes: 3 additions & 2 deletions src/keria/core/longrunning.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ def status(self, op):
else:
kever = self.hby.kevers[op.oid]
if "sn" in op.metadata:
if kever.sn >= op.metadata["sn"]:
sn = int(op.metadata['sn'], 16)
if kever.sn >= sn:
operation.done = True
operation.response = asdict(kever.state())
else:
Expand All @@ -304,7 +305,7 @@ def status(self, op):
ksn = self.hby.db.ksns.get(keys=(saider.qb64,))
break

if ksn and ksn.ked['d'] == kever.serder.said:
if ksn and ksn.d == kever.serder.said:
operation.done = True
operation.response = asdict(kever.state())
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/app/test_agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def test_querier(helpers):
doist = doing.Doist(limit=1.0, tock=0.03125, real=True)
deeds = doist.enter(doers=[qry])

qry.queries.append(dict(pre="EI7AkI40M11MS7lkTCb10JC9-nDt-tXwQh44OHAFlv_9", sn=1))
qry.queries.append(dict(pre="EI7AkI40M11MS7lkTCb10JC9-nDt-tXwQh44OHAFlv_9", sn="1"))
qry.recur(1.0, deeds=deeds)

assert len(qry.doers) == 1
Expand Down
12 changes: 12 additions & 0 deletions tests/core/test_longrunning.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from keri.help import helping

from keria.app import aiding
from keri.kering import ValidationError
from keria.core import longrunning
Expand Down Expand Up @@ -156,6 +158,16 @@ def test_operations(helpers):
assert isinstance(res.json, list)
assert len(res.json) == 0

op = agent.monitor.status(
longrunning.Op(type='query', oid=recp, start=helping.nowIso8601(), metadata={'sn': '0'}))
assert op.name == f"query.{recp}"
assert op.done is True

op = agent.monitor.status(
longrunning.Op(type='query', oid=recp, start=helping.nowIso8601(), metadata={'sn': '4'}))
assert op.name == f"query.{recp}"
assert op.done is False


def test_error(helpers):
with helpers.openKeria() as (agency, agent, app, client):
Expand Down

0 comments on commit cc3f2f5

Please sign in to comment.