Skip to content

Commit

Permalink
Fixed agent tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thehenrytsai committed Oct 9, 2024
1 parent 565f95a commit 21ea68c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions packages/agent/tests/dwn-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,11 @@ describe('AgentDwnApi', () => {
expect(readReply).to.have.property('status');
expect(readReply.status.code).to.equal(200);
expect(readReply).to.have.property('record');
expect(readReply.record).to.have.property('data');
expect(readReply.record).to.have.property('descriptor');
expect(readReply.record).to.have.property('recordId', writeMessage.recordId);
expect(readReply.entry).to.have.property('data');
expect(readReply.entry!.recordsWrite).to.have.property('descriptor');
expect(readReply.entry!.recordsWrite).to.have.property('recordId', writeMessage.recordId);

const readDataBytes = await NodeStream.consumeToBytes({ readable: readReply.record!.data });
const readDataBytes = await NodeStream.consumeToBytes({ readable: readReply.entry!.data! });
expect(readDataBytes).to.deep.equal(dataBytes);
});

Expand Down Expand Up @@ -1530,11 +1530,11 @@ describe('AgentDwnApi', () => {
expect(readReply).to.have.property('status');
expect(readReply.status.code).to.equal(200);
expect(readReply).to.have.property('record');
expect(readReply.record).to.have.property('data');
expect(readReply.record).to.have.property('descriptor');
expect(readReply.record).to.have.property('recordId', writeMessage.recordId);
expect(readReply.entry).to.have.property('data');
expect(readReply.entry?.recordsWrite).to.have.property('descriptor');
expect(readReply.entry?.recordsWrite).to.have.property('recordId', writeMessage.recordId);

const dataStream: ReadableStream | Readable = readReply.record!.data;
const dataStream: ReadableStream | Readable = readReply.entry!.data!;
// If the data stream is a web ReadableStream, convert it to a Node.js Readable.
const nodeReadable = Stream.isReadableStream(dataStream) ?
NodeStream.fromWebReadable({ readableStream: dataStream }) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ describe('HttpDwnRpcClient', () => {

// should return success, and the record we inserted
expect(readResponse.status.code).to.equal(200);
expect(readResponse.record).to.exist;
expect(readResponse.record?.recordId).to.equal(writeMessage.recordId);
expect(readResponse.entry).to.exist;
expect(readResponse.entry?.recordsWrite?.recordId).to.equal(writeMessage.recordId);
});

it('throws error if invalid response exists in the header', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ describe('WebSocketDwnRpcClient', () => {

// should return success, and the record we inserted
expect(readResponse.status.code).to.equal(200);
expect(readResponse.record).to.exist;
expect(readResponse.record?.recordId).to.equal(writeMessage.recordId);
expect(readResponse.entry).to.exist;
expect(readResponse.entry?.recordsWrite?.recordId).to.equal(writeMessage.recordId);
});

it('subscribes to updates to a record', async () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/agent/tests/sync-engine-level.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1109,9 +1109,9 @@ describe('SyncEngineLevel', () => {
messageParams : { filter: { recordId: writeResponse.message!.recordId } }
});
expect(readResponse.reply.status.code).to.equal(200);
expect(readResponse.reply.record).to.exist;
expect(readResponse.reply.record!.data).to.exist;
expect(readResponse.reply.record!.descriptor.dataSize).to.equal(LARGE_DATA_SIZE);
expect(readResponse.reply.entry).to.exist;
expect(readResponse.reply.entry!.data).to.exist;
expect(readResponse.reply.entry!.recordsWrite!.descriptor.dataSize).to.equal(LARGE_DATA_SIZE);
}).slow(1200); // Yellow at 600ms, Red at 1200ms.

it('synchronizes records for multiple identities from remote DWN to local DWN', async () => {
Expand Down Expand Up @@ -1776,8 +1776,8 @@ describe('SyncEngineLevel', () => {
});
const reply = readRecord.reply;
expect(reply.status.code).to.equal(200);
expect(reply.record).to.not.be.undefined;
expect(reply.record!.data).to.not.be.undefined;
expect(reply.entry).to.exist;
expect(reply.entry!.data).to.exist;
}).slow(1200); // Yellow at 600ms, Red at 1200ms.

it('synchronizes records for multiple identities from local DWN to remote DWN', async () => {
Expand Down

0 comments on commit 21ea68c

Please sign in to comment.