Skip to content

Commit 3794d69

Browse files
committed
Another test for expired tokens
1 parent 2cb7142 commit 3794d69

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
@@ -730,6 +730,28 @@ void main() {
730730
await Future<void>.delayed(const Duration(milliseconds: 500));
731731
expect(syncService.controller.hasListener, isTrue);
732732
});
733+
734+
test('closes connection after token expires', () async {
735+
final status = await waitForConnection(expectNoWarnings: false);
736+
syncService.addLine({
737+
'checkpoint': Checkpoint(
738+
lastOpId: '4',
739+
writeCheckpoint: null,
740+
checksums: [checksum(bucket: 'a', checksum: 10)],
741+
)
742+
});
743+
744+
await expectLater(status, emits(isSyncStatus(downloading: true)));
745+
syncService.addKeepAlive(0);
746+
747+
await pumpEventQueue();
748+
expect(syncService.controller.hasListener, isFalse);
749+
syncService.endCurrentListener();
750+
751+
// Should reconnect after delay.
752+
await Future<void>.delayed(const Duration(milliseconds: 500));
753+
expect(syncService.controller.hasListener, isTrue);
754+
});
733755
});
734756
}
735757

0 commit comments

Comments
 (0)