Skip to content

Commit

Permalink
Updated misleading tests to match intent clearly
Browse files Browse the repository at this point in the history
  • Loading branch information
thehenrytsai committed Aug 7, 2024
1 parent 4cdc932 commit 9599803
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/handlers/records-write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3009,6 +3009,7 @@ export function testRecordsWriteHandler(): void {

// bob learns of metadata (ie. dataCid) of alice's secret data,
// attempts to gain unauthorized access by writing to alice's DWN through open protocol referencing the dataCid without supplying the data
// which he is allowed to do, the DWN will treat the operation as an initial-write or a record that has a later and different state.
const imageRecordsWrite = await TestDataGenerator.generateRecordsWrite({
author : bob,
protocol,
Expand All @@ -3019,7 +3020,7 @@ export function testRecordsWriteHandler(): void {
dataSize,
recipient : alice.did
});
const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream });
const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message);
expect(imageReply.status.code).to.equal(204); // allows write but is not readable or queryable

// verify the record is not able to be read
Expand Down Expand Up @@ -3101,6 +3102,7 @@ export function testRecordsWriteHandler(): void {

// bob learns of metadata (ie. dataCid) of alice's secret data,
// attempts to gain unauthorized access by writing to alice's DWN through open protocol referencing the dataCid without supplying the data
// which he is allowed to do, the DWN will treat the operation as an initial-write or a record that has a later and different state.
const imageRecordsWrite = await TestDataGenerator.generateRecordsWrite({
author : bob,
protocol,
Expand All @@ -3111,7 +3113,7 @@ export function testRecordsWriteHandler(): void {
dataSize,
recipient : alice.did
});
const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message, { dataStream: imageRecordsWrite.dataStream });
const imageReply = await dwn.processMessage(alice.did, imageRecordsWrite.message);
expect(imageReply.status.code).to.equal(204); // allows write but is not readable or queryable

// verify the record is not able to be read
Expand Down
1 change: 1 addition & 0 deletions tests/utils/test-data-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ export class TestDataGenerator {

/**
* Generates a RecordsWrite message for testing.
* `dataBytes` & `dataStream` returned will be `undefined` as long as `dataCid` or `dataSize` is given.
* Implementation currently uses `RecordsWrite.create()`.
* @param input.attesters Attesters of the message. Will NOT be generated if not given.
* @param input.data Data that belongs to the record. Generated when not given only if `dataCid` and `dataSize` are also not given.
Expand Down

0 comments on commit 9599803

Please sign in to comment.