Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove use of dataStream for ProtocolsConfigure in tests #528

Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Here's to a thrilling Hacktoberfest voyage with us! 🎉
# Decentralized Web Node (DWN) SDK <!-- omit in toc -->

Code Coverage
![Statements](https://img.shields.io/badge/statements-97.78%25-brightgreen.svg?style=flat) ![Branches](https://img.shields.io/badge/branches-95.05%25-brightgreen.svg?style=flat) ![Functions](https://img.shields.io/badge/functions-94.26%25-brightgreen.svg?style=flat) ![Lines](https://img.shields.io/badge/lines-97.78%25-brightgreen.svg?style=flat)
![Statements](https://img.shields.io/badge/statements-97.78%25-brightgreen.svg?style=flat) ![Branches](https://img.shields.io/badge/branches-95.06%25-brightgreen.svg?style=flat) ![Functions](https://img.shields.io/badge/functions-94.26%25-brightgreen.svg?style=flat) ![Lines](https://img.shields.io/badge/lines-97.78%25-brightgreen.svg?style=flat)

- [Introduction](#introduction)
- [Installation](#installation)
Expand Down
20 changes: 10 additions & 10 deletions tests/handlers/protocols-configure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,19 @@ export function testProtocolsConfigureHandler(): void {
});

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

// older messages will not overwrite the existing
const reply2 = await dwn.processMessage(alice.did, oldProtocolsConfigure.message, oldProtocolsConfigure.dataStream);
const reply2 = await dwn.processMessage(alice.did, oldProtocolsConfigure.message);
expect(reply2.status.code).to.equal(409);

// newer message can overwrite the existing message
const newProtocolsConfigure = await TestDataGenerator.generateProtocolsConfigure({
author: alice,
protocolDefinition,
});
const reply3 = await dwn.processMessage(alice.did, newProtocolsConfigure.message, newProtocolsConfigure.dataStream);
const reply3 = await dwn.processMessage(alice.did, newProtocolsConfigure.message);
expect(reply3.status.code).to.equal(202);

// only the newest protocol should remain
Expand Down Expand Up @@ -196,15 +196,15 @@ export function testProtocolsConfigureHandler(): void {
= messageDataWithCid.sort((messageDataA, messageDataB) => { return lexicographicalCompare(messageDataA.cid, messageDataB.cid); });

// write the protocol with the middle lexicographic value
const reply1 = await dwn.processMessage(alice.did, middleProtocolsConfigure.message, middleProtocolsConfigure.dataStream);
const reply1 = await dwn.processMessage(alice.did, middleProtocolsConfigure.message);
expect(reply1.status.code).to.equal(202);

// test that the protocol with the smallest lexicographic value cannot be written
const reply2 = await dwn.processMessage(alice.did, lowestProtocolsConfigure.message, lowestProtocolsConfigure.dataStream);
const reply2 = await dwn.processMessage(alice.did, lowestProtocolsConfigure.message);
expect(reply2.status.code).to.equal(409);

// test that the protocol with the largest lexicographic value can be written
const reply3 = await dwn.processMessage(alice.did, highestProtocolsConfigure.message, highestProtocolsConfigure.dataStream);
const reply3 = await dwn.processMessage(alice.did, highestProtocolsConfigure.message);
expect(reply3.status.code).to.equal(202);

// test that lower lexicographic protocol message is removed from DB and only the newer protocol message remains
Expand Down Expand Up @@ -284,9 +284,9 @@ export function testProtocolsConfigureHandler(): void {
describe('event log', () => {
it('should add event for ProtocolsConfigure', async () => {
const alice = await DidKeyResolver.generate();
const { message, dataStream } = await TestDataGenerator.generateProtocolsConfigure({ author: alice });
const { message } = await TestDataGenerator.generateProtocolsConfigure({ author: alice });

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

const events = await eventLog.getEvents(alice.did);
Expand All @@ -302,10 +302,10 @@ export function testProtocolsConfigureHandler(): void {
await minimalSleep();
const newestWrite = await TestDataGenerator.generateProtocolsConfigure({ author: alice, protocolDefinition: minimalProtocolDefinition });

let reply = await dwn.processMessage(alice.did, oldestWrite.message, oldestWrite.dataStream);
let reply = await dwn.processMessage(alice.did, oldestWrite.message);
expect(reply.status.code).to.equal(202);

reply = await dwn.processMessage(alice.did, newestWrite.message, newestWrite.dataStream);
reply = await dwn.processMessage(alice.did, newestWrite.message);
expect(reply.status.code).to.equal(202);

const events = await eventLog.getEvents(alice.did);
Expand Down
12 changes: 6 additions & 6 deletions tests/handlers/protocols-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export function testProtocolsQueryHandler(): void {
const protocol2 = await TestDataGenerator.generateProtocolsConfigure({ author: alice });
const protocol3 = await TestDataGenerator.generateProtocolsConfigure({ author: alice });

await dwn.processMessage(alice.did, protocol1.message, protocol1.dataStream);
await dwn.processMessage(alice.did, protocol2.message, protocol2.dataStream);
await dwn.processMessage(alice.did, protocol3.message, protocol3.dataStream);
await dwn.processMessage(alice.did, protocol1.message);
await dwn.processMessage(alice.did, protocol2.message);
await dwn.processMessage(alice.did, protocol3.message);

// testing singular conditional query
const queryMessageData = await TestDataGenerator.generateProtocolsQuery({
Expand Down Expand Up @@ -107,9 +107,9 @@ export function testProtocolsQueryHandler(): void {
const protocol2 = await TestDataGenerator.generateProtocolsConfigure({ author: alice, published: true });
const protocol3 = await TestDataGenerator.generateProtocolsConfigure({ author: alice, published: true });

await dwn.processMessage(alice.did, protocol1.message, protocol1.dataStream);
await dwn.processMessage(alice.did, protocol2.message, protocol2.dataStream);
await dwn.processMessage(alice.did, protocol3.message, protocol3.dataStream);
await dwn.processMessage(alice.did, protocol1.message);
await dwn.processMessage(alice.did, protocol2.message);
await dwn.processMessage(alice.did, protocol3.message);

// testing unauthenticated conditional query
const conditionalQuery = await ProtocolsQuery.create({
Expand Down
35 changes: 17 additions & 18 deletions tests/handlers/records-read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes image to her DWN
Expand Down Expand Up @@ -250,7 +250,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes a message to the minimal protocol
Expand Down Expand Up @@ -292,7 +292,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition,
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes an email with Bob as recipient
Expand Down Expand Up @@ -347,7 +347,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes an email with Bob as recipient
Expand Down Expand Up @@ -396,7 +396,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolConfigReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolConfigReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolConfigReply.status.code).to.equal(202);

const foo1Write = await TestDataGenerator.generateRecordsWrite({
Expand Down Expand Up @@ -432,7 +432,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolConfigReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolConfigReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolConfigReply.status.code).to.equal(202);

const foo1Write = await TestDataGenerator.generateRecordsWrite({
Expand Down Expand Up @@ -704,7 +704,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes a record which Bob will later try to read
Expand Down Expand Up @@ -768,7 +768,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes a record which Bob will later try to read
Expand Down Expand Up @@ -832,7 +832,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes a record which Bob will later try to read
Expand Down Expand Up @@ -886,7 +886,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes a record which Bob will later try to read
Expand Down Expand Up @@ -939,7 +939,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes a record which Bob will later try to read
Expand Down Expand Up @@ -992,7 +992,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes a record which Bob will later try to read
Expand Down Expand Up @@ -1046,7 +1046,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes a record which Bob will later try to read
Expand Down Expand Up @@ -1099,7 +1099,7 @@ export function testRecordsReadHandler(): void {
author: alice,
protocolDefinition
});
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message, protocolsConfig.dataStream);
const protocolWriteReply = await dwn.processMessage(alice.did, protocolsConfig.message);
expect(protocolWriteReply.status.code).to.equal(202);

// Alice writes a record which Bob will later try to read
Expand Down Expand Up @@ -1565,8 +1565,7 @@ export function testRecordsReadHandler(): void {

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

Expand All @@ -1578,7 +1577,7 @@ export function testRecordsReadHandler(): void {
protocolDefinition : encryptedProtocolDefinitionForBob
});

const protocolsConfigureReply = await dwn.processMessage(bob.did, protocolsConfigureForBob.message, protocolsConfigureForBob.dataStream);
const protocolsConfigureReply = await dwn.processMessage(bob.did, protocolsConfigureForBob.message);
expect(protocolsConfigureReply.status.code).to.equal(202);

// Bob queries for Alice's chat protocol definition
Expand Down Expand Up @@ -1719,7 +1718,7 @@ export function testRecordsReadHandler(): void {
protocolDefinition : encryptedProtocolDefinition
});

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

// Bob queries for Alice's email protocol definition
Expand Down
Loading