You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dateKeys-dart/test/formats_differential_vm_tes...

83 lines
2.2 KiB

Stage 4b: the differential of the formats against Go tool/formats_go_vectors.go runs in the module of datekeys-go at c531e93, without changing anything there, and writes test/vectors/formats_*.json: the result, the normative code and the text of Go on inputs of a fixed seed, valid and broken in every layer of spec §69.1, and on the fixtures of testdata/, edited: - the PRELUDE (229 cases), the steps 1 to 3 of capsule.Inspect on cut and edited fixtures (492) and whole .dkk files (268); - PUBLIC_HEADER (660) and CONTROL_CBOR of the three formats (618); - Provider Profiles decoded (163) and validated as values (60); - extension arrays (260), Canonical (80), CheckDisjoint (50), the registries with places (120) and CheckWrite with Standard (60); - dk1_ strings (466); - RFC 3339 parsed (434) and formatted (80), Resolve (320), RoundTime (64), Validate (128) and MaxRound (8), on profiles of other genesis times and periods; - PaddedLength and PayloadAgeLength at the boundaries up to L_MAX (474), and the check of the padding of capsule.Open at step 17 on fixtures whose PAYLOAD_AGE is encrypted again with an edited plaintext (56); - the encoders on values and the decoders at the limits of spec §57 (90); - the frame of BODY (260) and the zeros of the area (60). The output is the same on every run. formats_vectors.g.dart holds every eighth case as Dart constants, so that the differential runs compiled to JavaScript too, on Node.js; a test on the VM checks that they are those of the files. Every file is under 310 KB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 days ago
// The differential of the formats against the Go reference on the VM, with
// every case of test/vectors/formats_*.json and the fixtures of testdata/
// that the cases of the frame of a .dkc cut and edit. And the part of those
// files that formats_vectors.g.dart holds for the tests compiled to
// JavaScript, which must be every eighth case of each section.
@TestOn('vm')
library;
import 'dart:convert';
import 'dart:io';
import 'package:datekeys/src/version.dart';
Stage 4b: the differential of the formats against Go tool/formats_go_vectors.go runs in the module of datekeys-go at c531e93, without changing anything there, and writes test/vectors/formats_*.json: the result, the normative code and the text of Go on inputs of a fixed seed, valid and broken in every layer of spec §69.1, and on the fixtures of testdata/, edited: - the PRELUDE (229 cases), the steps 1 to 3 of capsule.Inspect on cut and edited fixtures (492) and whole .dkk files (268); - PUBLIC_HEADER (660) and CONTROL_CBOR of the three formats (618); - Provider Profiles decoded (163) and validated as values (60); - extension arrays (260), Canonical (80), CheckDisjoint (50), the registries with places (120) and CheckWrite with Standard (60); - dk1_ strings (466); - RFC 3339 parsed (434) and formatted (80), Resolve (320), RoundTime (64), Validate (128) and MaxRound (8), on profiles of other genesis times and periods; - PaddedLength and PayloadAgeLength at the boundaries up to L_MAX (474), and the check of the padding of capsule.Open at step 17 on fixtures whose PAYLOAD_AGE is encrypted again with an edited plaintext (56); - the encoders on values and the decoders at the limits of spec §57 (90); - the frame of BODY (260) and the zeros of the area (60). The output is the same on every run. formats_vectors.g.dart holds every eighth case as Dart constants, so that the differential runs compiled to JavaScript too, on Node.js; a test on the VM checks that they are those of the files. Every file is under 310 KB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 days ago
import 'package:test/test.dart';
import 'formats_differential.dart';
import 'vectors/formats_vectors.g.dart';
const names = [
'framing',
'header',
'control',
'profile',
'extension',
'datekey',
'time',
'padding',
'body',
'encode',
];
void main() {
final files = {
for (final n in names)
n: jsonDecode(
File('test/vectors/formats_$n.json').readAsStringSync(),
) as Json,
};
test('every file is of this specification and of its generator', () {
for (final f in files.values) {
expect(f['spec'], specVersion);
Stage 4b: the differential of the formats against Go tool/formats_go_vectors.go runs in the module of datekeys-go at c531e93, without changing anything there, and writes test/vectors/formats_*.json: the result, the normative code and the text of Go on inputs of a fixed seed, valid and broken in every layer of spec §69.1, and on the fixtures of testdata/, edited: - the PRELUDE (229 cases), the steps 1 to 3 of capsule.Inspect on cut and edited fixtures (492) and whole .dkk files (268); - PUBLIC_HEADER (660) and CONTROL_CBOR of the three formats (618); - Provider Profiles decoded (163) and validated as values (60); - extension arrays (260), Canonical (80), CheckDisjoint (50), the registries with places (120) and CheckWrite with Standard (60); - dk1_ strings (466); - RFC 3339 parsed (434) and formatted (80), Resolve (320), RoundTime (64), Validate (128) and MaxRound (8), on profiles of other genesis times and periods; - PaddedLength and PayloadAgeLength at the boundaries up to L_MAX (474), and the check of the padding of capsule.Open at step 17 on fixtures whose PAYLOAD_AGE is encrypted again with an edited plaintext (56); - the encoders on values and the decoders at the limits of spec §57 (90); - the frame of BODY (260) and the zeros of the area (60). The output is the same on every run. formats_vectors.g.dart holds every eighth case as Dart constants, so that the differential runs compiled to JavaScript too, on Node.js; a test on the VM checks that they are those of the files. Every file is under 310 KB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 days ago
expect(f['generator'], 'tool/formats_go_vectors.go');
}
});
formatsDifferential(
files,
testdata: (path) => File('testdata/$path').readAsBytesSync(),
);
group('formats_vectors.g.dart', () {
const embedded = {
'framing': formatsFramingJson,
'header': formatsHeaderJson,
'control': formatsControlJson,
'profile': formatsProfileJson,
'extension': formatsExtensionJson,
'datekey': formatsDatekeyJson,
'time': formatsTimeJson,
'padding': formatsPaddingJson,
'body': formatsBodyJson,
'encode': formatsEncodeJson,
};
for (final MapEntry(key: name, value: text) in embedded.entries) {
test('holds every eighth case of formats_$name.json', () {
final part = jsonDecode(text) as Json;
final file = files[name]!;
expect(part.keys, file.keys);
for (final key in file.keys) {
final value = file[key];
if (value is! List) {
expect(part[key], value);
continue;
}
expect(part[key], [
for (var i = 0; i < value.length; i += 8) value[i],
], reason: key);
}
});
}
});
}

Powered by TurnKey Linux.