Skip to content

Commit 0bf631a

Browse files
committed
Another test for expired tokens
1 parent 9f22d2e commit 0bf631a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/powersync_core/test/in_memory_sync_test.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,28 @@ void main() {
701701
await Future<void>.delayed(const Duration(milliseconds: 500));
702702
expect(syncService.controller.hasListener, isTrue);
703703
});
704+
705+
test('closes connection after token expires', () async {
706+
final status = await waitForConnection(expectNoWarnings: false);
707+
syncService.addLine({
708+
'checkpoint': Checkpoint(
709+
lastOpId: '4',
710+
writeCheckpoint: null,
711+
checksums: [checksum(bucket: 'a', checksum: 10)],
712+
)
713+
});
714+
715+
await expectLater(status, emits(isSyncStatus(downloading: true)));
716+
syncService.addKeepAlive(0);
717+
718+
await pumpEventQueue();
719+
expect(syncService.controller.hasListener, isFalse);
720+
syncService.endCurrentListener();
721+
722+
// Should reconnect after delay.
723+
await Future<void>.delayed(const Duration(milliseconds: 500));
724+
expect(syncService.controller.hasListener, isTrue);
725+
});
704726
});
705727
}
706728

0 commit comments

Comments
 (0)