Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Gann committed Dec 19, 2023
1 parent e86545b commit eeb5b34
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
68 changes: 38 additions & 30 deletions test/attributes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { ValidationSchema } from "./lib/validation";
const launcher = new Launcher();
let client1: ConnectorClient;
let client2: ConnectorClient;
let client1Address: string;
let client2Address: string;

beforeAll(async () => {
[client1, client2] = await launcher.launch(2);
await establishRelationship(client1, client2);
client1Address = (await client1.account.getIdentityInfo()).result.address;
client2Address = (await client2.account.getIdentityInfo()).result.address;
}, 30000);
afterAll(() => launcher.stop());
Expand Down Expand Up @@ -132,36 +134,42 @@ describe("Execute AttributeQueries", () => {
expect(attributes).toContainEqual(attribute);
});

// TODO: requires an active relationship and an accept from peer before relationship attribute can be queried
// test("should execute a RelationshipAttributeQuery", async () => {
// await createRelationshipAttribute(client1, {
// content: {
// value: {
// "@type": "ProprietaryString",
// title: "ATitle",
// value: "AString"
// },
// key: "AKey",
// confidentiality: "public"
// },
// peer: "peer"
// });

// const executeRelationshipAttributeQueryResult = await client1.attributes.executeRelationshipAttributeQuery({
// query: {
// key: "AKey",
// owner: client1Address,
// attributeCreationHints: {
// valueType: "ProprietaryString",
// title: "A title",
// confidentiality: "public"
// }
// }
// });
// expect(executeRelationshipAttributeQueryResult).toBeSuccessful(ValidationSchema.ConnectorAttribute);

// expect(executeRelationshipAttributeQueryResult.result.content.value.value).toBe("AString");
// });
test("should execute a RelationshipAttributeQuery", async () => {
const createRequest = await client1.attributes.createAndShareRelationshipAttribute({
content: {
value: {
"@type": "ProprietaryString",
title: "ATitle",
value: "AString"
},
key: "AKey",
confidentiality: "public"
},
peer: "peer"
});

await syncUntilHasMessages(client2);

await client2.incomingRequests.accept(createRequest.result.id, { items: [{ accept: true }] });

await syncUntilHasMessages(client1);

const executeRelationshipAttributeQueryResult = await client1.attributes.executeRelationshipAttributeQuery({
query: {
key: "AKey",
owner: client1Address,
attributeCreationHints: {
valueType: "ProprietaryString",
title: "A title",
confidentiality: "public"
}
}
});

expect(executeRelationshipAttributeQueryResult).toBeSuccessful(ValidationSchema.ConnectorAttribute);

expect(executeRelationshipAttributeQueryResult.result.content.value.value).toBe("AString");
});

describe("Create Identity Attribute", () => {
test("Should share an Identity Attribute", async () => {
Expand Down
1 change: 0 additions & 1 deletion test/iqlquery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ test("Remote ProposeAttributeRequest containing IQL Query without existing attri

incomingRequestItem.attribute.owner = client1Address;
const requestItemAttribute = incomingRequestItem.attribute;
// TODO: also add tags in createIdentityAttribute?
const attributeId = (await client1.attributes.createIdentityAttribute({ content: { value: requestItemAttribute.value } })).result.id;

/* Reply to the response with the first matched attribute. Wait on C2 for
Expand Down

0 comments on commit eeb5b34

Please sign in to comment.