Skip to content

Commit

Permalink
Fix mismatched stopSyncing call which could cause test pollution
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed Jan 29, 2024
1 parent 5d38d2d commit 0c376f3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions internal/api/rust/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func (c *RustClient) StartSyncing(t ct.TestLike) (stopSyncing func(), err error)
return func() {
t.Logf("%s: Stopping sync service", c.userID)
syncService.Stop()
syncService.Destroy()
}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ func main() {
if err := client.Login(t, cfg); err != nil {
panic(err)
}
client.MustStartSyncing(t)
stopSyncing := client.MustStartSyncing(t)
defer client.Close(t)
defer stopSyncing()
roomID := "{{.RoomID}}"
fmt.Println("Client logged in. Sending '{{.Body}}' in room {{.RoomID}}")
eventID := client.SendMessage(t, "{{.RoomID}}", "{{.Body}}")
Expand Down
4 changes: 2 additions & 2 deletions tests/room_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,10 @@ func testRoomKeyIsNotCycledOnClientRestartJS(t *testing.T, clientType api.Client

// Alice and Bob are in a room.
alice := tc.MustLoginClient(t, tc.Alice, clientType, WithPersistentStorage())
aliceStopSyncing := alice.MustStartSyncing(t)
// no close here as we'll close it in the test mid-way
bob := tc.MustLoginClient(t, tc.Bob, clientType)
defer bob.Close(t)
aliceStopSyncing := alice.MustStartSyncing(t)
defer aliceStopSyncing()
bobStopSyncing := bob.MustStartSyncing(t)
defer bobStopSyncing()

Expand Down Expand Up @@ -235,6 +234,7 @@ func testRoomKeyIsNotCycledOnClientRestartJS(t *testing.T, clientType api.Client
},
}, func() {
// now alice is going to restart her client
aliceStopSyncing()
alice.Close(t)

alice = tc.MustCreateClient(t, tc.Alice, clientType, WithPersistentStorage())
Expand Down
3 changes: 2 additions & 1 deletion tests/state_synchronisation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ func testSigkillBeforeKeysUploadResponseRust(t *testing.T, clientType api.Client
// now make the same client
alice := MustCreateClient(t, clientType, cfg, tc.Deployment.SlidingSyncURL(t))
alice.Login(t, cfg) // login should work
alice.MustStartSyncing(t)
stopSyncing := alice.MustStartSyncing(t)
// ensure we see the 2nd keys/upload
seenSecondKeysUploadWaiter.Wait(t, 5*time.Second)
stopSyncing()
alice.Close(t)
})
}
Expand Down

0 comments on commit 0c376f3

Please sign in to comment.