Skip to content

Commit

Permalink
add test step for oobi resolution from delegator
Browse files Browse the repository at this point in the history
  • Loading branch information
lenkan committed Jul 16, 2024
1 parent 304b0ee commit ee47e68
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
keria-version: ['latest']
keria-version: ['0.2.0-dev0']
node-version: ['20']
env:
KERIA_IMAGE_TAG: ${{ matrix.keria-version }}
Expand Down
9 changes: 7 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: ${KERIA_IMAGE:-weboftrust/keria}:${KERIA_IMAGE_TAG:-0.2.0-dev0}
environment:
- KERI_AGENT_CORS=1
- KERI_URL=http://keria:3902
Expand Down Expand Up @@ -55,7 +55,7 @@ services:
- 3903:3903

witness-demo:
image: weboftrust/keri-witness-demo:1.1.0
image: weboftrust/keri:1.1.12
environment:
- PYTHONUNBUFFERED=1
- PYTHONIOENCODING=UTF-8
Expand All @@ -65,6 +65,11 @@ services:
timeout: 3s
retries: 5
start_period: 2s
entrypoint:
- kli
command:
- witness
- demo
volumes:
- ./config/witness-demo:/keripy/scripts/keri/cf/main
ports:
Expand Down
1 change: 0 additions & 1 deletion examples/integration-scripts/delegation-multisig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
resolveOobi,
waitForNotifications,
waitOperation,
warnNotifications,
} from './utils/test-util';
import { getOrCreateClient, getOrCreateIdentifier } from './utils/test-setup';
import {
Expand Down
15 changes: 15 additions & 0 deletions examples/integration-scripts/delegation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
resolveOobi,
waitOperation,
} from './utils/test-util';
import { getOrCreateContact } from './utils/test-setup';

const { url, bootUrl } = resolveEnvironment();

Expand Down Expand Up @@ -99,4 +100,18 @@ test('delegation', async () => {
console.log('Delegation approved for aid:', aid2.prefix);

await assertOperations(client1, client2);
const rpyResult2 = await client2
.identifiers()
.addEndRole('delegate', 'agent', client2!.agent!.pre);
await waitOperation(client2, await rpyResult2.op());
const oobis = await client2.oobis().get('delegate');

console.log(oobis);
const res = await getOrCreateContact(
client1,
'delegate',
oobis.oobis[0].split('/agent/')[0]
);
console.log(res);
// console.log(await client2.)
}, 60000);
8 changes: 5 additions & 3 deletions examples/integration-scripts/utils/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,18 @@ export async function getOrCreateContact(
oobi: string
): Promise<string> {
const list = await client.contacts().list(undefined, 'alias', `^${name}$`);
// console.log("contacts.list", list);
if (list.length > 0) {
const contact = list[0];
if (contact.oobi === oobi) {
// console.log("contacts.id", contact.id);
console.log('OOBI Already found', oobi);
return contact.id;
}
}
let op = await client.oobis().resolve(oobi, name);
op = await waitOperation(client, op);
// console.log("oobis.resolve", op);
console.dir(op, { depth: 100 });
const id = op.response.i;

await client.contacts().get(id);
return op.response.i;
}
28 changes: 8 additions & 20 deletions src/keri/app/aiding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,8 @@ export class Identifier {
icp: serder.ked,
sigs: sigs,
proxy: proxy,
smids:
states != undefined
? states.map((state) => state.i)
: undefined,
rmids:
rstates != undefined
? rstates.map((state) => state.i)
: undefined,
smids: states,
rmids: rstates ?? states,
};
jsondata[algo] = keeper.params();

Expand Down Expand Up @@ -284,8 +278,8 @@ export class Identifier {
jsondata[keeper.algo] = keeper.params();

const res = await this.client.fetch(
'/identifiers/' + name + '?type=ixn',
'PUT',
'/identifiers/' + name + '/events',
'POST',
jsondata
);
return new EventResult(serder, sigs, res);
Expand Down Expand Up @@ -370,20 +364,14 @@ export class Identifier {
const jsondata: any = {
rot: serder.ked,
sigs: sigs,
smids:
states != undefined
? states.map((state) => state.i)
: undefined,
rmids:
rstates != undefined
? rstates.map((state) => state.i)
: undefined,
smids: states,
rmids: rstates,
};
jsondata[keeper.algo] = keeper.params();

const res = await this.client.fetch(
'/identifiers/' + name,
'PUT',
'/identifiers/' + name + '/events',
'POST',
jsondata
);
return new EventResult(serder, sigs, res);
Expand Down

0 comments on commit ee47e68

Please sign in to comment.