Files
hash-wallet/test/bundled_yaml_valid_test.dart
jwinterm acccba9210 fix: remove duplicate useSSL key in polygon_node_list.yml (runtime crash)
package:yaml (used by the app) throws 'Duplicate mapping key' on the two
useSSL entries; PyYAML tolerated it so it slipped through. Adds a test that
parses every bundled YAML asset with package:yaml to prevent regression.
2026-08-30 04:55:28 -04:00

30 lines
1.1 KiB
Dart

import 'dart:io';
import 'package:yaml/yaml.dart';
import 'package:flutter_test/flutter_test.dart';
// Guards against the 1.0.2-era crash: a duplicate mapping key in a bundled
// node list (polygon_node_list.yml had two `useSSL`). PyYAML tolerates it,
// but the app parses with package:yaml, which throws "Duplicate mapping key"
// at runtime. Every bundled *.yml the app can loadYaml() must parse cleanly.
void main() {
test('all bundled node-list YAML assets parse under package:yaml', () {
final dir = Directory('assets');
final ymls = dir
.listSync(recursive: true)
.whereType<File>()
.where((f) => f.path.endsWith('.yml') || f.path.endsWith('.yaml'))
.toList();
expect(ymls, isNotEmpty, reason: 'no YAML assets found — wrong CWD?');
final failures = <String>[];
for (final f in ymls) {
try {
loadYaml(f.readAsStringSync());
} catch (e) {
failures.add('${f.path}: $e');
}
}
expect(failures, isEmpty, reason: 'YAML assets rejected by package:yaml:\n${failures.join('\n')}');
});
}