ethers.js/packages/testcases/lib/index.js

29 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-05-15 01:48:48 +03:00
'use strict';
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = __importDefault(require("fs"));
var path_1 = __importDefault(require("path"));
var browserify_zlib_1 = __importDefault(require("browserify-zlib"));
var random_1 = require("./random");
exports.randomBytes = random_1.randomBytes;
exports.randomHexString = random_1.randomHexString;
exports.randomNumber = random_1.randomNumber;
2019-05-15 01:48:48 +03:00
function saveTests(tag, data) {
//let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz');
2020-01-07 03:00:55 +03:00
var filename = path_1.default.resolve(__dirname, '../testcases', tag + '.json.gz');
2019-05-15 01:48:48 +03:00
fs_1.default.writeFileSync(filename, browserify_zlib_1.default.gzipSync(JSON.stringify(data, undefined, ' ') + '\n'));
console.log('Save testcase: ' + filename);
}
exports.saveTests = saveTests;
function loadTests(tag) {
var filename = path_1.default.resolve(__dirname, '../testcases', tag + '.json.gz');
2019-05-15 01:48:48 +03:00
return JSON.parse(browserify_zlib_1.default.gunzipSync(fs_1.default.readFileSync(filename)).toString());
}
exports.loadTests = loadTests;
function loadData(filename) {
return fs_1.default.readFileSync(path_1.default.resolve(__dirname, filename));
}
exports.loadData = loadData;