mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 19:33:09 -06:00
Add a simple test for EDU-only updates in notifier_test.go
Signed-off-by: Alex Chen <minecnly@gmail.com>
This commit is contained in:
parent
18c59e68cd
commit
badd360fe6
|
|
@ -35,6 +35,7 @@ var (
|
||||||
syncPositionVeryOld types.SyncPosition
|
syncPositionVeryOld types.SyncPosition
|
||||||
syncPositionBefore types.SyncPosition
|
syncPositionBefore types.SyncPosition
|
||||||
syncPositionAfter types.SyncPosition
|
syncPositionAfter types.SyncPosition
|
||||||
|
syncPositionNewEDU types.SyncPosition
|
||||||
syncPositionAfter2 types.SyncPosition
|
syncPositionAfter2 types.SyncPosition
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -59,6 +60,9 @@ func init() {
|
||||||
syncPositionAfter = baseSyncPos
|
syncPositionAfter = baseSyncPos
|
||||||
syncPositionAfter.PDUPosition = 12
|
syncPositionAfter.PDUPosition = 12
|
||||||
|
|
||||||
|
syncPositionNewEDU = syncPositionAfter
|
||||||
|
syncPositionNewEDU.TypingPosition = 1
|
||||||
|
|
||||||
syncPositionAfter2 = baseSyncPos
|
syncPositionAfter2 = baseSyncPos
|
||||||
syncPositionAfter2.PDUPosition = 13
|
syncPositionAfter2.PDUPosition = 13
|
||||||
|
|
||||||
|
|
@ -175,6 +179,34 @@ func TestNewInviteEventForUser(t *testing.T) {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test an EDU-only update wakes up the request.
|
||||||
|
func TestEDUWakeup(t *testing.T) {
|
||||||
|
n := NewNotifier(syncPositionAfter)
|
||||||
|
n.setUsersJoinedToRooms(map[string][]string{
|
||||||
|
roomID: {alice, bob},
|
||||||
|
})
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
pos, err := waitForEvents(n, newTestSyncRequest(bob, syncPositionAfter))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("TestNewInviteEventForUser error: %s", err)
|
||||||
|
}
|
||||||
|
if pos != syncPositionNewEDU {
|
||||||
|
t.Errorf("TestNewInviteEventForUser want %d, got %d", syncPositionNewEDU, pos)
|
||||||
|
}
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
|
||||||
|
stream := n.fetchUserStream(bob, true)
|
||||||
|
waitForBlocking(stream, 1)
|
||||||
|
|
||||||
|
n.OnNewEvent(&aliceInviteBobEvent, "", nil, syncPositionNewEDU)
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
// Test that all blocked requests get woken up on a new event.
|
// Test that all blocked requests get woken up on a new event.
|
||||||
func TestMultipleRequestWakeup(t *testing.T) {
|
func TestMultipleRequestWakeup(t *testing.T) {
|
||||||
n := NewNotifier(syncPositionBefore)
|
n := NewNotifier(syncPositionBefore)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue