mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
- Removed all Snow consensus code and dependencies - Replaced snow.Context with consensuscontext.Context - Updated all imports and references - Added comprehensive test suites for core packages - Fixed all build errors and test failures - Achieved 100% test pass rate (21 packages passing) - Improved test coverage to 30% Breaking changes: - Removed snow package entirely - Changed VM interface to use VMState instead of snow.State - Updated ChainContext structure Tests added: - core/app_error_test.go: 100% coverage - core/bootstrap_test.go: comprehensive concurrent tests - core/health_test.go: full integration tests - validators/validators_test.go: complete interface tests - version/version_test.go: 100% coverage - codec/codec_test.go: marshal/unmarshal tests - context/context_test.go: all functions tested
67 lines
2.0 KiB
JavaScript
67 lines
2.0 KiB
JavaScript
'use strict';
|
|
|
|
var ruleModules = require('../dotjs')
|
|
, toHash = require('./util').toHash;
|
|
|
|
module.exports = function rules() {
|
|
var RULES = [
|
|
{ type: 'number',
|
|
rules: [ { 'maximum': ['exclusiveMaximum'] },
|
|
{ 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
|
|
{ type: 'string',
|
|
rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
|
|
{ type: 'array',
|
|
rules: [ 'maxItems', 'minItems', 'items', 'contains', 'uniqueItems' ] },
|
|
{ type: 'object',
|
|
rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
|
|
{ 'properties': ['additionalProperties', 'patternProperties'] } ] },
|
|
{ rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if' ] }
|
|
];
|
|
|
|
var ALL = [ 'type', '$comment' ];
|
|
var KEYWORDS = [
|
|
'$schema', '$id', 'id', '$data', '$async', 'title',
|
|
'description', 'default', 'definitions',
|
|
'examples', 'readOnly', 'writeOnly',
|
|
'contentMediaType', 'contentEncoding',
|
|
'additionalItems', 'then', 'else'
|
|
];
|
|
var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
|
|
RULES.all = toHash(ALL);
|
|
RULES.types = toHash(TYPES);
|
|
|
|
RULES.forEach(function (group) {
|
|
group.rules = group.rules.map(function (keyword) {
|
|
var implKeywords;
|
|
if (typeof keyword == 'object') {
|
|
var key = Object.keys(keyword)[0];
|
|
implKeywords = keyword[key];
|
|
keyword = key;
|
|
implKeywords.forEach(function (k) {
|
|
ALL.push(k);
|
|
RULES.all[k] = true;
|
|
});
|
|
}
|
|
ALL.push(keyword);
|
|
var rule = RULES.all[keyword] = {
|
|
keyword: keyword,
|
|
code: ruleModules[keyword],
|
|
implements: implKeywords
|
|
};
|
|
return rule;
|
|
});
|
|
|
|
RULES.all.$comment = {
|
|
keyword: '$comment',
|
|
code: ruleModules.$comment
|
|
};
|
|
|
|
if (group.type) RULES.types[group.type] = group;
|
|
});
|
|
|
|
RULES.keywords = toHash(ALL.concat(KEYWORDS));
|
|
RULES.custom = {};
|
|
|
|
return RULES;
|
|
};
|