ethers.js/tests/utils.js

26 lines
614 B
JavaScript
Raw Normal View History

2016-07-27 00:58:17 +03:00
var crypto = require('crypto');
var utils = require('../lib/utils.js');
function random(lowerRandomInterval, upperOpenInterval) {
return lowerRandomInterval + parseInt((upperOpenInterval - lowerRandomInterval) * Math.random());
}
function randomBuffer(length) {
var buffer = crypto.randomBytes(length);
return buffer;
}
function randomHexString(length) {
return '0x' + randomBuffer(length).toString('hex');
}
module.exports = {
random: random,
randomBuffer: randomBuffer,
randomHexString: randomHexString,
isHexString: utils.isHexString,
hexOrBuffer: utils.hexOrBuffer,
}