Skip to content

Commit 8503315

Browse files
chore: fix API
1 parent e396c3b commit 8503315

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/sds/src/message_channel/message_channel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export class MessageChannel extends TypedEventEmitter<MessageChannelEvents> {
113113
this.possibleAcks = new Map();
114114
this.incomingBuffer = [];
115115
this.localHistory =
116-
localHistory ?? new LocalHistory({ storagePrefix: channelId });
116+
localHistory ?? new LocalHistory({ storage: { prefix: channelId } });
117117
this.causalHistorySize =
118118
options.causalHistorySize ?? DEFAULT_CAUSAL_HISTORY_SIZE;
119119
// TODO: this should be determined based on the bloom filter parameters and number of hashes

packages/sds/src/message_channel/persistent_storage.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ describe("Storage", () => {
1818
});
1919

2020
it("persists and restores messages", () => {
21-
const history1 = new LocalHistory({ storagePrefix: channelId });
21+
const history1 = new LocalHistory({ storage: { prefix: channelId } });
2222
history1.push(createMessage("msg-1", 1));
2323
history1.push(createMessage("msg-2", 2));
2424

25-
const history2 = new LocalHistory({ storagePrefix: channelId });
25+
const history2 = new LocalHistory({ storage: { prefix: channelId } });
2626

2727
expect(history2.length).to.equal(2);
2828
expect(history2.slice(0).map((msg) => msg.messageId)).to.deep.equal([
@@ -34,15 +34,15 @@ describe("Storage", () => {
3434
it("handles corrupt data gracefully", () => {
3535
localStorage.setItem(`waku:sds:storage:${channelId}`, "{ invalid json }");
3636

37-
const history = new LocalHistory({ storagePrefix: channelId });
37+
const history = new LocalHistory({ storage: { prefix: channelId } });
3838
expect(history.length).to.equal(0);
3939
// Corrupt data is removed
4040
expect(localStorage.getItem(`waku:sds:storage:${channelId}`)).to.be.null;
4141
});
4242

4343
it("isolates history by channel ID", () => {
44-
const history1 = new LocalHistory({ storagePrefix: "channel-1" });
45-
const history2 = new LocalHistory({ storagePrefix: "channel-2" });
44+
const history1 = new LocalHistory({ storage: { prefix: "channel-1" } });
45+
const history2 = new LocalHistory({ storage: { prefix: "channel-2" } });
4646

4747
history1.push(createMessage("msg-1", 1));
4848
history2.push(createMessage("msg-2", 2));
@@ -57,7 +57,7 @@ describe("Storage", () => {
5757
});
5858

5959
it("saves messages after each push", () => {
60-
const history = new LocalHistory({ storagePrefix: channelId });
60+
const history = new LocalHistory({ storage: { prefix: channelId } });
6161

6262
expect(localStorage.getItem(`waku:sds:storage:${channelId}`)).to.be.null;
6363

@@ -74,13 +74,13 @@ describe("Storage", () => {
7474
});
7575

7676
it("loads messages on initialization", () => {
77-
const history1 = new LocalHistory({ storagePrefix: channelId });
77+
const history1 = new LocalHistory({ storage: { prefix: channelId } });
7878

7979
history1.push(createMessage("msg-1", 1));
8080
history1.push(createMessage("msg-2", 2));
8181
history1.push(createMessage("msg-3", 3));
8282

83-
const history2 = new LocalHistory({ storagePrefix: channelId });
83+
const history2 = new LocalHistory({ storage: { prefix: channelId } });
8484

8585
expect(history2.length).to.equal(3);
8686
expect(history2.slice(0).map((m) => m.messageId)).to.deep.equal([

0 commit comments

Comments
 (0)