From b95a1fc2fe8057884cdcad52ca061b119002eb71 Mon Sep 17 00:00:00 2001 From: pfeairheller Date: Wed, 6 Dec 2023 10:59:59 -0800 Subject: [PATCH] Fix reference to .saider in challenge response and add test Signed-off-by: pfeairheller --- src/keri/app/challenging.py | 5 ++--- tests/app/test_challenging.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tests/app/test_challenging.py diff --git a/src/keri/app/challenging.py b/src/keri/app/challenging.py index 0540e92a3..3845815cc 100644 --- a/src/keri/app/challenging.py +++ b/src/keri/app/challenging.py @@ -4,8 +4,7 @@ """ -from hio.base import doing -from hio.help import decking +from keri.core import coring def loadHandlers(db, signaler, exc): @@ -55,4 +54,4 @@ def handle(self, serder, attachments=None): self.signaler.push(msg, topic="/challenge") # Log signer against event to track successful challenges with signed response - self.db.reps.add(keys=(signer,), val=serder.saider) + self.db.reps.add(keys=(signer,), val=coring.Saider(qb64=serder.said)) diff --git a/tests/app/test_challenging.py b/tests/app/test_challenging.py new file mode 100644 index 000000000..c1b0f73cd --- /dev/null +++ b/tests/app/test_challenging.py @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +""" +tests.app.challenging module + +""" + +from keri.app import habbing, challenging, signaling +from keri.peer import exchanging + + +def test_challenge_handler(): + with habbing.openHab(name="test", temp=True) as (hby, hab): + + signaler = signaling.Signaler() + handler = challenging.ChallengeHandler(db=hab.db, signaler=signaler) + + payload = dict(i=hab.pre, words=["the", "test", "words", "that", "are", "not", "sufficient"]) + exn, _ = exchanging.exchange(route="/challenge/response", payload=payload, sender=hab.pre) + + handler.handle(serder=exn) + + assert len(signaler.signals) == 1 + saids = hab.db.reps.get(keys=(hab.pre,)) + + assert len(saids) == 1 + assert saids[0].qb64 == exn.said