fix && tests for #147

This commit is contained in:
Marek Kotewicz 2015-03-28 14:38:56 +01:00
parent 9fc557543a
commit 2f45df835a
9 changed files with 38 additions and 8 deletions

View File

@ -2388,6 +2388,8 @@ var Jsonrpc = function () {
if (arguments.callee._singletonInstance) {
return arguments.callee._singletonInstance;
}
arguments.callee._singletonInstance = this;
this.messageId = 1;
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/ethereum.js vendored
View File

@ -2388,6 +2388,8 @@ var Jsonrpc = function () {
if (arguments.callee._singletonInstance) {
return arguments.callee._singletonInstance;
}
arguments.callee._singletonInstance = this;
this.messageId = 1;
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -25,6 +25,8 @@ var Jsonrpc = function () {
if (arguments.callee._singletonInstance) {
return arguments.callee._singletonInstance;
}
arguments.callee._singletonInstance = this;
this.messageId = 1;
};

23
test/jsonrpc.id.js Normal file
View File

@ -0,0 +1,23 @@
var chai = require('chai');
var assert = chai.assert;
var Jsonrpc = require('../lib/web3/jsonrpc');
describe('lib/web3/jsonrpc', function () {
describe('id', function () {
it('should increment the id', function () {
// given
var a = Jsonrpc.getInstance();
var b = Jsonrpc.getInstance();
var method = 'm';
// when
var p1 = a.toPayload(method);
var p2 = b.toPayload(method);
// then
assert.equal(p2.id, p1.id + 1);
});
});
});

View File

@ -1,4 +1,5 @@
var assert = require('assert');
var chai = require('chai');
var assert = chai.assert;
var jsonrpc = require('../lib/web3/jsonrpc');
jsonrpc = new jsonrpc();