chain-client-sdk-dart/test/fai_dart_sdk_test.dart
flemming-it da10820959 feat: live HubClient with generated proto bindings
Proto codegen wired in. tools/generate.sh wraps protoc against
../fai_platform/proto/, including the well-known types (Empty,
Struct, Timestamp) so they are generated alongside fai's own
messages — protobuf 4.x doesn't ship them as importable Dart
types, so we have to generate them ourselves.

HubClient now exposes typed methods backed by real RPCs:
- healthy() — Hub.Health probe (returns false on connect refused).
- listCapabilities() — HubAdmin.ListCapabilities.
- eventLog() — HubAdmin.EventLog with type filter.
- listApprovals() — HubAdmin.ListApprovals (status filter).
- approve() / reject() — HubAdmin.DecideApproval.

Generated bindings under lib/src/generated/ are excluded from
analyze (out of our style control). protoc_plugin pinned to
22.2.0 in tools/generate.sh comment because newer plugins
generate code against protobuf 6.x, while grpc 4.x still
constrains us to protobuf 4.x.

Bumps fai_dart_sdk 0.1.0 -> 0.2.0.

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
2026-05-05 16:24:16 +02:00

31 lines
840 B
Dart

import 'package:fai_dart_sdk/fai_dart_sdk.dart';
import 'package:test/test.dart';
void main() {
group('HubEndpoint', () {
test('default endpoint targets local fai serve', () {
const e = HubEndpoint();
expect(e.host, '127.0.0.1');
expect(e.port, 50051);
expect(e.secure, false);
expect(e.toString(), 'http://127.0.0.1:50051');
});
test('secure flag flips scheme', () {
const e = HubEndpoint(host: 'hub.example', port: 443, secure: true);
expect(e.toString(), 'https://hub.example:443');
});
});
group('HubClient', () {
test('constructs with default endpoint', () {
final c = HubClient();
expect(c.endpoint.host, '127.0.0.1');
});
test('close shuts the channel cleanly', () async {
final c = HubClient();
await c.close();
});
});
}