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
63 lines
1.0 KiB
JavaScript
63 lines
1.0 KiB
JavaScript
|
|
var Promise = require('any-promise')
|
|
var fs
|
|
try {
|
|
fs = require('graceful-fs')
|
|
} catch(err) {
|
|
fs = require('fs')
|
|
}
|
|
|
|
var api = [
|
|
'appendFile',
|
|
'chmod',
|
|
'chown',
|
|
'close',
|
|
'fchmod',
|
|
'fchown',
|
|
'fdatasync',
|
|
'fstat',
|
|
'fsync',
|
|
'ftruncate',
|
|
'futimes',
|
|
'lchown',
|
|
'link',
|
|
'lstat',
|
|
'mkdir',
|
|
'open',
|
|
'read',
|
|
'readFile',
|
|
'readdir',
|
|
'readlink',
|
|
'realpath',
|
|
'rename',
|
|
'rmdir',
|
|
'stat',
|
|
'symlink',
|
|
'truncate',
|
|
'unlink',
|
|
'utimes',
|
|
'write',
|
|
'writeFile'
|
|
]
|
|
|
|
typeof fs.access === 'function' && api.push('access')
|
|
typeof fs.copyFile === 'function' && api.push('copyFile')
|
|
typeof fs.mkdtemp === 'function' && api.push('mkdtemp')
|
|
|
|
require('thenify-all').withCallback(fs, exports, api)
|
|
|
|
exports.exists = function (filename, callback) {
|
|
// callback
|
|
if (typeof callback === 'function') {
|
|
return fs.stat(filename, function (err) {
|
|
callback(null, !err);
|
|
})
|
|
}
|
|
// or promise
|
|
return new Promise(function (resolve) {
|
|
fs.stat(filename, function (err) {
|
|
resolve(!err)
|
|
})
|
|
})
|
|
}
|