Skip to content

Commit

Permalink
remove unneeded tests for backward compatibilty
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Aug 1, 2023
1 parent 08bd73a commit f9a37c4
Showing 1 changed file with 0 additions and 102 deletions.
102 changes: 0 additions & 102 deletions tests/handlers/messages-get.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,108 +178,6 @@ export function testMessagesGetHandler(): void {
}
});

// it('calls dataStore for data when encodedData is below a threshold and encodedData is not set', async () => {
// const alice = await DidKeyResolver.generate();
// const { recordsWrite, dataStream, dataBytes } = await TestDataGenerator.generateRecordsWrite({
// author : alice,
// data : TestDataGenerator.randomBytes(DwnConstant.maxDataSizeAllowedToBeEncoded)
// });
// const { message } = recordsWrite;

// const writeReply = await dwn.processMessage(alice.did, message, dataStream);
// expect(writeReply.status.code).to.equal(202);

// const recordsWriteMessageCid = await Message.getCid(message);

// // messageStore.get resolves recordsWrite without encodedData set
// sinon.stub(messageStore, 'get')
// .withArgs(alice.did, recordsWriteMessageCid)
// .resolves(message);

// const responseStream = DataStream.fromBytes(dataBytes!);
// const getStub = sinon.stub(dataStore, 'get');
// getStub.withArgs(alice.did, recordsWriteMessageCid, message.descriptor.dataCid)
// .resolves({
// dataCid : message.descriptor.dataCid,
// dataSize : message.descriptor.dataSize,
// dataStream : responseStream,
// });

// const { message: getMessage } = await TestDataGenerator.generateMessagesGet({
// author : alice,
// messageCids : [recordsWriteMessageCid]
// });

// const reply: MessagesGetReply = await dwn.processMessage(alice.did, getMessage);
// expect(reply.status.code).to.equal(200);
// expect(reply.messages!.length).to.equal(1);
// expect(reply.messages![0].messageCid).to.equal(recordsWriteMessageCid);

// sinon.assert.calledOnce(getStub);
// expect(reply.messages![0].encodedData).to.equal(Encoder.bytesToBase64Url(dataBytes!));
// });

// it('calls dataStore for data when encodedData is below a threshold and encodedData is not set and there is no underlying data', async () => {
// const alice = await DidKeyResolver.generate();
// const { recordsWrite, dataStream } = await TestDataGenerator.generateRecordsWrite({
// author : alice,
// data : TestDataGenerator.randomBytes(DwnConstant.maxDataSizeAllowedToBeEncoded)
// });
// const { message } = recordsWrite;

// const writeReply = await dwn.processMessage(alice.did, message, dataStream);
// expect(writeReply.status.code).to.equal(202);

// const recordsWriteMessageCid = await Message.getCid(message);

// // messageStore.get resolves recordsWrite without encodedData set
// sinon.stub(messageStore, 'get')
// .withArgs(alice.did, recordsWriteMessageCid)
// .resolves(message);

// const getStub = sinon.stub(dataStore, 'get');
// getStub.withArgs(alice.did, recordsWriteMessageCid, message.descriptor.dataCid)
// .resolves(undefined);

// const { message: getMessage } = await TestDataGenerator.generateMessagesGet({
// author : alice,
// messageCids : [recordsWriteMessageCid]
// });

// const reply: MessagesGetReply = await dwn.processMessage(alice.did, getMessage);
// expect(reply.status.code).to.equal(200);
// expect(reply.messages!.length).to.equal(1);
// expect(reply.messages![0].messageCid).to.equal(recordsWriteMessageCid);

// sinon.assert.calledOnce(getStub);
// expect(reply.messages![0].encodedData).to.be.undefined;
// });

// it('does not call dataStore for data when encodedData is below a threshold and encodedData is set', async () => {
// const alice = await DidKeyResolver.generate();
// const { recordsWrite, dataStream } = await TestDataGenerator.generateRecordsWrite({
// author : alice,
// data : TestDataGenerator.randomBytes(DwnConstant.maxDataSizeAllowedToBeEncoded)
// });
// const writeReply = await dwn.processMessage(alice.did, recordsWrite.message, dataStream);
// expect(writeReply.status.code).to.equal(202);

// const dataStoreGet = sinon.spy(dataStore, 'get');

// const recordsWriteMessageCid = await Message.getCid(recordsWrite.message);
// const { message } = await TestDataGenerator.generateMessagesGet({
// author : alice,
// messageCids : [recordsWriteMessageCid]
// });

// const reply: MessagesGetReply = await dwn.processMessage(alice.did, message);
// expect(reply.status.code).to.equal(200);
// expect(reply.messages!.length).to.equal(1);
// expect(reply.messages![0].messageCid).to.equal(recordsWriteMessageCid);

// sinon.assert.notCalled(dataStoreGet);
// });

it('returns an error message for a specific cid if getting that message from the MessageStore fails', async () => {
// stub the messageStore.get call to throw an error
const messageStore = stubInterface<MessageStore>();
Expand Down

0 comments on commit f9a37c4

Please sign in to comment.