mirror of https://github.com/status-im/web3.js.git
merged develop
This commit is contained in:
commit
6f624be56c
|
@ -11,7 +11,6 @@ script:
|
|||
- "jshint *.js lib"
|
||||
after_script:
|
||||
- npm run-script build
|
||||
- npm run-script karma
|
||||
- npm run-script test-coveralls
|
||||
- cd test/node && npm install && node app.js
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
27
gulpfile.js
27
gulpfile.js
|
@ -17,7 +17,7 @@ var bower = require('bower');
|
|||
var streamify = require('gulp-streamify');
|
||||
var replace = require('gulp-replace');
|
||||
|
||||
var DEST = './dist/';
|
||||
var DEST = path.join(__dirname, 'dist/');
|
||||
var src = 'index';
|
||||
var dst = 'web3';
|
||||
var lightDst = 'web3-light';
|
||||
|
@ -29,7 +29,7 @@ var browserifyOptions = {
|
|||
bundleExternal: true
|
||||
};
|
||||
|
||||
gulp.task('versionReplace', function(){
|
||||
gulp.task('version', function(){
|
||||
gulp.src(['./package.json'])
|
||||
.pipe(replace(/\"version\"\: \"(.{5})\"/, '"version": "'+ version.version + '"'))
|
||||
.pipe(gulp.dest('./'));
|
||||
|
@ -41,24 +41,24 @@ gulp.task('versionReplace', function(){
|
|||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
|
||||
gulp.task('bower', function(cb){
|
||||
gulp.task('bower', ['version'], function(cb){
|
||||
bower.commands.install().on('end', function (installed){
|
||||
console.log(installed);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('clean', ['lint'], function(cb) {
|
||||
del([ DEST ], cb);
|
||||
});
|
||||
|
||||
gulp.task('lint', function(){
|
||||
gulp.task('lint', ['bower'], function(){
|
||||
return gulp.src(['./*.js', './lib/*.js'])
|
||||
.pipe(jshint())
|
||||
.pipe(jshint.reporter('default'));
|
||||
});
|
||||
|
||||
gulp.task('buildLight', ['clean'], function () {
|
||||
gulp.task('clean', ['lint'], function(cb) {
|
||||
del([ DEST ], cb);
|
||||
});
|
||||
|
||||
gulp.task('light', ['clean'], function () {
|
||||
return browserify(browserifyOptions)
|
||||
.require('./' + src + '.js', {expose: 'web3'})
|
||||
.ignore('bignumber.js')
|
||||
|
@ -73,7 +73,7 @@ gulp.task('buildLight', ['clean'], function () {
|
|||
.pipe(gulp.dest( DEST ));
|
||||
});
|
||||
|
||||
gulp.task('buildStandalone', ['clean'], function () {
|
||||
gulp.task('standalone', ['clean'], function () {
|
||||
return browserify(browserifyOptions)
|
||||
.require('./' + src + '.js', {expose: 'web3'})
|
||||
.require('bignumber.js') // expose it to dapp users
|
||||
|
@ -92,10 +92,5 @@ gulp.task('watch', function() {
|
|||
gulp.watch(['./lib/*.js'], ['lint', 'build']);
|
||||
});
|
||||
|
||||
gulp.task('light', ['versionReplace','bower', 'lint', 'buildLight']);
|
||||
gulp.task('standalone', ['versionReplace','bower', 'lint', 'buildStandalone']);
|
||||
gulp.task('default', ['light', 'standalone']);
|
||||
|
||||
|
||||
gulp.task('version', ['versionReplace']);
|
||||
gulp.task('default', ['version', 'bower', 'lint', 'clean', 'light', 'standalone']);
|
||||
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
// Karma configuration
|
||||
// Generated on Thu Feb 19 2015 19:57:47 GMT+0100 (W. Europe Standard Time)
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: true, logLevel: config.LOG_INFO,
|
||||
//singleRun: true, logLevel: config.LOG_DEBUG,
|
||||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['browserify', 'mocha'],
|
||||
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'test/*.js'
|
||||
],
|
||||
|
||||
|
||||
// list of files to exclude
|
||||
exclude: [
|
||||
],
|
||||
|
||||
client: {
|
||||
mocha: {
|
||||
//ui: 'tdd'
|
||||
timeout: 5000 // especially for the post requests
|
||||
}
|
||||
},
|
||||
browserify: {
|
||||
bundleDelay: 750,
|
||||
debug: true
|
||||
// transform: [],
|
||||
// //extensions: ['.js']
|
||||
},
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {
|
||||
'test/*.js': ['browserify']
|
||||
},
|
||||
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['dots'],
|
||||
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: true,
|
||||
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
// // Chrome
|
||||
// // PhantomJS
|
||||
browsers: ['Chrome', 'Safari', 'Firefox'],
|
||||
browserNoActivityTimeout: 10000,
|
||||
browserDisconnectTimeout: 5000,
|
||||
|
||||
customLaunchers: {
|
||||
chromeWithoutSecurity: {
|
||||
base: 'Chrome',
|
||||
flags: ['--disable-web-security']
|
||||
},
|
||||
|
||||
IE9: {
|
||||
base: 'IE',
|
||||
'x-ua-compatible': 'IE=EmulateIE9'
|
||||
},
|
||||
IE8: {
|
||||
base: 'IE',
|
||||
'x-ua-compatible': 'IE=EmulateIE8'
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
|
@ -262,6 +262,13 @@ var coder = new SolidityCoder([
|
|||
inputFormatter: f.formatInputBytes,
|
||||
outputFormatter: f.formatOutputBytes
|
||||
}),
|
||||
new SolidityType({
|
||||
name: 'string',
|
||||
match: 'strict',
|
||||
mode: 'bytes',
|
||||
inputFormatter: f.formatInputString,
|
||||
outputFormatter: f.formatOutputString
|
||||
}),
|
||||
new SolidityType({
|
||||
name: 'real',
|
||||
match: 'prefix',
|
||||
|
|
|
@ -43,25 +43,39 @@ var formatInputInt = function (value) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Formats input value to byte representation of string
|
||||
* Formats input bytes
|
||||
*
|
||||
* @method formatInputBytes
|
||||
* @param {String}
|
||||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputBytes = function (value) {
|
||||
var result = utils.fromAscii(value, c.ETH_PADDING).substr(2);
|
||||
var result = utils.padRight(utils.toHex(value).substr(2), 64);
|
||||
return new SolidityParam(result);
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats input bytes
|
||||
*
|
||||
* @method formatDynamicInputBytes
|
||||
* @param {String}
|
||||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputDynamicBytes = function (value) {
|
||||
value = utils.toHex(value);
|
||||
var result = utils.padRight((value).substr(2), 64);
|
||||
var length = Math.floor(value.length / 2 - 1);
|
||||
return new SolidityParam(formatInputInt(length).value + result, 32);
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats input value to byte representation of string
|
||||
*
|
||||
* @method formatInputDynamicBytes
|
||||
* @method formatInputString
|
||||
* @param {String}
|
||||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputDynamicBytes = function (value) {
|
||||
var formatInputString = function (value) {
|
||||
var result = utils.fromAscii(value, c.ETH_PADDING).substr(2);
|
||||
return new SolidityParam(formatInputInt(value.length).value + result, 32);
|
||||
};
|
||||
|
@ -165,27 +179,38 @@ var formatOutputBool = function (param) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Should be used to format output string
|
||||
* Should be used to format output bytes
|
||||
*
|
||||
* @method formatOutputBytes
|
||||
* @param {SolidityParam} left-aligned hex representation of string
|
||||
* @returns {String} ascii string
|
||||
* @returns {String} hex string
|
||||
*/
|
||||
var formatOutputBytes = function (param) {
|
||||
// length might also be important!
|
||||
return utils.toAscii(param.staticPart());
|
||||
return '0x' + param.staticPart();
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be used to format output bytes
|
||||
*
|
||||
* @method formatOutputDynamicBytes
|
||||
* @param {SolidityParam} left-aligned hex representation of string
|
||||
* @returns {String} hex string
|
||||
*/
|
||||
var formatOutputDynamicBytes = function (param) {
|
||||
var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
|
||||
return '0x' + param.dynamicPart().substr(64, length);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be used to format output string
|
||||
*
|
||||
* @method formatOutputDynamicBytes
|
||||
* @method formatOutputString
|
||||
* @param {SolidityParam} left-aligned hex representation of string
|
||||
* @returns {String} ascii string
|
||||
*/
|
||||
var formatOutputDynamicBytes = function (param) {
|
||||
// length might also be important!
|
||||
return utils.toAscii(param.dynamicPart().slice(64));
|
||||
var formatOutputString = function (param) {
|
||||
var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
|
||||
return utils.toAscii(param.dynamicPart().substr(64, length));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -204,6 +229,7 @@ module.exports = {
|
|||
formatInputInt: formatInputInt,
|
||||
formatInputBytes: formatInputBytes,
|
||||
formatInputDynamicBytes: formatInputDynamicBytes,
|
||||
formatInputString: formatInputString,
|
||||
formatInputBool: formatInputBool,
|
||||
formatInputReal: formatInputReal,
|
||||
formatOutputInt: formatOutputInt,
|
||||
|
@ -213,6 +239,7 @@ module.exports = {
|
|||
formatOutputBool: formatOutputBool,
|
||||
formatOutputBytes: formatOutputBytes,
|
||||
formatOutputDynamicBytes: formatOutputDynamicBytes,
|
||||
formatOutputString: formatOutputString,
|
||||
formatOutputAddress: formatOutputAddress
|
||||
};
|
||||
|
||||
|
|
|
@ -75,6 +75,19 @@ var padLeft = function (string, chars, sign) {
|
|||
return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to pad string to expected length
|
||||
*
|
||||
* @method padRight
|
||||
* @param {String} string to be padded
|
||||
* @param {Number} characters that result string should have
|
||||
* @param {String} sign, by default 0
|
||||
* @returns {String} right aligned string
|
||||
*/
|
||||
var padRight = function (string, chars, sign) {
|
||||
return string + (new Array(chars - string.length + 1).join(sign ? sign : "0"));
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get sting from it's hex representation
|
||||
*
|
||||
|
@ -91,10 +104,6 @@ var toAscii = function(hex) {
|
|||
}
|
||||
for (; i < l; i+=2) {
|
||||
var code = parseInt(hex.substr(i, 2), 16);
|
||||
if (code === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
str += String.fromCharCode(code);
|
||||
}
|
||||
|
||||
|
@ -204,7 +213,7 @@ var fromDecimal = function (value) {
|
|||
* @return {String}
|
||||
*/
|
||||
var toHex = function (val) {
|
||||
/*jshint maxcomplexity:7 */
|
||||
/*jshint maxcomplexity: 8 */
|
||||
|
||||
if (isBoolean(val))
|
||||
return fromDecimal(+val);
|
||||
|
@ -218,9 +227,11 @@ var toHex = function (val) {
|
|||
// if its a negative number, pass it through fromDecimal
|
||||
if (isString(val)) {
|
||||
if (val.indexOf('-0x') === 0)
|
||||
return fromDecimal(val);
|
||||
return fromDecimal(val);
|
||||
else if (!isFinite(val))
|
||||
return fromAscii(val);
|
||||
else if(val.indexOf('0x') === 0)
|
||||
return val;
|
||||
}
|
||||
|
||||
return fromDecimal(val);
|
||||
|
@ -471,6 +482,7 @@ var isIBAN = function (iban) {
|
|||
|
||||
module.exports = {
|
||||
padLeft: padLeft,
|
||||
padRight: padRight,
|
||||
toHex: toHex,
|
||||
toDecimal: toDecimal,
|
||||
fromDecimal: fromDecimal,
|
||||
|
|
|
@ -55,6 +55,7 @@ HttpProvider.prototype.send = function (payload) {
|
|||
|
||||
request.open('POST', this.host, false);
|
||||
request.setRequestHeader('Content-type','application/json');
|
||||
request.setRequestHeader('Connection','Keep-Alive');
|
||||
|
||||
try {
|
||||
request.send(JSON.stringify(payload));
|
||||
|
|
|
@ -94,10 +94,10 @@ IpcProvider.prototype._getResponse = function(payload, callback) {
|
|||
|
||||
IpcProvider.prototype.isConnected = function() {
|
||||
// try reconnect, when connection is gone
|
||||
if(!this.connection._handle)
|
||||
if(!this.connection.writable)
|
||||
this.connection.connect({path: this.path});
|
||||
|
||||
return !!this.connection._handle;
|
||||
return !!this.connection.writable;
|
||||
};
|
||||
|
||||
IpcProvider.prototype.send = function (payload) {
|
||||
|
@ -105,7 +105,7 @@ IpcProvider.prototype.send = function (payload) {
|
|||
if(this.connection.writeSync) {
|
||||
|
||||
// try reconnect, when connection is gone
|
||||
if(!this.connection._handle)
|
||||
if(!this.connection.writable)
|
||||
this.connection.connect({path: this.path});
|
||||
|
||||
var result = this.connection.writeSync(JSON.stringify(payload));
|
||||
|
@ -125,7 +125,7 @@ IpcProvider.prototype.send = function (payload) {
|
|||
|
||||
IpcProvider.prototype.sendAsync = function (payload, callback) {
|
||||
// try reconnect, when connection is gone
|
||||
if(!this.connection._handle)
|
||||
if(!this.connection.writable)
|
||||
this.connection.connect({path: this.path});
|
||||
|
||||
|
||||
|
|
23
package.json
23
package.json
|
@ -15,37 +15,30 @@
|
|||
"browser": {
|
||||
},
|
||||
"devDependencies": {
|
||||
"bower": ">=1.3.0",
|
||||
"bower": ">=1.4.1",
|
||||
"browserify": ">=10.0",
|
||||
"chai": "^2.1.1",
|
||||
"chai": "^3.0.0",
|
||||
"coveralls": "^2.11.2",
|
||||
"del": ">=0.1.1",
|
||||
"del": ">=1.2.0",
|
||||
"exorcist": "^0.4.0",
|
||||
"gulp": ">=3.4.0",
|
||||
"gulp": ">=3.9.0",
|
||||
"gulp-jshint": ">=1.5.0",
|
||||
"gulp-rename": ">=1.2.0",
|
||||
"gulp-replace": "^0.5.3",
|
||||
"gulp-streamify": "0.0.5",
|
||||
"gulp-uglify": ">=1.0.0",
|
||||
"gulp-uglify": ">=1.2.0",
|
||||
"istanbul": "^0.3.5",
|
||||
"jshint": ">=2.5.0",
|
||||
"karma": "^0.12.31",
|
||||
"karma-browserify": "^4.0.0",
|
||||
"karma-chrome-launcher": "^0.1.7",
|
||||
"karma-firefox-launcher": "^0.1.4",
|
||||
"karma-mocha": "^0.1.10",
|
||||
"karma-safari-launcher": "^0.1.1",
|
||||
"mocha": ">=2.1.0",
|
||||
"sandboxed-module": "^2.0.0",
|
||||
"vinyl-source-stream": "^1.0.0"
|
||||
"sandboxed-module": "^2.0.2",
|
||||
"vinyl-source-stream": "^1.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp",
|
||||
"watch": "gulp watch",
|
||||
"lint": "jshint *.js lib",
|
||||
"test": "mocha",
|
||||
"test-coveralls": "istanbul cover _mocha -- -R spec && cat coverage/lcov.info | coveralls --verbose",
|
||||
"karma": "./node_modules/karma/bin/karma start --singleRun=true --browsers=\"Firefox\""
|
||||
"test-coveralls": "istanbul cover _mocha -- -R spec && cat coverage/lcov.info | coveralls --verbose"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -20,10 +20,39 @@ describe('lib/solidity/coder', function () {
|
|||
test({ type: 'int256', expected: new bn(1), value: '0000000000000000000000000000000000000000000000000000000000000001'});
|
||||
test({ type: 'int256', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int256', expected: new bn(-1), value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'});
|
||||
test({ type: 'bytes32', expected: 'gavofyork', value: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes', expected: 'gavofyork', value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
test({ type: 'int8', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int32', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int64', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int128', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'bytes32', expected: '0x6761766f66796f726b0000000000000000000000000000000000000000000000',
|
||||
value: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes', expected: '0x6761766f66796f726b',
|
||||
value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes32', expected: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
value: '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
test({ type: 'bytes', expected: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
test({ type: 'string', expected: 'gavofyork', value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'string', expected: '\xc3\xa4\x00\x00\xc3\xa4',
|
||||
value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000006' +
|
||||
'c3a40000c3a40000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'string', expected: '\xc3',
|
||||
value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'c300000000000000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes', expected: '0xc3a40000c3a4',
|
||||
value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000006' +
|
||||
'c3a40000c3a40000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes32', expected: '0xc3a40000c3a40000000000000000000000000000000000000000000000000000',
|
||||
value: 'c3a40000c3a40000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'int[]', expected: [], value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'int[]', expected: [new bn(3)], value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
|
@ -62,13 +91,13 @@ describe('lib/solidity/coder', function () {
|
|||
|
||||
|
||||
test({ types: ['int'], expected: [new bn(1)], values: '0000000000000000000000000000000000000000000000000000000000000001'});
|
||||
test({ types: ['bytes32', 'int'], expected: ['gavofyork', new bn(5)],
|
||||
test({ types: ['bytes32', 'int'], expected: ['0x6761766f66796f726b0000000000000000000000000000000000000000000000', new bn(5)],
|
||||
values: '6761766f66796f726b0000000000000000000000000000000000000000000000' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000005'});
|
||||
test({ types: ['int', 'bytes32'], expected: [new bn(5), 'gavofyork'],
|
||||
test({ types: ['int', 'bytes32'], expected: [new bn(5), '0x6761766f66796f726b0000000000000000000000000000000000000000000000'],
|
||||
values: '0000000000000000000000000000000000000000000000000000000000000005' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ types: ['int', 'bytes', 'int', 'int', 'int', 'int[]'], expected: [new bn(1), 'gavofyork', new bn(2), new bn(3), new bn(4),
|
||||
test({ types: ['int', 'string', 'int', 'int', 'int', 'int[]'], expected: [new bn(1), 'gavofyork', new bn(2), new bn(3), new bn(4),
|
||||
[new bn(5), new bn(6), new bn(7)]],
|
||||
values: '0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'00000000000000000000000000000000000000000000000000000000000000c0' +
|
||||
|
|
|
@ -20,10 +20,37 @@ describe('lib/solidity/coder', function () {
|
|||
test({ type: 'int256', value: 1, expected: '0000000000000000000000000000000000000000000000000000000000000001'});
|
||||
test({ type: 'int256', value: 16, expected: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int256', value: -1, expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'});
|
||||
test({ type: 'bytes32', value: 'gavofyork', expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes', value: 'gavofyork', expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
test({ type: 'bytes32', value: '0x6761766f66796f726b',
|
||||
expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes32', value: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
expected: '731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
test({ type: 'bytes32', value: '0x02838654a83c213dae3698391eabbd54a5b6e1fb3452bc7fa4ea0dd5c8ce7e29',
|
||||
expected: '02838654a83c213dae3698391eabbd54a5b6e1fb3452bc7fa4ea0dd5c8ce7e29'});
|
||||
test({ type: 'bytes', value: '0x6761766f66796f726b',
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes', value: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
test({ type: 'string', value: 'gavofyork', expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes', value: '0xc3a40000c3a4',
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000006' +
|
||||
'c3a40000c3a40000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'bytes32', value: '0xc3a40000c3a4',
|
||||
expected: 'c3a40000c3a40000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'string', value: '\xc3\xa4\x00\x00\xc3\xa4',
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000006' +
|
||||
'c3a40000c3a40000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'string', value: '\xc3',
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'c300000000000000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'int[]', value: [], expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000000'});
|
||||
test({ type: 'int[]', value: [3], expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
|
@ -67,8 +94,9 @@ describe('lib/solidity/coder', function () {
|
|||
test({ types: ['int256'], values: [1], expected: '0000000000000000000000000000000000000000000000000000000000000001'});
|
||||
test({ types: ['int256'], values: [16], expected: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ types: ['int256'], values: [-1], expected: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'});
|
||||
test({ types: ['bytes32'], values: ['gavofyork'], expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ types: ['bytes'], values: ['gavofyork'], expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
test({ types: ['bytes32'], values: ['0x6761766f66796f726b'],
|
||||
expected: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ types: ['string'], values: ['gavofyork'], expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ types: ['int[]'], values: [[3]], expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
|
@ -91,18 +119,18 @@ describe('lib/solidity/coder', function () {
|
|||
'0000000000000000000000000000000000000000000000000000000000000002' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000004'});
|
||||
test({ types: ['bytes32', 'int'], values: ['gavofyork', 5],
|
||||
test({ types: ['bytes32', 'int'], values: ['0x6761766f66796f726b', 5],
|
||||
expected: '6761766f66796f726b0000000000000000000000000000000000000000000000' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000005'});
|
||||
test({ types: ['int', 'bytes32'], values: [5, 'gavofyork'],
|
||||
test({ types: ['int', 'bytes32'], values: [5, '0x6761766f66796f726b'],
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000005' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ types: ['bytes', 'int'], values: ['gavofyork', 5],
|
||||
test({ types: ['string', 'int'], values: ['gavofyork', 5],
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000040' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000005' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ types: ['bytes', 'bool', 'int[]'], values: ['gavofyork', true, [1, 2, 3]],
|
||||
test({ types: ['string', 'bool', 'int[]'], values: ['gavofyork', true, [1, 2, 3]],
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000060' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'00000000000000000000000000000000000000000000000000000000000000a0' +
|
||||
|
@ -112,7 +140,7 @@ describe('lib/solidity/coder', function () {
|
|||
'0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000002' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003'});
|
||||
test({ types: ['bytes', 'int[]'], values: ['gavofyork', [1, 2, 3]],
|
||||
test({ types: ['string', 'int[]'], values: ['gavofyork', [1, 2, 3]],
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000040' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000080' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
|
@ -121,12 +149,12 @@ describe('lib/solidity/coder', function () {
|
|||
'0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000002' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003'});
|
||||
test({ types: ['int', 'bytes'], values: [5, 'gavofyork'],
|
||||
test({ types: ['int', 'string'], values: [5, 'gavofyork'],
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000005' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000040' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
test({ types: ['int', 'bytes', 'int', 'int', 'int', 'int[]'], values: [1, 'gavofyork', 2, 3, 4, [5, 6, 7]],
|
||||
test({ types: ['int', 'string', 'int', 'int', 'int', 'int[]'], values: [1, 'gavofyork', 2, 3, 4, [5, 6, 7]],
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'00000000000000000000000000000000000000000000000000000000000000c0' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000002' +
|
||||
|
|
|
@ -40,7 +40,7 @@ describe('lib/web3/ipcprovider', function () {
|
|||
it('should return false', function () {
|
||||
var provider = new IpcProvider();
|
||||
|
||||
provider.connection._handle = null;
|
||||
provider.connection.writable = false;
|
||||
|
||||
assert.isFalse(provider.isConnected());
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ describe('lib/web3/ipcprovider', function () {
|
|||
it('should return true, when a net handle is set', function () {
|
||||
var provider = new IpcProvider();
|
||||
|
||||
provider.connection._handle = {fd: true};
|
||||
provider.connection.writable = true;
|
||||
|
||||
assert.isTrue(provider.isConnected());
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ var tests = [
|
|||
{ value: '-0x1', expected: '-0x1'},
|
||||
{ value: '-15', expected: '-0xf'},
|
||||
{ value: '-0xf', expected: '-0xf'},
|
||||
{ value: '0x657468657265756d', expected: '0x657468657265756d'},
|
||||
{ value: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
|
||||
{ value: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'},
|
||||
{ value: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
|
||||
|
|
Loading…
Reference in New Issue