One Flutter client for network-computer: drive a remote Linux/Mac desktop from Android, iPhone, iPad, or desktop over WebRTC.

0 downloads

network-computer-flutter/test/protocol_test.dart
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/network-computer-flutter.git
HTTPS
https://gitstable.com/git/askrobots/network-computer-flutter.git
SSH
ssh://git@gitstable.com:2222/askrobots/network-computer-flutter.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Dan Quellhorst No colour (compare) in ⋯: the desk's picture in grey on this device c74471a 1 month, 3 weeks ago History
protocol_test.dart · 1.2 KB · 32 lines
1import 'dart:convert';
2import 'package:flutter_test/flutter_test.dart';
3import 'package:network_computer/protocol.dart';
4import 'package:network_computer/signaling.dart';
5
6void main() {
7 test('offer carries pin and pairing token in the Go field names', () {
8 final m = SignalMessage(type: 'offer', to: 'box', sdp: 'v=0', pin: '424242', pair: 'abc.def');
9 final j = jsonDecode(jsonEncode(m.toJson())) as Map<String, dynamic>;
10 expect(j['pin'], '424242');
11 expect(j['pair'], 'abc.def');
12 });
13
14 test('answer from the host yields its pairing token', () {
15 final m = SignalMessage.fromJson(
16 {'type': 'answer', 'from': 'c3', 'sdp': 'v=0', 'pair': 'tok.sig'});
17 expect(m.pair, 'tok.sig');
18 });
19
20 test('absent fields are omitted, not sent as null', () {
21 final j = SignalMessage(type: 'offer', to: 'box', sdp: 'v=0').toJson();
22 expect(j.containsKey('pin'), isFalse);
23 expect(j.containsKey('pair'), isFalse);
24 });
25
26 test('fingerprints normalise from any common format', () {
27 const hex = 'ab12cd34';
28 expect(normalizeFingerprint('AB:12:CD:34'), hex);
29 expect(normalizeFingerprint('sha256 ab12cd34'), hex);
30 expect(normalizeFingerprint(' AB12CD34 '), hex);
31 });
32}