Skip to content

Commit

Permalink
feat: expose inception dts in hab info (#335)
Browse files Browse the repository at this point in the history
* feat: expose inception dts in hab info

* test: validate dt format
  • Loading branch information
iFergal authored Dec 10, 2024
1 parent 638f626 commit b04d4fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/keria/app/aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
from keri import core
from keri.app import habbing
from keri.app.keeping import Algos
from keri.core import coring, serdering
from keri.core.coring import Ilks
from keri.core import coring, serdering, eventing
from keri.db import dbing
from keri.help import ogler
from mnemonic import mnemonic
Expand Down Expand Up @@ -1000,6 +999,8 @@ def info(hab, rm, full=False):
if isinstance(hab, habbing.SignifyGroupHab):
data["group"]["mhab"] = info(hab.mhab, rm, full)

data["icp_dt"] = bytes(hab.db.getDts(eventing.dgKey(hab.pre, hab.pre))).decode("utf-8")

if hab.accepted and full:
kever = hab.kevers[hab.pre]
data["transferable"] = kever.transferable
Expand Down
9 changes: 9 additions & 0 deletions tests/app/test_aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import json
import os
import pytest
from datetime import datetime

import falcon
from falcon import testing
Expand Down Expand Up @@ -1624,6 +1625,9 @@ def test_rotation(helpers):
assert aid["name"] == "aid1"
assert aid["prefix"] == "EHgwVwQT15OJvilVvW57HE4w0-GPs_Stj2OFoAHZSysY"

icp_dt = aid["icp_dt"]
datetime.fromisoformat(icp_dt) # will raise an error if the format is not a valid iso dt

serder2, signers2 = helpers.incept(salt, "signify:aid", pidx=1, count=3)
sigers2 = [signer.sign(ser=serder2.raw, index=0).qb64 for signer in signers2]

Expand Down Expand Up @@ -1716,6 +1720,11 @@ def test_rotation(helpers):
assert res.json['done'] is True

res = client.simulate_get(path=f"/identifiers/{aid1['name']}")
assert res.status_code == 200

# Ensure rotation doesn't change dt
assert res.json["icp_dt"] == icp_dt

mhab = res.json
agent0 = mhab["state"]

Expand Down

0 comments on commit b04d4fe

Please sign in to comment.