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

Fix/test del rot multisig more #267

Merged
merged 51 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
532d5b6
testing delegation and deployed services
2byrds May 29, 2024
50c5fd6
tested delegation endpoint
2byrds Jun 4, 2024
17037bc
successful single and multisig delegation
2byrds Jun 6, 2024
a6b77c8
fixed local test-setup run with latest keria
2byrds Jun 6, 2024
931c934
fixed salty log event ked/serder creation
2byrds Jun 8, 2024
b1db802
with keripy multiplexor parser using local=True, getting to delegatee…
2byrds Jun 11, 2024
1b86f43
small salty test fixes and updates del-multisig to notify
2byrds Jun 13, 2024
493eb6c
fixes for keripy/keria updates to exn w/ rp field
2byrds Jun 13, 2024
df700ac
del multisig w/o witnesses success
2byrds Jun 13, 2024
2cf38cf
added back witnesses for delegated multisig successful integration test
2byrds Jun 13, 2024
6ead09e
multisig-vlei-issuance successful integration test
2byrds Jun 13, 2024
badc2b4
updated digest in test per Serder changes
2byrds Jun 14, 2024
2c889ea
revert local test changes
2byrds Jun 14, 2024
619e76b
remove comments, etc
2byrds Jun 14, 2024
d6062c8
small fix depending on env
2byrds Jun 14, 2024
d8fb5b9
prettier
2byrds Jun 14, 2024
23158fa
making multisig methods available for other tests
2byrds Jun 14, 2024
aa6ca23
fix docker digest
2byrds Jun 14, 2024
eda9bad
fix docker keria health check
2byrds Jun 14, 2024
b7de398
prettier and audit fix
2byrds Jun 14, 2024
ba44f33
some test utility consolidation but a new issue should be created
2byrds Jun 14, 2024
c5968a8
prettier
2byrds Jun 14, 2024
63c473d
fix syntax
2byrds Jun 14, 2024
723c60a
prettier
2byrds Jun 16, 2024
aed163c
Fix naming
2byrds Jun 17, 2024
4bb8503
prettier
2byrds Jun 17, 2024
44d9078
Merge branch 'WebOfTrust:main' into fix/test_del_rot_multisig_more
2byrds Jun 21, 2024
d3def41
updated docker-compose.yaml with entrypoint override for keria
2byrds Jun 22, 2024
444a6f7
restoring original keria docker-compose version string
2byrds Jul 16, 2024
139d028
simplify admitSingleSig call
2byrds Jul 16, 2024
19240dd
bump version to 0.3.0 to signal breaking change with previous 0.1.x k…
2byrds Jul 16, 2024
e884277
fixed ixn url
2byrds Jul 16, 2024
3368475
merged latest
2byrds Jul 16, 2024
545abe5
prettier
2byrds Jul 16, 2024
d467f59
fix npm audit issue with mermaid-js with override
2byrds Jul 16, 2024
114a2b1
restore eslint, etc
2byrds Jul 16, 2024
76fd97d
using constants
2byrds Jul 17, 2024
682ebcc
revert package-lock.json to original with minimal audit fixes
2byrds Jul 17, 2024
bd43e40
specify the keria version
2byrds Jul 17, 2024
8b6acf8
adding test coverage for delegation approval
2byrds Jul 17, 2024
8600ead
unit test coverage for delegation approval
2byrds Jul 17, 2024
cd5325f
prettier
2byrds Jul 17, 2024
edf3012
reverting to 127.0.0.1 oobis for test value in local mode
2byrds Jul 26, 2024
80cc196
per review, delegating test - remove credential related code
2byrds Jul 26, 2024
f6c7696
per review, added check of body for delegation approval
2byrds Jul 26, 2024
de4a29d
per review, removing comments
2byrds Jul 26, 2024
af3bffa
per review, avoid testing changing id
2byrds Jul 26, 2024
4e067a7
per review, fixing warnings in delegation test
2byrds Jul 26, 2024
830728b
per review, consolidated waitAndMarkNotification functions
2byrds Jul 26, 2024
5841484
prettier
2byrds Jul 26, 2024
fe262d4
small fixes from checks
2byrds Jul 26, 2024
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
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
- 7723:7723

keria:
image: ${KERIA_IMAGE:-weboftrust/keria}:${KERIA_IMAGE_TAG:-latest}
image: 2byrds/keria
2byrds marked this conversation as resolved.
Show resolved Hide resolved
environment:
- KERI_AGENT_CORS=1
- KERI_URL=http://keria:3902
Expand All @@ -44,7 +44,7 @@ services:
- --name
- agent
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:3902/spec.yaml']
test: ['CMD', 'wget', '--spider', 'http://keria:3902/spec.yaml']
2byrds marked this conversation as resolved.
Show resolved Hide resolved
interval: 2s
timeout: 3s
retries: 5
Expand Down
326 changes: 251 additions & 75 deletions examples/integration-scripts/delegation-multisig.test.ts
Original file line number Diff line number Diff line change
@@ -1,113 +1,289 @@
import { strict as assert } from 'assert';
import signify from 'signify-ts';
import signify, { Operation } from 'signify-ts';

Check warning on line 2 in examples/integration-scripts/delegation-multisig.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'Operation' is defined but never used

Check warning on line 2 in examples/integration-scripts/delegation-multisig.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'Operation' is defined but never used

Check warning on line 2 in examples/integration-scripts/delegation-multisig.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'Operation' is defined but never used

Check warning on line 2 in examples/integration-scripts/delegation-multisig.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'Operation' is defined but never used
import {
assertNotifications,
assertOperations,
createTimestamp,
markAndRemoveNotification,
resolveOobi,
waitForNotifications,
waitOperation,
warnNotifications,
} from './utils/test-util';
import { getOrCreateClient, getOrCreateIdentifier } from './utils/test-setup';
import {
getOrCreateClient,
getOrCreateContact,
getOrCreateIdentifier,
} from './utils/test-setup';
import {
acceptMultisigIncept,
addEndRoleMultisig,
delegateMultisig,
startMultisigIncept,
waitAndMarkNotification,
} from './utils/multisig-utils';
import { step } from './utils/test-step';

const gtor = 'gtor';
2byrds marked this conversation as resolved.
Show resolved Hide resolved
const gtee = 'gtee';
const tor1 = 'tor1';
const tor2 = 'tor2';
const tee1 = 'tee1';
const tee2 = 'tee2';

const RETRY_DEFAULTS = {
maxSleep: 10000,
minSleep: 1000,
maxRetries: 10,
timeout: 30000,
};

test('delegation-multisig', async () => {
await signify.ready();
// Boot three clients
const [client0, client1, client2] = await Promise.all([
getOrCreateClient(),
getOrCreateClient(),
getOrCreateClient(),
]);
const [ctor1, ctor2, ctee1, ctee2] = await step(
2byrds marked this conversation as resolved.
Show resolved Hide resolved
'Creating single sig clients',
async () => {
return await Promise.all([
getOrCreateClient(),
getOrCreateClient(),
getOrCreateClient(),
getOrCreateClient(),
]);
}
);

// Create four identifiers, one for each client
const [aid0, aid1, aid2] = await Promise.all([
createAID(client0, 'delegator'),
createAID(client1, 'member1'),
createAID(client2, 'member2'),
]);
// Create delegator and delegatee identifiers clients
const [ator1, ator2, atee1, atee2] = await step(
'Creating single sig aids',
async () => {
return await Promise.all([
createAID(ctor1, tor1),
createAID(ctor2, tor2),
createAID(ctee1, tee1),
createAID(ctee2, tee2),
]);
}
);

// Exchange OOBIs
console.log('Resolving OOBIs');
const oobi0 = await client0.oobis().get('delegator', 'agent');
const oobi1 = await client1.oobis().get('member1', 'agent');
const oobi2 = await client2.oobis().get('member2', 'agent');
const [toroobi1, toroobi2, teeoobi1, teeoobi2] = await step(
'Getting OOBIs before resolving...',
async () => {
return await Promise.all([
await ctor1.oobis().get(tor1, 'agent'),
await ctor2.oobis().get(tor2, 'agent'),
await ctee1.oobis().get(tee1, 'agent'),
await ctee2.oobis().get(tee2, 'agent'),
]);
}
);

await step('Resolving OOBIs', async () => {
await Promise.all([
resolveOobi(ctor1, toroobi2.oobis[0], tor2),
resolveOobi(ctor2, toroobi1.oobis[0], tor1),
resolveOobi(ctee1, teeoobi2.oobis[0], tee2),
resolveOobi(ctee2, teeoobi1.oobis[0], tee1),
]);
});
console.log(
`${tor1}(${ator1.prefix}) and ${tee1}(${atee1.prefix}) resolved ${tor2}(${ator2.prefix}) and ${tee2}(${atee2.prefix}) OOBIs and vice versa`
);

// First member start the creation of a multisig identifier
// Create a multisig AID for the GEDA.
// Skip if a GEDA AID has already been incepted.
const otor1 = await step(
`${tor1}(${ator1.prefix}) initiated delegator multisig, waiting for ${tor2}(${ator2.prefix}) to join...`,
async () => {
return await startMultisigIncept(ctor1, {
groupName: gtor,
localMemberName: ator1.name,
participants: [ator1.prefix, ator2.prefix],
isith: 2,
nsith: 2,
toad: 2,
wits: [
'BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha',
'BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM',
'BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX',
],
});
}
);

const [ntor] = await waitForNotifications(
ctor2,
'/multisig/icp',
RETRY_DEFAULTS
);
await markAndRemoveNotification(ctor2, ntor);
assert(ntor.a.d);
const otor2 = await acceptMultisigIncept(ctor2, {
localMemberName: ator2.name,
groupName: gtor,
msgSaid: ntor.a.d,
});

const torpre = otor1.name.split('.')[1];
await Promise.all([
resolveOobi(client1, oobi0.oobis[0], 'delegator'),
resolveOobi(client1, oobi2.oobis[0], 'member2'),
resolveOobi(client2, oobi0.oobis[0], 'delegator'),
resolveOobi(client2, oobi1.oobis[0], 'member1'),
waitOperation(ctor1, otor1),
waitOperation(ctor2, otor2),
]);

console.log('Member1 and Member2 resolved 2 OOBIs');
const agtor1 = await ctor1.identifiers().get(gtor);
const agtor2 = await ctor2.identifiers().get(gtor);

// First member start the creation of a multisig identifier
const op1 = await startMultisigIncept(client1, {
groupName: 'multisig',
localMemberName: aid1.name,
participants: [aid1.prefix, aid2.prefix],
isith: 2,
nsith: 2,
toad: 2,
delpre: aid0.prefix,
wits: [
'BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha',
'BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM',
'BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX',
],
});
console.log('Member1 initiated multisig, waiting for others to join...');

// Second member check notifications and join the multisig
const [notification] = await waitForNotifications(client2, '/multisig/icp');
await markAndRemoveNotification(client2, notification);
assert(notification.a.d);
const op2 = await acceptMultisigIncept(client2, {
localMemberName: aid2.name,
groupName: 'multisig',
msgSaid: notification.a.d,
});
assert.equal(agtor1.prefix, agtor2.prefix);
assert.equal(agtor1.name, agtor2.name);
const agtor = agtor1;

//Resolve delegator OOBI
const gtorOobi = await step(
`Add and resolve delegator OOBI ${gtor}(${agtor.prefix})`,
async () => {
// const ogtor1 = await ctor1.oobis().get(gtor, 'agent');
// return await resolveOobi(ctor1, ogtor1.oobis[0], gtor);
const timestamp = createTimestamp();
const opList1 = await addEndRoleMultisig(
ctor1,
gtor,
ator1,
[ator2],
agtor,
timestamp,
true
);
const opList2 = await addEndRoleMultisig(
ctor2,
gtor,
ator2,
[ator1],
agtor,
timestamp
);

await Promise.all(opList1.map((op) => waitOperation(ctor1, op)));
await Promise.all(opList2.map((op) => waitOperation(ctor2, op)));

console.log('Member2 joined multisig, waiting for delegator...');
await waitAndMarkNotification(ctor1, '/multisig/rpy');
await waitAndMarkNotification(ctor2, '/multisig/rpy');

const delegatePrefix = op1.name.split('.')[1];
assert.equal(op2.name.split('.')[1], delegatePrefix);
console.log("Delegate's prefix:", delegatePrefix);
console.log('Delegate waiting for approval...');
const [ogtor1, ogtor2] = await Promise.all([
ctor1.oobis().get(agtor.name, 'agent'),
ctor2.oobis().get(agtor.name, 'agent'),
]);

// Client 0 approves delegation
const anchor = {
i: delegatePrefix,
s: '0',
d: delegatePrefix,
};
const ixnResult = await client0.identifiers().interact('delegator', anchor);
await waitOperation(client0, await ixnResult.op());
console.log('Delegator approved delegation');
assert.equal(ogtor1.role, ogtor2.role);
assert.equal(ogtor1.oobis[0], ogtor2.oobis[0]);

const op3 = await client1.keyStates().query(aid0.prefix, '1');
const op4 = await client2.keyStates().query(aid0.prefix, '1');
return ogtor1.oobis[0];
}
);

// Check for completion
const oobiGtor = gtorOobi.split('/agent/')[0];
await Promise.all([
waitOperation(client1, op1),
waitOperation(client2, op2),
waitOperation(client1, op3),
waitOperation(client2, op4),
getOrCreateContact(ctee1, agtor.name, oobiGtor),
getOrCreateContact(ctee2, agtor.name, oobiGtor),
]);

const otee1 = await step(
`${tee1}(${atee1.prefix}) initiated delegatee multisig, waiting for ${tee2}(${atee2.prefix}) to join...`,
async () => {
return await startMultisigIncept(ctee1, {
groupName: gtee,
localMemberName: atee1.name,
participants: [atee1.prefix, atee2.prefix],
isith: 2,
nsith: 2,
toad: 2,
delpre: torpre,
wits: [
'BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha',
'BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM',
'BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX',
],
});
}
);

// Second member of delegatee check notifications and join the multisig
const [ntee] = await waitForNotifications(ctee2, '/multisig/icp');
await markAndRemoveNotification(ctee2, ntee);
assert(ntee.a.d);

const otee2 = await acceptMultisigIncept(ctee2, {
localMemberName: atee2.name,
groupName: gtee,
msgSaid: ntee.a.d,
});

console.log(`${tee2} joined multisig, waiting for delegator...`);

const agtee1 = await ctee1.identifiers().get(gtee);
const agtee2 = await ctee2.identifiers().get(gtee);

assert.equal(agtee1.prefix, agtee2.prefix);
assert.equal(agtee1.name, agtee2.name);

const teepre = otee1.name.split('.')[1];
assert.equal(otee2.name.split('.')[1], teepre);
console.log('Delegatee prefix:', teepre);

await step('delegator anchors/approves delegation', async () => {
// GEDA anchors delegation with an interaction event.
const anchor = {
i: teepre,
s: '0',
d: teepre,
};
const delApprOp1 = await delegateMultisig(
ctor1,
ator1,
[ator2],
agtor,
anchor,
true
);
const delApprOp2 = await delegateMultisig(
ctor2,
ator2,
[ator1],
agtor,
anchor
);
const [dresult1, dresult2] = await Promise.all([
waitOperation(ctor1, delApprOp1),
waitOperation(ctor2, delApprOp2),
]);

assert.equal(dresult1.response, dresult2.response);

await waitAndMarkNotification(ctor1, '/multisig/ixn');
});

const queryOp1 = await ctor1.keyStates().query(agtor.prefix, '1');
const queryOp2 = await ctor2.keyStates().query(agtor.prefix, '1');

const kstor1 = await waitOperation(ctor1, queryOp1);
const kstor2 = await waitOperation(ctor2, queryOp2);

// QARs query the GEDA's key state
const ksteetor1 = await ctee1.keyStates().query(agtor.prefix, '1');
const ksteetor2 = await ctee2.keyStates().query(agtor.prefix, '1');
const teeTor1 = await waitOperation(ctee1, ksteetor1);
const teeTor2 = await waitOperation(ctee2, ksteetor2);

const teeDone1 = await waitOperation(ctee1, otee1);
const teeDone2 = await waitOperation(ctee2, otee2);
console.log('Delegated multisig created!');

const aid_delegate = await client1.identifiers().get('multisig');
assert.equal(aid_delegate.prefix, delegatePrefix);
const agtee = await ctee1.identifiers().get(gtee);
assert.equal(agtee.prefix, teepre);

await assertOperations(client0, client1, client2);
await assertNotifications(client0, client1, client2);
}, 30000);
await assertOperations(ctor1, ctor2, ctee1, ctee2);
await assertNotifications(ctor1, ctor2, ctee1, ctee2);
}, 600000);

async function createAID(client: signify.SignifyClient, name: string) {
await getOrCreateIdentifier(client, name);
Expand Down
Loading
Loading