Skip to content

Commit dcabf18

Browse files
committed
Switch sync state to Synced after NeighboudhoodCreationInitiated
1 parent 448804d commit dcabf18

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

rust-executor/src/perspectives/perspective_instance.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,12 @@ impl PerspectiveInstance {
281281
let mut link_language_guard = self.link_language.lock().await;
282282
if let Some(link_language) = link_language_guard.as_mut() {
283283
match link_language.sync().await {
284-
Ok(_) => (),
284+
Ok(_) => {
285+
// Transition to Synced state on successful sync
286+
let _ = self
287+
.update_perspective_state(PerspectiveState::Synced)
288+
.await;
289+
}
285290
Err(e) => {
286291
log::error!("Error calling sync on link language: {:?}", e);
287292
let _ = self

tests/js/tests/neighbourhood.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,20 @@ export default function neighbourhoodTests(testContext: TestContext) {
4242
expect(perspective?.neighbourhood).not.to.be.undefined;
4343
expect(perspective?.neighbourhood!.data.linkLanguage).to.be.equal(socialContext.address);
4444
expect(perspective?.neighbourhood!.data.meta.links.length).to.be.equal(1);
45-
expect(perspective?.state).to.be.equal(PerspectiveState.Synced);
45+
46+
// The perspective should start in NeighbourhoodCreationInitiated state
47+
expect(perspective?.state).to.be.equal(PerspectiveState.NeighboudhoodCreationInitiated);
48+
49+
// Wait for the perspective to transition to Synced state
50+
let tries = 0;
51+
const maxTries = 10;
52+
let currentPerspective = perspective;
53+
while (currentPerspective?.state !== PerspectiveState.Synced && tries < maxTries) {
54+
await sleep(1000);
55+
currentPerspective = await ad4mClient.perspective.byUUID(create.uuid);
56+
tries++;
57+
}
58+
expect(currentPerspective?.state).to.be.equal(PerspectiveState.Synced);
4659
})
4760

4861
it('can be created by Alice and joined by Bob', async () => {

0 commit comments

Comments
 (0)