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/tool/release_copy.dart

57 lines
2.0 KiB

Specification 0.15: the release object, a release in hand and step 9.c specVersion is 0.15 and testdata is synced with datekeys-go at 3c3e737 (branch v0.15): every file changes its spec field, mutations.json gains the field source and four cases, and vectors/release.json and releases/ are new (142 files). release.dart, as provider of Go at 2eeca40, with its texts: encodeRelease and decodeRelease of the release object (spec v0.15, 47.1) with the CBOR profile of the library, its size first, then its type and version, then its schema; parseRelease, which also reads drand's JSON with the rules of encoding/json of Go for its three fields; verifyRelease checks the chain hash a release names, ERR_PROFILE_MISMATCH, before its round and its signature; ReleaseSupplier, EncodedRelease and supplyRelease, a release in the caller's hand; and ReleaseArchive, the lookup of a local release archive (50), whose failures are ERR_RELEASE_UNAVAILABLE at step 9. open: OpenOptions.release takes a release in hand, exclusive with source. It is not compared with the clock (step 9.c); Opened.clockBehind reports a clock behind it, and the step 9 detail is Go's. Step 10 starts with the layers of the object. A network source keeps its behaviour. Opened.release carries the chain hash of the pinned profile. Vectors: mutation_texts.json is regenerated with tool/mutation_go_texts.go, which now replays each case with its source as testkit does: 149 cases change only the detail of step 9 ("release supplied by the caller"), the case "round not reached yet" now opens, and the four new cases are added. release_vectors.json, the open vectors, and the formats, locator, security and seal vectors come out the same at 3c3e737 but for their spec field. tool/release_archive_go_texts.go writes the texts of provider.Archive on edited archives; tool/release_copy.dart copies release.json, releases/ and those texts to release.g.dart for the tests compiled to JavaScript. errors_spec_test reads the spec at the commit of testdata/SOURCE.json rather than at its tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
24 hours ago
// Writes test/vectors/release.g.dart: the text of
// testdata/vectors/release.json, every file of testdata/releases/ in
// hexadecimal, and the text of test/vectors/release_archive_texts.json, as
// Dart constants for test/release_object_test.dart compiled to JavaScript,
// where no file can be read. test/release_object_vm_test.dart checks that
// the copy is the files byte for byte. Run it after every sync of testdata/.
//
// dart run tool/release_copy.dart
import 'dart:io';
void main() {
final root = File(Platform.script.toFilePath()).parent.parent;
String text(String path) {
final s = File('${root.path}/$path').readAsStringSync();
if (s.contains("'''")) throw StateError('$path holds three quotes');
return s;
}
final files =
Directory('${root.path}/testdata/releases')
.listSync()
.whereType<File>()
.toList()
..sort((a, b) => a.path.compareTo(b.path));
final out = StringBuffer()
..write(
'// Generated by tool/release_copy.dart from\n'
'// testdata/vectors/release.json, testdata/releases/ and\n'
'// test/vectors/release_archive_texts.json, for the tests that also\n'
'// run compiled to JavaScript, where no file can be read. Do not edit.\n'
'\n'
'/// The text of testdata/vectors/release.json.\n'
"const releaseJson = r'''\n"
"${text('testdata/vectors/release.json')}''';\n"
'\n'
'/// The files of testdata/releases/, by name, in hexadecimal.\n'
'const releaseFiles = {\n',
);
for (final f in files) {
final name = f.uri.pathSegments.last;
final hex = [
for (final b in f.readAsBytesSync()) b.toRadixString(16).padLeft(2, '0'),
].join();
out.write(" '$name': '$hex',\n");
}
out.write(
'};\n'
'\n'
'/// The text of test/vectors/release_archive_texts.json.\n'
"const releaseArchiveTextsJson = r'''\n"
"${text('test/vectors/release_archive_texts.json')}''';\n",
);
File('${root.path}/test/vectors/release.g.dart')
.writeAsStringSync(out.toString());
}

Powered by TurnKey Linux.