Skip to content

Commit

Permalink
remove whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Apr 11, 2024
1 parent 26401ac commit 2c50068
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
1 change: 1 addition & 0 deletions packages/agent/src/prototyping/crypto/jose/jwe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ export class JweKeyManagement {

// Set the CEK to the key management `key`.
cek = key;

break;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/types/dwn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,4 @@ export {
PaginationCursor as DwnPaginationCursor,
EncryptionAlgorithm as DwnEncryptionAlgorithm,
KeyDerivationScheme as DwnKeyDerivationScheme,
} from '@tbd54566975/dwn-sdk-js';
} from '@tbd54566975/dwn-sdk-js';
46 changes: 23 additions & 23 deletions packages/agent/tests/rpc-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,45 @@ import { JsonRpcErrorCodes, createJsonRpcErrorResponse, createJsonRpcSuccessResp
describe('RPC Clients', () => {
describe('Web5RpcClient', () => {
let alice: Persona;

beforeEach(async () => {
sinon.restore();

alice = await TestDataGenerator.generateDidKeyPersona();
});

it('returns available transports', async () => {
const httpOnlyClient = new Web5RpcClient();
expect(httpOnlyClient.transportProtocols).to.have.members(['http:', 'https:']);

const wsAndHttpClients = new Web5RpcClient([
new WebSocketWeb5RpcClient()
]);

expect(wsAndHttpClients.transportProtocols).to.have.members([
'http:',
'https:',
'ws:',
'wss:'
]);
});

describe('sendDidRequest', () => {
it('should send to the client depending on transport', async () => {
const stubHttpClient = sinon.createStubInstance(HttpWeb5RpcClient);
const httpOnlyClient = new Web5RpcClient([ stubHttpClient ]);

// request with http
const request = { method: DidRpcMethod.Resolve, url: 'http://127.0.0.1', data: 'some-data' };
httpOnlyClient.sendDidRequest(request);

expect(stubHttpClient.sendDidRequest.callCount).to.equal(1);
});

it('should throw if transport client is not found', async () => {
const stubHttpClient = sinon.createStubInstance(HttpWeb5RpcClient);
const httpOnlyClient = new Web5RpcClient([ stubHttpClient ]);

// request with http
const request = { method: DidRpcMethod.Resolve, url: 'ws://127.0.0.1', data: 'some-data' };
try {
Expand All @@ -61,12 +61,12 @@ describe('RPC Clients', () => {
} catch (error: any) {
expect(error.message).to.equal('no ws: transport client available');
}

// confirm http transport was not called
expect(stubHttpClient.sendDidRequest.callCount).to.equal(0);
});
});

describe('sendDwnRequest', () => {
it('should send to the client depending on transport', async () => {
const stubHttpClient = sinon.createStubInstance(HttpWeb5RpcClient);
Expand All @@ -77,18 +77,18 @@ describe('RPC Clients', () => {
schema: 'foo/bar'
}
});

// request with http
await httpOnlyClient.sendDwnRequest({
dwnUrl : 'http://127.0.0.1',
targetDid : alice.did,
message,
});

// confirm http transport was called
expect(stubHttpClient.sendDwnRequest.callCount).to.equal(1);
});

it('should throw if transport client is not found', async () => {
const stubHttpClient = sinon.createStubInstance(HttpWeb5RpcClient);
const httpOnlyClient = new Web5RpcClient([ stubHttpClient ]);
Expand All @@ -98,7 +98,7 @@ describe('RPC Clients', () => {
schema: 'foo/bar'
}
});

try {
// request with ws
await httpOnlyClient.sendDwnRequest({
Expand All @@ -110,7 +110,7 @@ describe('RPC Clients', () => {
} catch(error: any) {
expect(error.message).to.equal('no ws: transport client available');
}

// confirm http transport was not called
expect(stubHttpClient.sendDwnRequest.callCount).to.equal(0);
});
Expand Down Expand Up @@ -211,13 +211,13 @@ describe('RPC Clients', () => {
const dwnUrl = new URL(testDwnUrl);
dwnUrl.protocol = dwnUrl.protocol === 'http:' ? 'ws:' : 'wss:';
const socketDwnUrl = dwnUrl.toString();

beforeEach(async () => {
sinon.restore();

alice = await TestDataGenerator.generateDidKeyPersona();
});

describe('sendDwnRequest', () => {
it('supports sending dwn requests', async () => {
// create a generic records query
Expand All @@ -227,20 +227,20 @@ describe('RPC Clients', () => {
schema: 'foo/bar'
}
});

const response = await client.sendDwnRequest({
dwnUrl : socketDwnUrl,
targetDid : alice.did,
message,
});

// should return success but without any records as none exist yet
expect(response.status.code).to.equal(200);
expect(response.entries).to.exist;
expect(response.entries?.length).to.equal(0);
});
});

describe('sendDidRequest', () => {
it('did requests are not supported over sockets', async () => {
const request = { method: DidRpcMethod.Resolve, url: socketDwnUrl, data: 'some-data' };
Expand Down

0 comments on commit 2c50068

Please sign in to comment.