You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
var chai = require('chai');
|
|
var assert = chai.assert;
|
|
var web3 = require('../index');
|
|
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
|
|
|
|
var method = 'hashrate';
|
|
|
|
var tests = [{
|
|
result: '0x788a8',
|
|
formattedResult: 493736,
|
|
call: 'eth_'+ method
|
|
}];
|
|
|
|
describe('web3.eth', function () {
|
|
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.eth[method];
|
|
|
|
// then
|
|
assert.strictEqual(test.formattedResult, result);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|