From 373e9c7726d2b0d4098a18fe5c3562957ee0cc3d Mon Sep 17 00:00:00 2001 From: pfeairheller Date: Tue, 5 Dec 2023 11:28:17 -0800 Subject: [PATCH 01/11] Adding verifier to single issuer script --- .../single-issuer-holder.test.ts | 59 ++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/examples/integration-scripts/single-issuer-holder.test.ts b/examples/integration-scripts/single-issuer-holder.test.ts index fa6e838f..242055bd 100644 --- a/examples/integration-scripts/single-issuer-holder.test.ts +++ b/examples/integration-scripts/single-issuer-holder.test.ts @@ -2,7 +2,7 @@ import assert from 'node:assert'; import signify, { SignifyClient, IssueCredentialArgs, - Operation, + Operation, Serder, } from 'signify-ts'; import { resolveEnvironment } from './utils/resolve-env'; @@ -118,6 +118,32 @@ async function issueCredential( return creds[0]; } +async function grantCredential( + client: SignifyClient, + issuerName: string, + recipient: string, + acdc: Serder, anc: Serder, iss: Serder +) { + const dt = createTimestamp(); + + const [grant, gsigs, end] = await client.ipex().grant({ + senderName: issuerName, + recipient: recipient, + datetime: dt, + acdc: acdc, + anc: anc, + iss: iss, + }); + + await client + .exchanges() + .sendFromEvents(issuerName, 'credential', grant, gsigs, end, [ + recipient, + ]); + + console.log('Grant message sent'); +} + interface Notification { i: string; dt: string; @@ -207,9 +233,11 @@ test( await signify.ready(); const issuerClient = await connect(url, bootUrl); const holderClient = await connect(url, bootUrl); + const verifierClient = await connect(url, bootUrl); await issuerClient.state(); await holderClient.state(); + await verifierClient.state(); const issuerWits = await Promise.all( witnessUrls.map(async (url, i) => { @@ -233,6 +261,17 @@ test( }) ); + const verifierWits = await Promise.all( + witnessUrls.map(async (url, i) => { + const result = await resolveOobi( + verifierClient, + url + '/oobi', + `witness-${i}` + ); + return result.i; + }) + ); + // Create two identifiers, one for each client const issuerPrefix = await createIdentifier( issuerClient, @@ -244,10 +283,16 @@ test( 'holder', holderWits ); + const verifierPrefix = await createIdentifier( + verifierClient, + 'verifier', + verifierWits + ); // Exchange OOBIs const issuerOobi = await getAgentOobi(issuerClient, 'issuer'); const holderOobi = await getAgentOobi(holderClient, 'holder'); + const verifierOobi = await getAgentOobi(verifierClient, 'verifier'); await resolveOobi(issuerClient, holderOobi, 'holder'); await resolveOobi( issuerClient, @@ -260,6 +305,13 @@ test( vleiServerUrl + '/oobi/' + SCHEMA_SAID, 'schema' ); + await resolveOobi(verifierClient, holderOobi, 'holder'); + await resolveOobi(holderClient, verifierOobi, 'verifier'); + await resolveOobi( + verifierClient, + vleiServerUrl + '/oobi/' + SCHEMA_SAID, + 'schema' + ); await createRegistry(issuerClient, 'issuer', 'vLEI'); @@ -288,10 +340,13 @@ test( await holderClient.notifications().mark(grantNotification.i); - await wait(async () => { + const c = await wait(async () => { const creds = await holderClient.credentials().list(); assert(creds.length >= 1); + return creds[0] }); + + const cred = await holderClient.credentials().get("holder", c['sad']['d']) }, 1000 * 60 * 5 ); From facf020363da52e09be9713af88e9091fe77268a Mon Sep 17 00:00:00 2001 From: pfeairheller Date: Wed, 6 Dec 2023 07:52:13 -0800 Subject: [PATCH 02/11] Addition of submitGrant that calls the correct endpoint to perform a credential grant. Sample in `single-issuer-holder.test.ts` of using data from credentials/list to create a GRANT for presenting a held credential. --- .../single-issuer-holder.test.ts | 71 ++++++++++++++++--- src/keri/app/credentialing.ts | 52 ++++++++++++-- 2 files changed, 105 insertions(+), 18 deletions(-) diff --git a/examples/integration-scripts/single-issuer-holder.test.ts b/examples/integration-scripts/single-issuer-holder.test.ts index 242055bd..e65b45ee 100644 --- a/examples/integration-scripts/single-issuer-holder.test.ts +++ b/examples/integration-scripts/single-issuer-holder.test.ts @@ -2,7 +2,8 @@ import assert from 'node:assert'; import signify, { SignifyClient, IssueCredentialArgs, - Operation, Serder, + Operation, + Serder, } from 'signify-ts'; import { resolveEnvironment } from './utils/resolve-env'; @@ -122,7 +123,12 @@ async function grantCredential( client: SignifyClient, issuerName: string, recipient: string, - acdc: Serder, anc: Serder, iss: Serder + acdc: Serder, + acdcAttachment: string, + anc: Serder, + ancAttachment: string, + iss: Serder, + issAttachment: string ) { const dt = createTimestamp(); @@ -131,17 +137,14 @@ async function grantCredential( recipient: recipient, datetime: dt, acdc: acdc, + acdcAttachment: acdcAttachment, anc: anc, + ancAttachment: ancAttachment, iss: iss, + issAttachment: issAttachment, }); - await client - .exchanges() - .sendFromEvents(issuerName, 'credential', grant, gsigs, end, [ - recipient, - ]); - - console.log('Grant message sent'); + await client.ipex().submitGrant(issuerName, grant, gsigs, end, [recipient]); } interface Notification { @@ -343,10 +346,56 @@ test( const c = await wait(async () => { const creds = await holderClient.credentials().list(); assert(creds.length >= 1); - return creds[0] + return creds[0]; + }); + + console.log('Loading full credential'); + const cred = await holderClient + .credentials() + .get('holder', c['sad']['d']); + + const acdc = new Serder(cred['sad']); + const iss = new Serder(cred['iss']); + const anc = new Serder(cred['anc']); + + console.log(`Presenting credential to verifier: ${c['sad']['d']}`); + await grantCredential( + holderClient, + 'holder', + verifierPrefix, + acdc, + cred['atc'], + anc, + cred['ancatc'], + iss, + cred['issatc'] + ); + + const verifierGrantNotification = await waitForNotification( + verifierClient, + '/exn/ipex/grant' + ); + + console.log( + `Notifcation of grant received by verifier ${verifierGrantNotification.a.d}` + ); + await admitCredential( + verifierClient, + 'verifier', + verifierGrantNotification.a.d!, + holderPrefix + ); + + await verifierClient.notifications().mark(verifierGrantNotification.i); + + console.log('Checking for credential'); + const p = await wait(async () => { + const creds = await verifierClient.credentials().list(); + assert(creds.length >= 1); + return creds[0]; }); - const cred = await holderClient.credentials().get("holder", c['sad']['d']) + console.log(`Credential ${p.sad.d} received by Verifier`); }, 1000 * 60 * 5 ); diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index 3317a4bc..6e31774c 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -112,8 +112,11 @@ export interface IpexGrantArgs { agree?: string; datetime?: string; acdc: Serder; + acdcAttachment?: string; iss: Serder; + issAttachment?: string; anc: Serder; + ancAttachment?: string; } /** @@ -704,15 +707,27 @@ export class Ipex { i: args.recipient, }; - const keeper = this.client.manager?.get(hab); - const sigs = await keeper.sign(b(args.anc.raw)); - const sigers = sigs.map((sig: string) => new Siger({ qb64: sig })); - const ims = d(messagize(args.anc, sigers)); - const atc = ims.substring(args.anc.size); + let atc = args.ancAttachment; + if (atc === undefined) { + const keeper = this.client.manager?.get(hab); + const sigs = keeper.sign(b(args.anc.raw)); + const sigers = sigs.map((sig: string) => new Siger({ qb64: sig })); + const ims = d(messagize(args.anc, sigers)); + atc = ims.substring(args.anc.size); + } + + const acdcAtc = + args.acdcAttachment === undefined + ? d(serializeACDCAttachment(args.iss)) + : args.acdcAttachment; + const issAtc = + args.issAttachment === undefined + ? d(serializeIssExnAttachment(args.anc)) + : args.issAttachment; const embeds: Record = { - acdc: [args.acdc, d(serializeACDCAttachment(args.iss))], - iss: [args.iss, d(serializeIssExnAttachment(args.anc))], + acdc: [args.acdc, acdcAtc], + iss: [args.iss, issAtc], anc: [args.anc, atc], }; @@ -729,6 +744,29 @@ export class Ipex { ); } + async submitGrant( + name: string, + exn: Serder, + sigs: string[], + atc: string, + recp: string[] + ): Promise { + const body = { + exn: exn.ked, + sigs: sigs, + atc: atc, + rec: recp, + }; + + const response = await this.client.fetch( + `/identifiers/${name}/ipex/grant`, + 'POST', + body + ); + + return response.json(); + } + /** * Create an IPEX admit EXN message * @async From c6e8a4c4ae9320aff8feaf8adbe2336e40723d44 Mon Sep 17 00:00:00 2001 From: pfeairheller Date: Wed, 6 Dec 2023 11:11:23 -0800 Subject: [PATCH 03/11] Getting unit tests to run locally and successfully --- .../integration-scripts/credentials.test.ts | 27 +++++++++---------- src/keri/app/credentialing.ts | 4 +-- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/examples/integration-scripts/credentials.test.ts b/examples/integration-scripts/credentials.test.ts index d9712ce4..52b074de 100644 --- a/examples/integration-scripts/credentials.test.ts +++ b/examples/integration-scripts/credentials.test.ts @@ -1,18 +1,20 @@ import { strict as assert } from 'assert'; import signify from 'signify-ts'; +import {resolveEnvironment} from "./utils/resolve-env"; +const { url, bootUrl, vleiServerUrl, witnessIds, witnessUrls } = resolveEnvironment(); -const url = 'http://127.0.0.1:3901'; -const boot_url = 'http://127.0.0.1:3903'; -const WAN_WITNESS_AID = 'BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha'; -const WIL_WITNESS_AID = 'BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM'; -const WES_WITNESS_AID = 'BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX'; -const WITNESS_HOST = 'witness-demo'; +const boot_url = bootUrl; +const WAN_WITNESS_AID = witnessIds[0]; +const WIL_WITNESS_AID = witnessIds[1]; +const WES_WITNESS_AID = witnessIds[2]; const WITNESS_OOBIS = [ - `http://${WITNESS_HOST}:5642/oobi/${WAN_WITNESS_AID}/controller?name=Wan&tag=witness`, - `http://${WITNESS_HOST}:5643/oobi/${WIL_WITNESS_AID}/controller?name=Wil&tag=witness`, - `http://${WITNESS_HOST}:5644/oobi/${WES_WITNESS_AID}/controller?name=Wes&tag=witness`, + `${witnessUrls[0]}/oobi/${WAN_WITNESS_AID}/controller?name=Wan&tag=witness`, + `${witnessUrls[1]}/oobi/${WIL_WITNESS_AID}/controller?name=Wil&tag=witness`, + `${witnessUrls[2]}/oobi/${WES_WITNESS_AID}/controller?name=Wes&tag=witness`, ]; +console.log(WITNESS_OOBIS) + const KLI_WITNESS_DEMO_PREFIXES = [ WAN_WITNESS_AID, WIL_WITNESS_AID, @@ -21,7 +23,7 @@ const KLI_WITNESS_DEMO_PREFIXES = [ // Credential Schema discovery through credential schema OOBI resolution const qviSchemaSAID = 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao'; -const vLEIServerHostUrl = 'http://vlei-server:7723/oobi'; +const vLEIServerHostUrl = `${vleiServerUrl}/oobi`; const schemaOobiUrl = `${vLEIServerHostUrl}/${qviSchemaSAID}`; // Boots an agent and connects to it, returning the connected SignifyClient @@ -82,11 +84,6 @@ test('credentials', async () => { const issuerClient = await bootAndConnect(signify.randomPasscode()); const holderClient = await bootAndConnect(signify.randomPasscode()); const verifierClient = await bootAndConnect(signify.randomPasscode()); - await Promise.all([ - resolveWitnesses(issuerClient), - resolveWitnesses(holderClient), - resolveWitnesses(verifierClient), - ]); const state1 = await issuerClient.state(); const state2 = await holderClient.state(); diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index 6e31774c..0443b4ef 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -295,8 +295,8 @@ export class Credentials { d: '', i: said, s: '1', - p: cred.status.d, ri: cred.sad.ri, + p: cred.status.d, dt: dt, }; @@ -710,7 +710,7 @@ export class Ipex { let atc = args.ancAttachment; if (atc === undefined) { const keeper = this.client.manager?.get(hab); - const sigs = keeper.sign(b(args.anc.raw)); + const sigs = await keeper.sign(b(args.anc.raw)); const sigers = sigs.map((sig: string) => new Siger({ qb64: sig })); const ims = d(messagize(args.anc, sigers)); atc = ims.substring(args.anc.size); From ed571827d0fdec010f4a5b74392ff2737c273a46 Mon Sep 17 00:00:00 2001 From: pfeairheller Date: Wed, 6 Dec 2023 12:27:20 -0800 Subject: [PATCH 04/11] Prettier --- examples/integration-scripts/credentials.test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/integration-scripts/credentials.test.ts b/examples/integration-scripts/credentials.test.ts index 52b074de..35a60116 100644 --- a/examples/integration-scripts/credentials.test.ts +++ b/examples/integration-scripts/credentials.test.ts @@ -1,7 +1,8 @@ import { strict as assert } from 'assert'; import signify from 'signify-ts'; -import {resolveEnvironment} from "./utils/resolve-env"; -const { url, bootUrl, vleiServerUrl, witnessIds, witnessUrls } = resolveEnvironment(); +import { resolveEnvironment } from './utils/resolve-env'; +const { url, bootUrl, vleiServerUrl, witnessIds, witnessUrls } = + resolveEnvironment(); const boot_url = bootUrl; const WAN_WITNESS_AID = witnessIds[0]; @@ -13,8 +14,6 @@ const WITNESS_OOBIS = [ `${witnessUrls[2]}/oobi/${WES_WITNESS_AID}/controller?name=Wes&tag=witness`, ]; -console.log(WITNESS_OOBIS) - const KLI_WITNESS_DEMO_PREFIXES = [ WAN_WITNESS_AID, WIL_WITNESS_AID, From b006fdd69110df3d3b1ab29e2ebfd9fa600d3b5c Mon Sep 17 00:00:00 2001 From: lenkan Date: Wed, 6 Dec 2023 22:19:32 +0100 Subject: [PATCH 05/11] add logs --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d0f11fe5..0b87367c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -69,3 +69,7 @@ jobs: run: docker compose up deps - name: Run integration test run: npm run test:integration + - name: Print logs + run: docker compose logs + if: always() + From 507ed5616a2c563cb4f0c9b490cc357871fb4721 Mon Sep 17 00:00:00 2001 From: lenkan Date: Wed, 6 Dec 2023 22:25:30 +0100 Subject: [PATCH 06/11] add timeouts --- examples/integration-scripts/singlesig-ixn.test.ts | 4 ++-- examples/integration-scripts/singlesig-rot.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/integration-scripts/singlesig-ixn.test.ts b/examples/integration-scripts/singlesig-ixn.test.ts index 1986ba6a..7776f87d 100644 --- a/examples/integration-scripts/singlesig-ixn.test.ts +++ b/examples/integration-scripts/singlesig-ixn.test.ts @@ -38,7 +38,7 @@ describe('singlesig-ixn', () => { // local and remote keystate sequence match expect(keystate1[0].s).toEqual(keystate2[0].s); - }); + }, 30000); test('ixn1', async () => { // local keystate before ixn const keystate0: KeyState = ( @@ -75,5 +75,5 @@ describe('singlesig-ixn', () => { const keystate3: KeyState = op.response; // local and remote keystate match expect(keystate3.s).toEqual(keystate1.s); - }); + }, 30000); }); diff --git a/examples/integration-scripts/singlesig-rot.test.ts b/examples/integration-scripts/singlesig-rot.test.ts index d5a7af91..1da3d339 100644 --- a/examples/integration-scripts/singlesig-rot.test.ts +++ b/examples/integration-scripts/singlesig-rot.test.ts @@ -40,7 +40,7 @@ describe('singlesig-rot', () => { // local and remote keystate sequence match expect(keystate1[0].s).toEqual(keystate2[0].s); - }); + }, 30000); test('rot1', async () => { // local keystate before rot const keystate0: KeyState = ( @@ -86,5 +86,5 @@ describe('singlesig-rot', () => { expect(keystate3.s).toEqual(keystate1.s); expect(keystate3.k[0]).toEqual(keystate1.k[0]); expect(keystate3.n[0]).toEqual(keystate1.n[0]); - }); + }, 30000); }); From e54ea2b50466e2ebf11ba9ca6b1bc031970ea717 Mon Sep 17 00:00:00 2001 From: lenkan Date: Wed, 6 Dec 2023 22:27:28 +0100 Subject: [PATCH 07/11] remove oobis --- examples/integration-scripts/multisig.test.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/examples/integration-scripts/multisig.test.ts b/examples/integration-scripts/multisig.test.ts index 3ab15bfe..dddf9690 100644 --- a/examples/integration-scripts/multisig.test.ts +++ b/examples/integration-scripts/multisig.test.ts @@ -6,14 +6,13 @@ import signify, { } from 'signify-ts'; import { resolveEnvironment } from './utils/resolve-env'; -const { url, bootUrl, witnessUrls, vleiServerUrl } = resolveEnvironment(); +const { url, bootUrl, vleiServerUrl } = resolveEnvironment(); const WITNESS_AIDS = [ 'BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha', 'BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM', 'BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX', ]; -const WITNESS_OOBIS = witnessUrls.map((url) => `${url}/oobi`); const SCHEMA_SAID = 'EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao'; const SCHEMA_OOBI = `${vleiServerUrl}/oobi/${SCHEMA_SAID}`; @@ -1144,7 +1143,6 @@ async function bootClient(): Promise { state.agent.i ); - await resolveWitnesses(client); return client; } @@ -1161,12 +1159,6 @@ async function createAID(client: SignifyClient, name: string, wits: string[]) { return aid; } -async function resolveWitnesses(client: SignifyClient) { - await Promise.all( - WITNESS_OOBIS.map((oobi) => client.oobis().resolve(oobi)) - ); -} - async function multisigIssue( client: SignifyClient, memberName: string, From 73cd2c1151b11e24c71c4e12b19ea77d71abf0e2 Mon Sep 17 00:00:00 2001 From: lenkan Date: Wed, 6 Dec 2023 22:29:41 +0100 Subject: [PATCH 08/11] increase timeout --- examples/integration-scripts/multisig.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/integration-scripts/multisig.test.ts b/examples/integration-scripts/multisig.test.ts index dddf9690..857dc57f 100644 --- a/examples/integration-scripts/multisig.test.ts +++ b/examples/integration-scripts/multisig.test.ts @@ -1105,7 +1105,7 @@ test('multisig', async function run() { console.log('Member1 received exchange message with the admit response'); const creds = await client4.credentials().list(); console.log(`Holder holds ${creds.length} credential`); -}, 240000); +}, 360000); async function waitForOp(client: SignifyClient, op: any) { while (!op['done']) { From 318c7555b148995ca2e3e13ecc594423934826a6 Mon Sep 17 00:00:00 2001 From: pfeairheller Date: Wed, 6 Dec 2023 16:51:01 -0800 Subject: [PATCH 09/11] One script change to get local execution to work. Changed workflow for integration tests to pull image every time since our plan is to overwrite the dev tags on the images for development builds for KERIA / KERIpy --- .github/workflows/main.yml | 2 +- .../integration-scripts/test-setup-single-client.test.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0b87367c..7e6341d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,7 +66,7 @@ jobs: - name: Build run: npm run build - name: Start dependencies - run: docker compose up deps + run: docker compose up deps --pull always - name: Run integration test run: npm run test:integration - name: Print logs diff --git a/examples/integration-scripts/test-setup-single-client.test.ts b/examples/integration-scripts/test-setup-single-client.test.ts index 32bb084b..f01957e8 100644 --- a/examples/integration-scripts/test-setup-single-client.test.ts +++ b/examples/integration-scripts/test-setup-single-client.test.ts @@ -29,16 +29,16 @@ describe('test-setup-single-client', () => { switch (env.preset) { case 'local': expect(name1_oobi).toEqual( - `http://localhost:3902/oobi/${name1_id}/agent/EC60ue9GOpQGrLBlS9T0dO6JkBTbv3V05Y4O730QBBoc` + `http://127.0.0.1:3902/oobi/${name1_id}/agent/EC60ue9GOpQGrLBlS9T0dO6JkBTbv3V05Y4O730QBBoc` ); expect(oobi.oobis[0]).toEqual( - `http://localhost:5642/oobi/${name1_id}/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha` + `http://127.0.0.1:5642/oobi/${name1_id}/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha` ); expect(oobi.oobis[1]).toEqual( - `http://localhost:5643/oobi/${name1_id}/witness/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM` + `http://127.0.0.1:5643/oobi/${name1_id}/witness/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM` ); expect(oobi.oobis[2]).toEqual( - `http://localhost:5644/oobi/${name1_id}/witness/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX` + `http://127.0.0.1:5644/oobi/${name1_id}/witness/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX` ); break; case 'docker': From 272ac28154acc1fe77f8958962a9973c693b4166 Mon Sep 17 00:00:00 2001 From: pfeairheller Date: Wed, 6 Dec 2023 18:34:19 -0800 Subject: [PATCH 10/11] Add test coverage for new grant methods. --- test/app/credentialing.test.ts | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/test/app/credentialing.test.ts b/test/app/credentialing.test.ts index ef131d1d..daff35ae 100644 --- a/test/app/credentialing.test.ts +++ b/test/app/credentialing.test.ts @@ -7,12 +7,12 @@ import libsodium from 'libsodium-wrappers-sumo'; import fetchMock from 'jest-fetch-mock'; import 'whatwg-fetch'; import { - b, + b, d, Ident, Ilks, interact, Saider, - Serder, + Serder, serializeACDCAttachment, serializeIssExnAttachment, Serials, versify, } from '../../src'; @@ -323,7 +323,7 @@ describe('Credentialing', () => { }); describe('Ipex', () => { - it('Ipex', async () => { + it('should do all the IPEX things', async () => { await libsodium.ready; const bran = '0123456789abcdefghijk'; const client = new SignifyClient(url, bran, Tier.low, boot_url); @@ -426,6 +426,27 @@ describe('Ipex', () => { 'Vp8j2uxTTPkItO7ED' ); + const [ng, ngsigs, ngend] = await ipex.grant({ + senderName: 'multisig', + recipient: holder, + message: '', + acdc: new Serder(acdc), + acdcAttachment: d(serializeACDCAttachment(iserder)), + iss: iserder, + issAttachment: d(serializeIssExnAttachment(anc)), + anc, + ancAttachment: "-AABAADMtDfNihvCSXJNp1VronVojcPGo--0YZ4Kh6CAnowRnn4Or4FgZQqaqCEv6XVS413qfZoVp8j2uxTTPkItO7ED", + datetime: mockCredential.sad.a.dt, + }); + + assert.deepStrictEqual(ng.ked, grant.ked) + assert.deepStrictEqual(ngsigs, gsigs) + assert.deepStrictEqual(ngend, ngend) + + await ipex.submitGrant("multisig", ng, ngsigs, ngend, [holder]) + let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; + assert.equal(lastCall[0], 'http://127.0.0.1:3901/identifiers/multisig/ipex/grant') + const [admit, asigs, aend] = await ipex.admit( 'holder', '', @@ -450,6 +471,11 @@ describe('Ipex', () => { 'AAD6NAWzEr_KonMJhKL32JLTVZ2_xwVNMqlr-ovAwoIQS5IEWZ8POd4rbWO49-8NqK8GedjUyii3y9o1b0QkYzQJ', ]); + await ipex.submitAdmit("multisig", admit, asigs, aend, [holder]) + lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; + assert.equal(lastCall[0], 'http://127.0.0.1:3901/identifiers/multisig/ipex/admit') + + assert.equal(aend, ''); }); }); From 11b1d37a14c67c623295939ad83a2767fd131948 Mon Sep 17 00:00:00 2001 From: pfeairheller Date: Wed, 6 Dec 2023 18:39:37 -0800 Subject: [PATCH 11/11] Pretty --- test/app/credentialing.test.ts | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/test/app/credentialing.test.ts b/test/app/credentialing.test.ts index daff35ae..b016fb31 100644 --- a/test/app/credentialing.test.ts +++ b/test/app/credentialing.test.ts @@ -7,12 +7,15 @@ import libsodium from 'libsodium-wrappers-sumo'; import fetchMock from 'jest-fetch-mock'; import 'whatwg-fetch'; import { - b, d, + b, + d, Ident, Ilks, interact, Saider, - Serder, serializeACDCAttachment, serializeIssExnAttachment, + Serder, + serializeACDCAttachment, + serializeIssExnAttachment, Serials, versify, } from '../../src'; @@ -435,17 +438,21 @@ describe('Ipex', () => { iss: iserder, issAttachment: d(serializeIssExnAttachment(anc)), anc, - ancAttachment: "-AABAADMtDfNihvCSXJNp1VronVojcPGo--0YZ4Kh6CAnowRnn4Or4FgZQqaqCEv6XVS413qfZoVp8j2uxTTPkItO7ED", + ancAttachment: + '-AABAADMtDfNihvCSXJNp1VronVojcPGo--0YZ4Kh6CAnowRnn4Or4FgZQqaqCEv6XVS413qfZoVp8j2uxTTPkItO7ED', datetime: mockCredential.sad.a.dt, }); - assert.deepStrictEqual(ng.ked, grant.ked) - assert.deepStrictEqual(ngsigs, gsigs) - assert.deepStrictEqual(ngend, ngend) + assert.deepStrictEqual(ng.ked, grant.ked); + assert.deepStrictEqual(ngsigs, gsigs); + assert.deepStrictEqual(ngend, ngend); - await ipex.submitGrant("multisig", ng, ngsigs, ngend, [holder]) + await ipex.submitGrant('multisig', ng, ngsigs, ngend, [holder]); let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; - assert.equal(lastCall[0], 'http://127.0.0.1:3901/identifiers/multisig/ipex/grant') + assert.equal( + lastCall[0], + 'http://127.0.0.1:3901/identifiers/multisig/ipex/grant' + ); const [admit, asigs, aend] = await ipex.admit( 'holder', @@ -471,10 +478,12 @@ describe('Ipex', () => { 'AAD6NAWzEr_KonMJhKL32JLTVZ2_xwVNMqlr-ovAwoIQS5IEWZ8POd4rbWO49-8NqK8GedjUyii3y9o1b0QkYzQJ', ]); - await ipex.submitAdmit("multisig", admit, asigs, aend, [holder]) + await ipex.submitAdmit('multisig', admit, asigs, aend, [holder]); lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!; - assert.equal(lastCall[0], 'http://127.0.0.1:3901/identifiers/multisig/ipex/admit') - + assert.equal( + lastCall[0], + 'http://127.0.0.1:3901/identifiers/multisig/ipex/admit' + ); assert.equal(aend, ''); });