From fee687aa6611ea013a2762f9ae20ff96ead60e7b Mon Sep 17 00:00:00 2001 From: iFergal Date: Sun, 1 Sep 2024 11:33:34 +0100 Subject: [PATCH] test: ipex multisig/exn test for correct recipient of embedded ipex msgs --- src/keria/app/ipexing.py | 2 +- tests/app/test_ipexing.py | 45 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/keria/app/ipexing.py b/src/keria/app/ipexing.py index 2333f40..6c77c65 100644 --- a/src/keria/app/ipexing.py +++ b/src/keria/app/ipexing.py @@ -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)) diff --git a/tests/app/test_ipexing.py b/tests/app/test_ipexing.py index ab2f182..c45d6e8 100644 --- a/tests/app/test_ipexing.py +++ b/tests/app/test_ipexing.py @@ -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(), @@ -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) @@ -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(), @@ -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) @@ -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, @@ -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) @@ -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, @@ -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) @@ -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, @@ -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) @@ -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, @@ -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) @@ -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, @@ -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)