From 9bc09fa1eb870cc4bdc803745fe5edd4ab88f3e9 Mon Sep 17 00:00:00 2001 From: Alex Good Date: Fri, 26 Jul 2024 13:52:25 +0100 Subject: [PATCH] fix rebase conflicts --- packages/automerge-repo/src/Repo.ts | 6 +++++- packages/automerge-repo/test/Repo.test.ts | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/automerge-repo/src/Repo.ts b/packages/automerge-repo/src/Repo.ts index 08e27d6c0..0d28335a3 100644 --- a/packages/automerge-repo/src/Repo.ts +++ b/packages/automerge-repo/src/Repo.ts @@ -23,6 +23,10 @@ import { CollectionSynchronizer } from "./synchronizer/CollectionSynchronizer.js import { SyncStatePayload } from "./synchronizer/Synchronizer.js" import type { AnyDocumentId, DocumentId, PeerId } from "./types.js" +function randomPeerId() { + return ("peer-" + Math.random().toString(36).slice(4)) as PeerId +} + /** A Repo is a collection of documents with networking, syncing, and storage capabilities. */ /** The `Repo` is the main entry point of this library * @@ -61,7 +65,7 @@ export class Repo extends EventEmitter { constructor({ storage, network = [], - peerId, + peerId = randomPeerId(), sharePolicy, isEphemeral = storage === undefined, enableRemoteHeadsGossiping = false, diff --git a/packages/automerge-repo/test/Repo.test.ts b/packages/automerge-repo/test/Repo.test.ts index 5ca54aeb8..2a40a38a8 100644 --- a/packages/automerge-repo/test/Repo.test.ts +++ b/packages/automerge-repo/test/Repo.test.ts @@ -1263,7 +1263,6 @@ describe("Repo", () => { aliceDoc.change((doc: any) => (doc.text = "Hello world")) const bobDoc = bobRepo.find(aliceDoc.url) - bobDoc.unavailable() await eventPromise(bobDoc, "unavailable") aliceAdapter.peerCandidate(bob)