Skip to content
Merged
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
8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,15 @@
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/chai": "^4.3.4",
"@types/chai-as-promised": "^7.1.5",
"@types/google-protobuf": "^3.15.6",
"@types/jsonld": "^1.5.14",
"@types/node": "^18.14.2",
"@types/pako": "^2.0.3",
"@types/sinon": "^17.0.3",
"@types/sinon-chai": "^3.2.12",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.55.0",
"@vitest/browser": "^1.6.0",
"@vitest/coverage-istanbul": "^1.6.0",
"anoncreds-wasm": "./externals/generated/anoncreds-wasm",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"didcomm-wasm": "./externals/generated/didcomm-wasm",
"eslint": "^8.36.0",
"eslint-plugin-react": "^7.32.2",
Expand All @@ -99,8 +93,6 @@
"protoc-gen-ts": "^0.8.7",
"rxdb": "^14.17.1",
"semantic-release": "^24.0.0",
"sinon": "^18.0.0",
"sinon-chai": "^3.7.0",
"tsup": "^8.4.0",
"typedoc": "^0.25.2",
"typedoc-plugin-external-module-map": "^1.3.2",
Expand Down
8 changes: 4 additions & 4 deletions src/mercury/Mercury.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class Mercury implements MercuryInterface {
public castor: Castor,
public protocol: DIDCommProtocol,
public api: Api
) { }
) {}

/**
* Asynchronously packs a given message object into a string representation. This function may throw an error if the
Expand All @@ -39,7 +39,7 @@ export default class Mercury implements MercuryInterface {
* @param {Domain.Message} message
* @returns {Promise<string>}
*/
packMessage(message: Domain.Message): Promise<string> {
async packMessage(message: Domain.Message): Promise<string> {
const toDid = message.to;
const fromDid = message.from;

Expand Down Expand Up @@ -135,7 +135,7 @@ export default class Mercury implements MercuryInterface {
const responseJSON = JSON.stringify(responseBody);
return await this.unpackMessage(responseJSON);
} catch (err) {
return undefined
return undefined;
}
}

Expand All @@ -152,7 +152,7 @@ export default class Mercury implements MercuryInterface {
if (typeof did.toString !== "function") {
return true;
}
return false
return false;
}

private prepareForwardMessage(
Expand Down
116 changes: 46 additions & 70 deletions tests/agent/Agent.test.ts

Large diffs are not rendered by default.

15 changes: 3 additions & 12 deletions tests/agent/didcomm/invitation.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { vi, describe, it, expect, test, beforeEach, afterEach } from 'vitest';
import chai from "chai";
import chaiAsPromised from "chai-as-promised";
import SinonChai from "sinon-chai";
import UUIDLib from "@stablelib/uuid";
import Agent from "../../../src/edge-agent/Agent";
import { AttachmentDescriptor, DID, Message, MessageDirection, Seed } from "../../../src/domain";
import { AttachmentDescriptor, DID, MessageDirection, Seed } from "../../../src/domain";
import { HandshakeRequest, OutOfBandInvitation, ProtocolType } from "../../../src";
import { InvitationIsInvalidError } from "../../../src/domain/models/errors/Agent";
import { mockPluto } from "../../fixtures/inmemory/factory";
Expand All @@ -13,11 +10,6 @@ import { StartMediator } from '../../../src/edge-agent/didcomm/StartMediator';
import { StartFetchingMessages } from '../../../src/edge-agent/didcomm/StartFetchingMessages';
import { MediatorConnection } from '../../../src/edge-agent/connections/didcomm';

chai.use(SinonChai);
chai.use(chaiAsPromised);



describe("Agent", () => {
let agent: Agent;

Expand Down Expand Up @@ -98,13 +90,12 @@ describe("Agent", () => {
expect(result).to.be.instanceOf(OutOfBandInvitation);
});

it("Invitation expired - throws", () => {
it("Invitation expired - throws", async () => {
const oob = makeOOB();
oob.expires_time = (Date.now() / 1000) - 10;
const url = `https://my.domain.com/path?_oob=${encodeB64(oob)}`;

expect(agent.parseInvitation(url))
.to.eventually.be.rejectedWith(InvitationIsInvalidError);
await expect(agent.parseInvitation(url)).rejects.toThrow(InvitationIsInvalidError);
});

it("Credential Offer Attachment - returns OutOfBandInvitation with attachment", async () => {
Expand Down
24 changes: 5 additions & 19 deletions tests/apollo/Apollo.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { describe, it, expect, test, beforeEach, afterEach } from 'vitest';

import chai, { assert } from "chai";
import chaiAsPromised from "chai-as-promised";
import Apollo from "../../src/apollo/Apollo";
import { Secp256k1KeyPair } from "../../src/apollo/utils/Secp256k1KeyPair";
import * as ECConfig from "../../src/domain/models/ECConfig";
Expand Down Expand Up @@ -31,7 +28,6 @@ import { DerivationAxis } from "../../src/domain/models/derivation/DerivationAxi
import ApolloPKG from "@hyperledger/identus-apollo";

const ApolloSDK = ApolloPKG.org.hyperledger.identus.apollo;
chai.use(chaiAsPromised);

describe("Apollo", () => {
let apollo: Apollo;
Expand Down Expand Up @@ -107,21 +103,13 @@ describe("Apollo", () => {
it(`Should fail when mnemonics is wrong length [${i}]`, () => {
const mnemonics = list.slice(0, i);

assert.throws(
() => apollo.createSeed(mnemonics as any, ""),
ApolloError.MnemonicLengthError
);
expect(() => apollo.createSeed(mnemonics as any, "")).throws(ApolloError.MnemonicLengthError);
});
}

it("Should test failure when checksum is incorrect", () => {
const mnemonicCode = Array(24).fill("abandon") as MnemonicWordList;
assert.throws(
() => {
apollo.createSeed(mnemonicCode, "");
},
ApolloError.MnemonicWordError
);
expect(() => { apollo.createSeed(mnemonicCode, ""); }).throws(ApolloError.MnemonicWordError);
});

it("Should compute the right binary seed", () => {
Expand All @@ -147,9 +135,7 @@ describe("Apollo", () => {
"codus",
...Array(20).fill("abandon"),
] as MnemonicWordList;
assert.throws(() => {
apollo.createSeed(mnemonicCode, "");
}, ApolloError.MnemonicWordError);
expect(() => { apollo.createSeed(mnemonicCode, ""); }).throws(ApolloError.MnemonicWordError);
});
});

Expand Down Expand Up @@ -454,7 +440,7 @@ describe("Apollo", () => {
raw: Fixtures.Keys.ed25519.privateKey.raw
};

assert.throws(() => apollo.restorePrivateKey(key as any), ApolloError.KeyRestoratonFailed);
expect(() => apollo.restorePrivateKey(key as any)).throws(ApolloError.KeyRestoratonFailed);
});
});

Expand Down Expand Up @@ -498,7 +484,7 @@ describe("Apollo", () => {
raw: Fixtures.Keys.ed25519.publicKey.raw
};

assert.throws(() => apollo.restorePublicKey(key as any), ApolloError.KeyRestoratonFailed);
expect(() => apollo.restorePublicKey(key as any)).throws(ApolloError.KeyRestoratonFailed);
});
});
});
Expand Down
Loading
Loading