mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 11:38:12 +00:00
* added sub packages * added lerna monopackage management * check for package is instance * added method, subscription and utils package * moved almost all packages * moved all packages, no umbrella package yet * added extend to packages * made contract pass * made batch tests pass * expose providers * fixed test async * fixed test errors * fixed test event encode decode * fixed test formatter tests * fixed method tests * fixed method utils * fixed some eth methods * fixed some eth methods 2 * bumped version 0.18.3 to republish meteor package * fixed get* tests * fixed subscribe tests * added newBlockHeaders subscription * remove unpublished package from package.json * added sendTransaction test * fixed call test * moved files to done * changed extend * added iban tests * Fixed ALL tests * Fixed lint tests * Fixed contract tests * added method tests * added more method tests to test promiEvents extensively * added confirmation event * improved method confirmation checking
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
var assert = require('assert');
|
|
var Jsonrpc = require('../packages/web3-core-requestManager/src/jsonrpc');
|
|
|
|
describe('jsonrpc', function () {
|
|
describe('toBatchPayload', function () {
|
|
it('should create basic batch payload', function () {
|
|
|
|
// given
|
|
var messages = [{
|
|
method: 'helloworld'
|
|
}, {
|
|
method: 'test2',
|
|
params: [1]
|
|
}];
|
|
|
|
// when
|
|
var payload = Jsonrpc.toBatchPayload(messages);
|
|
|
|
// then
|
|
assert.equal(payload instanceof Array, true);
|
|
assert.equal(payload.length, 2);
|
|
assert.equal(payload[0].jsonrpc, '2.0');
|
|
assert.equal(payload[1].jsonrpc, '2.0');
|
|
assert.equal(payload[0].method, 'helloworld');
|
|
assert.equal(payload[1].method, 'test2');
|
|
assert.equal(payload[0].params instanceof Array, true);
|
|
assert.equal(payload[1].params.length, 1);
|
|
assert.equal(payload[1].params[0], 1);
|
|
assert.equal(typeof payload[0].id, 'number');
|
|
assert.equal(typeof payload[1].id, 'number');
|
|
assert.equal(payload[0].id + 1, payload[1].id);
|
|
});
|
|
|
|
it('should create batch payload for empty input array', function () {
|
|
|
|
// given
|
|
var messages = [];
|
|
|
|
// when
|
|
var payload = Jsonrpc.toBatchPayload(messages);
|
|
|
|
// then
|
|
assert.equal(payload instanceof Array, true);
|
|
assert.equal(payload.length, 0);
|
|
});
|
|
});
|
|
});
|