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

test coverage for reply escrow #818

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
74 changes: 74 additions & 0 deletions scripts/demo/basic/keri/mutlisig-end-role-assignment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# WITNESSES
# To run the following scripts, open another console window and run:
# $ kli witness demo

# mutlisig1 EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4
# multisig2 EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1

kli init --name multisig1 --base "${KERI_TEMP_DIR}" --salt 0ACDEyMzQ1Njc4OWxtbm9aBc --nopasscode --config-dir ${KERI_SCRIPT_DIR} --config-file demo-witness-oobis
kli incept --name multisig1 --base "${KERI_TEMP_DIR}" --alias multisig1 --file ${KERI_DEMO_SCRIPT_DIR}/data/multisig-1-sample.json
# kli ends add --name multisig1 --base "${KERI_TEMP_DIR}" --alias multisig1 --eid BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM --role mailbox

kli init --name multisig2 --base "${KERI_TEMP_DIR}" --salt 0ACDEyMzQ1Njc4OWdoaWpsaw --nopasscode --config-dir ${KERI_SCRIPT_DIR} --config-file demo-witness-oobis
kli incept --name multisig2 --base "${KERI_TEMP_DIR}" --alias multisig2 --file ${KERI_DEMO_SCRIPT_DIR}/data/multisig-2-sample.json
# kli ends add --name multisig2 --base "${KERI_TEMP_DIR}" --alias multisig2 --eid BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX --role mailbox

kli oobi resolve --name multisig1 --base "${KERI_TEMP_DIR}" --oobi-alias multisig2 --oobi http://127.0.0.1:5642/oobi/EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1
kli oobi resolve --name multisig2 --base "${KERI_TEMP_DIR}" --oobi-alias multisig1 --oobi http://127.0.0.1:5642/oobi/EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4

# Follow commands run in parallel
kli multisig incept --name multisig1 --base "${KERI_TEMP_DIR}" --alias multisig1 --group multisig --file ${KERI_DEMO_SCRIPT_DIR}/data/multisig-sample.json &
pid=$!
PID_LIST+=" $pid"
kli multisig incept --name multisig2 --base "${KERI_TEMP_DIR}" --alias multisig2 --group multisig --file ${KERI_DEMO_SCRIPT_DIR}/data/multisig-sample.json &
pid=$!
PID_LIST+=" $pid"

wait $PID_LIST

kli status --name multisig1 --base "${KERI_TEMP_DIR}" --alias multisig

TIME=$(date -Iseconds -u | sed 's/+00:00//').000000+00:00
echo "TIME: ${TIME}"
echo "ADDING AGENTS"
kli ends add --base "${KERI_TEMP_DIR}" --name multisig1 --alias multisig --eid BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM --role agent --time "${TIME}" &
pid=$!
PID_LIST="$pid"

kli ends add --base "${KERI_TEMP_DIR}" --name multisig2 --alias multisig --eid BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM --role agent --time "${TIME}" &
pid=$!
PID_LIST+=" $pid"

wait $PID_LIST

## Rotate multisig keys:
kli rotate --name multisig1 --alias multisig1 --base "${KERI_TEMP_DIR}"
kli query --name multisig2 --alias multisig2 --base "${KERI_TEMP_DIR}" --prefix EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4
kli rotate --name multisig2 --alias multisig2 --base "${KERI_TEMP_DIR}"
kli query --name multisig1 --alias multisig1 --base "${KERI_TEMP_DIR}" --prefix EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1

kli multisig rotate --name multisig1 --alias multisig --base "${KERI_TEMP_DIR}" --smids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4 --smids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1 --isith '["1/2", "1/2"]' --nsith '["1/2", "1/2"]' --rmids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4 --rmids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1 &
pid=$!
PID_LIST+=" $pid"

kli multisig rotate --name multisig2 --alias multisig --base "${KERI_TEMP_DIR}" --smids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4 --smids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1 --isith '["1/2", "1/2"]' --nsith '["1/2", "1/2"]' --rmids EKYLUMmNPZeEs77Zvclf0bSN5IN-mLfLpx2ySb-HDlk4 --rmids EJccSRTfXYF6wrUVuenAIHzwcx3hJugeiJsEKmndi5q1 &
pid=$!
PID_LIST+=" $pid"

wait $PID_LIST

kli ends add --base "${KERI_TEMP_DIR}" --name multisig1 --alias multisig --eid BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM --role agent --time "${TIME}" &
pid=$!
PID_LIST="$pid"

kli ends add --base "${KERI_TEMP_DIR}" --name multisig2 --alias multisig --eid BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM --role agent --time "${TIME}" &
pid=$!
PID_LIST+=" $pid"

wait $PID_LIST

kli oobi resolve --name multisig1 --base "${KERI_TEMP_DIR}" --oobi-alias multisig --oobi http://127.0.0.1:5642/oobi/EC61gZ9lCKmHAS7U5ehUfEbGId5rcY0D7MirFZHDQcE2

echo "Test Complete"
87 changes: 87 additions & 0 deletions tests/app/test_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from keri.vdr import eventing as veventing
from keri.db import dbing
from keri.peer import exchanging
from keri.kering import Roles


def test_counselor():
Expand Down Expand Up @@ -806,3 +807,89 @@ def test_multisig_interact_handler(mockHelpingNowUTC):
prefixers = hby1.db.maids.get(keys=(esaid,))
assert len(prefixers) == 1
assert prefixers[0].qb64 == ghab2.mhab.pre

def test_multisig_reply(mockHelpingNowUTC):
with openMultiSig(prefix="test") as ((hby1, ghab1), (hby2, ghab2), (hby3, ghab3)):
assert ghab1.pre == "EERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSRskH3BZZiy"
assert ghab2.pre == "EERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSRskH3BZZiy"
assert ghab3.pre == "EERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSRskH3BZZiy"

assert ghab3.kever.tholder.thold == 3

eid = "EDF8o6SK-s2jxUVnlGtqAVtXTF-wyZ26c0dUsS5p766q"
msg = ghab1.makeEndRole(eid, role=Roles.agent)
assert msg == (b'{"v":"KERI10JSON000111_","t":"rpy","d":"EDRqljKSfw4948zVq-NJ16kP'
b'jnrQl6YKLloSDR_mSGZ1","dt":"2021-01-01T00:00:00.000000+00:00","r'
b'":"/end/role/add","a":{"cid":"EERn_laF0qwP8zTBGL86LbF84J0Yh2IvQS'
b'RskH3BZZiy","role":"agent","eid":"EDF8o6SK-s2jxUVnlGtqAVtXTF-wyZ'
b'26c0dUsS5p766q"}}-VA0-FABEERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSRskH3'
b'BZZiy0AAAAAAAAAAAAAAAAAAAAAAAEERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSR'
b'skH3BZZiy-AABBADkAXvMC0F0kPDahcMVlzbcMhWi96vSjPMsx17MESoy4TzZfNp'
b'WGDjm8fcyhe5Nh_Eqc6-jLI0tvQfAUgp2HHEB')

ghab1.psr.parseOne(ims=bytes(msg))
serder = serdering.SerderKERI(raw=bytes(msg))

route = "/end/role"
assert ghab1.db.sdts.get(keys=(serder.said,)).dts == "2021-01-01T00:00:00.000000+00:00"
assert ghab1.db.rpys.get(keys=(serder.said,)).said == serder.said
assert ghab1.db.rpes.get(keys=(route,))[0].qb64 == serder.said

msg = ghab2.makeEndRole(eid, role=Roles.agent)
assert msg == (b'{"v":"KERI10JSON000111_","t":"rpy","d":"EDRqljKSfw4948zVq-NJ16kP'
b'jnrQl6YKLloSDR_mSGZ1","dt":"2021-01-01T00:00:00.000000+00:00","r'
b'":"/end/role/add","a":{"cid":"EERn_laF0qwP8zTBGL86LbF84J0Yh2IvQS'
b'RskH3BZZiy","role":"agent","eid":"EDF8o6SK-s2jxUVnlGtqAVtXTF-wyZ'
b'26c0dUsS5p766q"}}-VA0-FABEERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSRskH3'
b'BZZiy0AAAAAAAAAAAAAAAAAAAAAAAEERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSR'
b'skH3BZZiy-AABBBDcXYcNf6xrJX0ziLLMzuNpBN-kubJv9ZjdUCYwZIaqG8RWcy3'
b'Lv0897bSiGuam6Yh1bxmg9lxwwdYVWqIvagUL')

ghab1.psr.parseOne(ims=bytes(msg))

endRole = ghab1.loadEndRole(cid=ghab1.pre, eid=eid, role=Roles.agent)
assert len(endRole) == 0

msg = ghab3.makeEndRole(eid, role=Roles.agent)
assert msg == (b'{"v":"KERI10JSON000111_","t":"rpy","d":"EDRqljKSfw4948zVq-NJ16kP'
b'jnrQl6YKLloSDR_mSGZ1","dt":"2021-01-01T00:00:00.000000+00:00","r'
b'":"/end/role/add","a":{"cid":"EERn_laF0qwP8zTBGL86LbF84J0Yh2IvQS'
b'RskH3BZZiy","role":"agent","eid":"EDF8o6SK-s2jxUVnlGtqAVtXTF-wyZ'
b'26c0dUsS5p766q"}}-VA0-FABEERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSRskH3'
b'BZZiy0AAAAAAAAAAAAAAAAAAAAAAAEERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSR'
b'skH3BZZiy-AABBCBR-YODIoQxmoCbageJFteUXJS5-18SpKbC8vIyuLAbKrv2Wg1'
b'lUpXbaRaejCfknSZSRtfvTB4T_SBKC3KU8YkD')
ghab1.psr.parseOne(ims=bytes(msg))

assert ghab1.db.rpes.get(keys=(route,))[0].qb64 == serder.said

ghab1.psr.rvy.processEscrowReply()

assert len(ghab1.db.rpes.get(keys=(route,))) == 0
endRole = ghab1.loadEndRole(cid=ghab1.pre, eid=eid, role=Roles.agent)
assert endRole == (b'{"v":"KERI10JSON000111_","t":"rpy","d":"EDRqljKSfw4948zVq-NJ16kP'
b'jnrQl6YKLloSDR_mSGZ1","dt":"2021-01-01T00:00:00.000000+00:00","r'
b'":"/end/role/add","a":{"cid":"EERn_laF0qwP8zTBGL86LbF84J0Yh2IvQS'
b'RskH3BZZiy","role":"agent","eid":"EDF8o6SK-s2jxUVnlGtqAVtXTF-wyZ'
b'26c0dUsS5p766q"}}-VBg-FABEERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSRskH3'
b'BZZiy0AAAAAAAAAAAAAAAAAAAAAAAEERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSR'
b'skH3BZZiy-AADBADkAXvMC0F0kPDahcMVlzbcMhWi96vSjPMsx17MESoy4TzZfNp'
b'WGDjm8fcyhe5Nh_Eqc6-jLI0tvQfAUgp2HHEBBBDcXYcNf6xrJX0ziLLMzuNpBN-'
b'kubJv9ZjdUCYwZIaqG8RWcy3Lv0897bSiGuam6Yh1bxmg9lxwwdYVWqIvagULBCB'
b'R-YODIoQxmoCbageJFteUXJS5-18SpKbC8vIyuLAbKrv2Wg1lUpXbaRaejCfknSZ'
b'SRtfvTB4T_SBKC3KU8YkD')

ghab1.psr.parseOne(ims=bytes(msg))
ghab1.psr.rvy.processEscrowReply()
endRole = ghab1.loadEndRole(cid=ghab1.pre, eid=eid, role=Roles.agent)
assert endRole == (b'{"v":"KERI10JSON000111_","t":"rpy","d":"EDRqljKSfw4948zVq-NJ16kP'
b'jnrQl6YKLloSDR_mSGZ1","dt":"2021-01-01T00:00:00.000000+00:00","r'
b'":"/end/role/add","a":{"cid":"EERn_laF0qwP8zTBGL86LbF84J0Yh2IvQS'
b'RskH3BZZiy","role":"agent","eid":"EDF8o6SK-s2jxUVnlGtqAVtXTF-wyZ'
b'26c0dUsS5p766q"}}-VBg-FABEERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSRskH3'
b'BZZiy0AAAAAAAAAAAAAAAAAAAAAAAEERn_laF0qwP8zTBGL86LbF84J0Yh2IvQSR'
b'skH3BZZiy-AADBADkAXvMC0F0kPDahcMVlzbcMhWi96vSjPMsx17MESoy4TzZfNp'
b'WGDjm8fcyhe5Nh_Eqc6-jLI0tvQfAUgp2HHEBBBDcXYcNf6xrJX0ziLLMzuNpBN-'
b'kubJv9ZjdUCYwZIaqG8RWcy3Lv0897bSiGuam6Yh1bxmg9lxwwdYVWqIvagULBCB'
b'R-YODIoQxmoCbageJFteUXJS5-18SpKbC8vIyuLAbKrv2Wg1lUpXbaRaejCfknSZ'
b'SRtfvTB4T_SBKC3KU8YkD')
Loading