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

Add unit test for querying exn message with embed with attachments. #118

Merged
Merged
Changes from all commits
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
49 changes: 46 additions & 3 deletions tests/peer/test_exchanging.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

"""
import json
from pprint import pprint

from hio.base import doing
from keri.core import coring
from keri.core import coring, eventing
from keri.peer.exchanging import exchange

from keria.app import aiding
Expand Down Expand Up @@ -49,9 +50,11 @@ def test_exchange_end(helpers):
aid = op["response"]
pre = aid['i']
assert pre == "EHgwVwQT15OJvilVvW57HE4w0-GPs_Stj2OFoAHZSysY"
serder, signers = helpers.incept(salt, "signify:aid", pidx=0)
serder, sigers = helpers.incept(salt, "signify:aid", pidx=0)
assert serder.pre == pre
signer = signers[0]
signer = sigers[0]

ims = eventing.messagize(serder=serder, sigers=sigers)

salt1 = b'abcdef0123456789'
op = helpers.createAid(client, "aid2", salt1)
Expand Down Expand Up @@ -145,3 +148,43 @@ def test_exchange_end(helpers):
assert res.status_code == 200
serder = coring.Serder(ked=res.json['exn'])
assert serder.said == exn.said

payload = dict(
m="Please give me credential",
s=QVI_SAID,
a=dict(),
i=pre1
)

embeds = dict(
icp=ims,
)
exn, atc = exchange(route="/ipex/offer", payload=payload, sender=pre, embeds=embeds)
sig = signer.sign(ser=exn.raw, index=0).qb64

body = dict(
exn=exn.ked,
sigs=[sig],
atc=atc.decode("utf-8"),
rec=[pre1],
tpc="/ipex"
)

res = client.simulate_post(path="/identifiers/aid1/exchanges", json=body)
assert res.status_code == 202
assert len(agent.exchanges) == 1
assert res.json == exn.ked

doist.recur(deeds=deeds)
agent.exnseeker.index(exn.said)

body = json.dumps({'sort': ['-dt']}).encode("utf-8")
res = client.simulate_post(f"/identifiers/aid1/exchanges/query", body=body)
assert res.status_code == 200
assert len(res.json) == 3

offer = res.json[2]
assert offer['pathed'] == {'icp': '-AABADzZ23DyzL4TLQqTtjx5IKkWwRt3_NYHHIqc9g1rBjwr'}



Loading