mirror of https://github.com/status-im/web3.js.git
77 lines
1.9 KiB
JavaScript
77 lines
1.9 KiB
JavaScript
var chai = require('chai');
|
|
var web3 = require('../index');
|
|
var assert = chai.assert;
|
|
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
|
|
|
|
var method = 'filter';
|
|
|
|
|
|
var tests = [{
|
|
args: [{
|
|
fromBlock: 0,
|
|
toBlock: 10,
|
|
address: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'
|
|
}],
|
|
formattedArgs: [{
|
|
fromBlock: '0x0',
|
|
toBlock: '0xa',
|
|
address: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
|
|
topics: []
|
|
}],
|
|
result: '0xf',
|
|
formattedResult: '0xf',
|
|
call: 'eth_newFilter'
|
|
},{
|
|
args: [{
|
|
fromBlock: 'latest',
|
|
toBlock: 'latest',
|
|
address: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855'
|
|
}],
|
|
formattedArgs: [{
|
|
fromBlock: 'latest',
|
|
toBlock: 'latest',
|
|
address: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
|
|
topics: []
|
|
}],
|
|
result: '0xf',
|
|
formattedResult: '0xf',
|
|
call: 'eth_newFilter'
|
|
},{
|
|
args: ['latest'],
|
|
formattedArgs: [],
|
|
result: '0xf',
|
|
formattedResult: '0xf',
|
|
call: 'eth_newBlockFilter'
|
|
},{
|
|
args: ['pending'],
|
|
formattedArgs: [],
|
|
result: '0xf',
|
|
formattedResult: '0xf',
|
|
call: 'eth_newPendingTransactionFilter'
|
|
}];
|
|
|
|
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, test.formattedArgs);
|
|
});
|
|
|
|
// call
|
|
web3.eth[method].apply(null, test.args);
|
|
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|