From 21ea68cce83321b203d0af41aaecbbd71750729d Mon Sep 17 00:00:00 2001 From: Henry Tsai Date: Tue, 8 Oct 2024 17:35:49 -0700 Subject: [PATCH] Fixed agent tests --- packages/agent/tests/dwn-api.spec.ts | 16 ++++++++-------- .../clients/http-dwn-rpc-client.spec.ts | 4 ++-- .../clients/ws-dwn-rpc-client.spec.ts | 4 ++-- packages/agent/tests/sync-engine-level.spec.ts | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/agent/tests/dwn-api.spec.ts b/packages/agent/tests/dwn-api.spec.ts index 85c5abc2b..07028e76f 100644 --- a/packages/agent/tests/dwn-api.spec.ts +++ b/packages/agent/tests/dwn-api.spec.ts @@ -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); }); @@ -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 }) : diff --git a/packages/agent/tests/prototyping/clients/http-dwn-rpc-client.spec.ts b/packages/agent/tests/prototyping/clients/http-dwn-rpc-client.spec.ts index b860d041f..1cf3e5b11 100644 --- a/packages/agent/tests/prototyping/clients/http-dwn-rpc-client.spec.ts +++ b/packages/agent/tests/prototyping/clients/http-dwn-rpc-client.spec.ts @@ -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 () => { diff --git a/packages/agent/tests/prototyping/clients/ws-dwn-rpc-client.spec.ts b/packages/agent/tests/prototyping/clients/ws-dwn-rpc-client.spec.ts index 4d3d84d5f..e1d68f013 100644 --- a/packages/agent/tests/prototyping/clients/ws-dwn-rpc-client.spec.ts +++ b/packages/agent/tests/prototyping/clients/ws-dwn-rpc-client.spec.ts @@ -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 () => { diff --git a/packages/agent/tests/sync-engine-level.spec.ts b/packages/agent/tests/sync-engine-level.spec.ts index 3d5653e03..4ce1a509d 100644 --- a/packages/agent/tests/sync-engine-level.spec.ts +++ b/packages/agent/tests/sync-engine-level.spec.ts @@ -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 () => { @@ -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 () => {