2015-03-24 10:44:33 +00:00
|
|
|
var chai = require('chai');
|
|
|
|
var assert = chai.assert;
|
|
|
|
var web3 = require('../index');
|
|
|
|
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
|
|
|
|
|
|
|
|
var method = 'listening';
|
|
|
|
|
|
|
|
var tests = [{
|
|
|
|
result: true,
|
|
|
|
formattedResult: true,
|
|
|
|
call: 'net_'+ method
|
|
|
|
}];
|
|
|
|
|
2015-03-25 21:22:35 +00:00
|
|
|
describe('web3.net', function () {
|
2015-03-24 10:44:33 +00:00
|
|
|
describe(method, function () {
|
|
|
|
tests.forEach(function (test, index) {
|
|
|
|
it('property test: ' + index, function () {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var provider = new FakeHttpProvider();
|
|
|
|
web3.setProvider(provider);
|
|
|
|
provider.injectResult(test.result);
|
|
|
|
provider.injectValidation(function (payload) {
|
|
|
|
assert.equal(payload.jsonrpc, '2.0');
|
|
|
|
assert.equal(payload.method, test.call);
|
|
|
|
assert.deepEqual(payload.params, []);
|
|
|
|
});
|
|
|
|
|
|
|
|
// when
|
|
|
|
var result = web3.net[method];
|
|
|
|
|
|
|
|
// then
|
|
|
|
assert.deepEqual(test.formattedResult, result);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|