// The public note of spec ยง24.1 against Go: test/vectors/open_notes.json, // which tool/open_go_vectors.go writes with extension.CheckNote, Note, // Header.UnusableNote and extension.Standard of the reference. @TestOn('vm') library; import 'dart:convert'; import 'dart:io'; import 'package:datekeys/datekeys.dart'; import 'package:test/test.dart'; import 'open_vectors_support.dart'; Json readJson(String path) => jsonDecode(File(path).readAsStringSync()) as Json; void main() { test('open_notes.json: every note as in Go', () { final f = readJson('test/vectors/open_notes.json'); expect(f['spec'], specVersion); final check = (f['check']! as List).cast(); expect(check, hasLength(greaterThan(300))); expect(check.where((c) => c['result'] == 'ok'), hasLength(greaterThan(10))); checkNoteCases( check, (f['note']! as List).cast(), (f['standard']! as List).cast(), ); }); test('the note of a header, as PublicNote and UnusableNote of Go', () { final r = jsonDecode( File('testdata/fixtures/time_only_extensions.json').readAsStringSync(), ) as Json; final h = decodeHeader(fromHex(r['public_header']! as String)); expect([h.publicNote, h.unusableNote], [null, false]); final noted = Header( capsuleId: h.capsuleId, dateKey: h.dateKey, policy: h.policy, noncritical: [newNote('Cartas del viaje a Lisboa'), ...h.noncritical], ); expect( [noted.publicNote, noted.unusableNote], ['Cartas del viaje a Lisboa', false], ); final bad = Header( capsuleId: h.capsuleId, dateKey: h.dateKey, policy: h.policy, noncritical: [Extension(noteExtensionId, 1, fromHex('610962'))], ); expect([bad.publicNote, bad.unusableNote], [null, true]); }); }