fix: Prevent invalid map bounds #123

This commit is contained in:
Janez T
2026-03-16 22:16:36 +01:00
parent cfd233d38e
commit 993563f059
11 changed files with 129 additions and 25 deletions

View File

@@ -94,4 +94,37 @@ void main() {
expect(await MeshMapNodesService.loadCachedNodes(), isEmpty);
expect(await MeshMapNodesService.cachedAt(), isNull);
});
test('fetchNodes ignores nodes with invalid coordinates', () async {
final client = MockClient(
(_) async => http.Response(
jsonEncode({
'nodes': [
{
'type': 1,
'name': 'Broken',
'public_key': 'bad123',
'latitude': 3213.0,
'longitude': 14.50,
'updated_at': 123456,
},
{
'type': 1,
'name': 'Alpha',
'public_key': 'aa11bb22',
'latitude': 46.05,
'longitude': 14.50,
'updated_at': 123456,
},
],
}),
200,
),
);
final nodes = await MeshMapNodesService.fetchNodes(client: client);
expect(nodes, hasLength(1));
expect(nodes.first.name, 'Alpha');
});
}