import 'dart:convert'; import 'dart:io'; import '../lib/core/transport/ikar_network.dart'; import 'live_ikar_smoke.dart' as live; Future main() async { final stamp = DateTime.now().microsecondsSinceEpoch.toString().substring(6); final peer = await live.Device.create( Uri.parse('https://ikar.kusoft.xyz'), Platform.environment['IKAR_TEST_NODE'] ?? 'node', '+999$stamp', 'Video diagnostics', ); final client = IkarNetwork.client(); try { final info = (await peer.ok(82, {'count': 1}))['info'][0]; final request = await client.postUrl(Uri.parse(info['url'])); final bytes = await File('assets/debug/fake_video_note.mp4').readAsBytes(); request.headers.contentType = ContentType('video', 'mp4'); request.contentLength = bytes.length; request.add(bytes); final upload = await request.close(); live.check(upload.statusCode == 200, 'Video upload failed'); await upload.drain(); final sent = await peer.ok(64, { 'chatId': 0, 'message': { 'attaches': [{'_type': 'VIDEO', 'token': info['token']}], }, }); final message = sent['message']; final attachment = message['attaches'][0]; final sources = await peer.ok(83, { 'chatId': 0, 'messageId': message['id'], 'videoId': attachment['videoId'], 'token': attachment['token'], }); final report = { 'sourceKeys': sources.keys.toList(), 'attachmentKeys': (attachment as Map).keys.toList(), 'thumbnailPresent': attachment['thumbnail'] != null, }; await File('artifacts/video-sources-before.json').writeAsString(jsonEncode(report)); stdout.writeln(jsonEncode(report)); } finally { await peer.ok(199, {}); await peer.close(); client.close(force: true); } }