mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
d9b422cfbc
a0cfa3c version upgrade e58e2f5 jsonrpc.js tests && jsonrpc response validation is more strict 45134de jsonrpc.js file && batch polling f3ce1f0 simplified polling && jsonrpc payload creation ddc1719 tests && fixes for utils methods fdcc1af clearing tests 4a54b8c version upgrade 0.0.12 git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: a0cfa3ca21163f26f3f71a0e2ce0a1e617554c72
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
var assert = require('assert');
|
|
var jsonrpc = require('../lib/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);
|
|
});
|
|
});
|
|
});
|