Skip to content

Commit

Permalink
test: ipex multisig/exn test for correct recipient of embedded ipex m…
Browse files Browse the repository at this point in the history
…sgs (#288)
  • Loading branch information
iFergal committed Sep 2, 2024
1 parent 70209b2 commit 5e91152
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/keria/app/ipexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def sendMultisigExn(agent, hab, ked, sigs, atc, rec):
serder = serdering.SerderKERI(sad=admitked)
ims = bytearray(serder.raw) + pathed['exn']
agent.hby.psr.parseOne(ims=ims)
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=[grant.ked['i']], topic="credential"))
agent.exchanges.append(dict(said=serder.said, pre=hab.pre, rec=[admitked['a']['i']], topic="credential"))
agent.admits.append(dict(said=admitked['d'], pre=hab.pre))

return agent.monitor.submit(serder.pre, longrunning.OpTypes.exchange, metadata=dict(said=serder.said))
Expand Down
45 changes: 42 additions & 3 deletions tests/app/test_ipexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,11 @@ def test_multisig(seeder, helpers):

data = json.dumps(body).encode("utf-8")
res = client0.simulate_post(path="/identifiers/issuer/ipex/grant", body=data)

assert res.status_code == 200

agent0.exchanges.popleft() # The multisig/exn
assert agent0.exchanges.popleft()["rec"][0] == holderPre # The grant

# Package up the GRANT into a multisig/exn from participant 1 to send to participant 0
multiExnSerder, end = exchanging.exchange(route="/multisig/exn",
payload=dict(),
Expand All @@ -945,6 +947,9 @@ def test_multisig(seeder, helpers):
res = client1.simulate_post(path="/identifiers/issuer/ipex/grant", body=data)
assert res.status_code == 200

agent1.exchanges.popleft() # The multisig/exn
assert agent1.exchanges.popleft()["rec"][0] == holderPre # The grant

# Wait until the GRANT has been persisted by Agent0
while agent0.exc.complete(said=grantSerder.said) is not True:
doist.recur(deeds=deeds)
Expand Down Expand Up @@ -996,9 +1001,11 @@ def test_multisig(seeder, helpers):

data = json.dumps(body).encode("utf-8")
res = hclient0.simulate_post(path="/identifiers/holder/ipex/admit", body=data)

assert res.status_code == 200

hagent0.exchanges.popleft() # The multisig/exn
assert hagent0.exchanges.popleft()["rec"][0] == issuerPre # The admit

# Package up the ADMIT into a multisig/exn from participant 1 to send to participant 0
multiExnSerder, end = exchanging.exchange(route="/multisig/exn",
payload=dict(),
Expand All @@ -1017,6 +1024,9 @@ def test_multisig(seeder, helpers):
res = hclient1.simulate_post(path="/identifiers/holder/ipex/admit", body=data)
assert res.status_code == 200

hagent1.exchanges.popleft() # The multisig/exn
assert hagent1.exchanges.popleft()["rec"][0] == issuerPre # The admit

# Wait until the ADMIT has been persisted by Hagent0
while hagent0.exc.complete(said=admitSerder.said) is not True:
doist.recur(deeds=deeds)
Expand Down Expand Up @@ -1073,6 +1083,9 @@ def test_multisig(seeder, helpers):
res = vclient0.simulate_post(path="/identifiers/verifier/ipex/apply", body=data)
assert res.status_code == 200

vagent0.exchanges.popleft() # The multisig/exn
assert vagent0.exchanges.popleft()["rec"][0] == holderPre # The apply

multiExnSerder1, end = exchanging.exchange(route="/multisig/exn",
payload=dict(),
sender=vpre1,
Expand All @@ -1090,6 +1103,9 @@ def test_multisig(seeder, helpers):
res = vclient1.simulate_post(path="/identifiers/verifier/ipex/apply", body=data)
assert res.status_code == 200

vagent1.exchanges.popleft() # The multisig/exn
assert vagent1.exchanges.popleft()["rec"][0] == holderPre # The apply

while vagent0.exc.complete(said=applySerder.said) is not True:
doist.recur(deeds=deeds)

Expand Down Expand Up @@ -1138,6 +1154,9 @@ def test_multisig(seeder, helpers):
res = hclient0.simulate_post(path="/identifiers/holder/ipex/offer", body=data)
assert res.status_code == 200

hagent0.exchanges.popleft() # The multisig/exn
assert hagent0.exchanges.popleft()["rec"][0] == verifierPre # The offer

multiExnSerder1, end = exchanging.exchange(route="/multisig/exn",
payload=dict(),
sender=hpre1,
Expand All @@ -1155,6 +1174,9 @@ def test_multisig(seeder, helpers):
res = hclient1.simulate_post(path="/identifiers/holder/ipex/offer", body=data)
assert res.status_code == 200

hagent1.exchanges.popleft() # The multisig/exn
assert hagent1.exchanges.popleft()["rec"][0] == verifierPre # The offer

while hagent0.exc.complete(said=offerSerder.said) is not True:
doist.recur(deeds=deeds)

Expand Down Expand Up @@ -1202,6 +1224,9 @@ def test_multisig(seeder, helpers):
res = vclient0.simulate_post(path="/identifiers/verifier/ipex/agree", body=data)
assert res.status_code == 200

vagent0.exchanges.popleft() # The multisig/exn
assert vagent0.exchanges.popleft()["rec"][0] == holderPre # The agree

multiExnSerder1, end = exchanging.exchange(route="/multisig/exn",
payload=dict(),
sender=vpre1,
Expand All @@ -1219,6 +1244,9 @@ def test_multisig(seeder, helpers):
res = vclient1.simulate_post(path="/identifiers/verifier/ipex/agree", body=data)
assert res.status_code == 200

vagent1.exchanges.popleft() # The multisig/exn
assert vagent1.exchanges.popleft()["rec"][0] == holderPre # The agree

while vagent0.exc.complete(said=agreeSerder.said) is not True:
doist.recur(deeds=deeds)

Expand Down Expand Up @@ -1271,9 +1299,11 @@ def test_multisig(seeder, helpers):

data = json.dumps(body).encode("utf-8")
res = hclient0.simulate_post(path="/identifiers/holder/ipex/grant", body=data)

assert res.status_code == 200

hagent0.exchanges.popleft() # The multisig/exn
assert hagent0.exchanges.popleft()["rec"][0] == verifierPre # The grant

multiExnSerder1, end = exchanging.exchange(route="/multisig/exn",
payload=dict(),
sender=hpre1,
Expand All @@ -1291,6 +1321,9 @@ def test_multisig(seeder, helpers):
res = hclient1.simulate_post(path="/identifiers/holder/ipex/grant", body=data)
assert res.status_code == 200

hagent1.exchanges.popleft() # The multisig/exn
assert hagent1.exchanges.popleft()["rec"][0] == verifierPre # The grant

while hagent0.exc.complete(said=grantSerder.said) is not True:
doist.recur(deeds=deeds)

Expand Down Expand Up @@ -1337,6 +1370,9 @@ def test_multisig(seeder, helpers):
res = vclient0.simulate_post(path="/identifiers/verifier/ipex/admit", body=data)
assert res.status_code == 200

vagent0.exchanges.popleft() # The multisig/exn
assert vagent0.exchanges.popleft()["rec"][0] == holderPre # The admit

multiExnSerder1, end = exchanging.exchange(route="/multisig/exn",
payload=dict(),
sender=vpre1,
Expand All @@ -1354,6 +1390,9 @@ def test_multisig(seeder, helpers):
res = vclient1.simulate_post(path="/identifiers/verifier/ipex/admit", body=data)
assert res.status_code == 200

vagent1.exchanges.popleft() # The multisig/exn
assert vagent1.exchanges.popleft()["rec"][0] == holderPre # The admit

while vagent0.exc.complete(said=admitSerder.said) is not True:
doist.recur(deeds=deeds)

Expand Down

0 comments on commit 5e91152

Please sign in to comment.