fixed karma test

This commit is contained in:
Marek Kotewicz 2015-03-07 17:43:51 +01:00
parent 75e92c8048
commit 0b9d450a4d
6 changed files with 35 additions and 17 deletions

21
dist/ethereum.js vendored
View File

@ -972,7 +972,7 @@ var padLeft = function (string, chars, sign) {
var formatInputInt = function (value) {
/*jshint maxcomplexity:7 */
var padding = c.ETH_PADDING * 2;
if (value instanceof BigNumber || typeof value === 'number') {
if (utils.isBigNumber(value) || typeof value === 'number') {
if (typeof value === 'number')
value = new BigNumber(value);
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
@ -982,10 +982,13 @@ var formatInputInt = function (value) {
value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
value = value.toString(16);
}
else if (value.indexOf('0x') === 0)
value = value.substr(2);
else if (typeof value === 'string')
value = formatInputInt(new BigNumber(value));
else if (typeof value === 'string') {
if (value.indexOf('0x') === 0) {
value = value.substr(2);
} else {
value = formatInputInt(new BigNumber(value));
}
}
else
value = (+value).toString(16);
return padLeft(value, padding);
@ -1958,6 +1961,11 @@ var isAddress = function(address) {
return /^\w+$/.test(address);
};
var isBigNumber = function (value) {
return value instanceof BigNumber ||
(value && value.constructor && value.constructor.name === 'BigNumber');
};
module.exports = {
findIndex: findIndex,
@ -1972,7 +1980,8 @@ module.exports = {
toEth: toEth,
toWei: toWei,
fromWei: fromWei,
isAddress: isAddress
isAddress: isAddress,
isBigNumber: isBigNumber
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -22,8 +22,8 @@ module.exports = function (config) {
// list of files / patterns to load in the browser
files: [
'node_modules/bignumber.js/bignumber.js',
'test/*.js',
],

View File

@ -42,7 +42,7 @@ var padLeft = function (string, chars, sign) {
var formatInputInt = function (value) {
/*jshint maxcomplexity:7 */
var padding = c.ETH_PADDING * 2;
if (value instanceof BigNumber || typeof value === 'number') {
if (utils.isBigNumber(value) || typeof value === 'number') {
if (typeof value === 'number')
value = new BigNumber(value);
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
@ -52,10 +52,13 @@ var formatInputInt = function (value) {
value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
value = value.toString(16);
}
else if (value.indexOf('0x') === 0)
value = value.substr(2);
else if (typeof value === 'string')
value = formatInputInt(new BigNumber(value));
else if (typeof value === 'string') {
if (value.indexOf('0x') === 0) {
value = value.substr(2);
} else {
value = formatInputInt(new BigNumber(value));
}
}
else
value = (+value).toString(16);
return padLeft(value, padding);

View File

@ -287,6 +287,11 @@ var isAddress = function(address) {
return /^\w+$/.test(address);
};
var isBigNumber = function (value) {
return value instanceof BigNumber ||
(value && value.constructor && value.constructor.name === 'BigNumber');
};
module.exports = {
findIndex: findIndex,
@ -301,6 +306,7 @@ module.exports = {
toEth: toEth,
toWei: toWei,
fromWei: fromWei,
isAddress: isAddress
isAddress: isAddress,
isBigNumber: isBigNumber
};