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.

106 lines
3.8 KiB

Squashed 'libjsqrc/ethereumjs/' changes from e908439..16861fc 16861fc version 0.4.2 e4f7dde fixed failing lint 69e7d9d fixed #133 55553d7 add async error test d02a375 Merge branch 'develop' of github.com:ethereum/web3.js into develop ff48da1 fixed callback error issue 471bce1 #133 in progress dc69085 version 0.4.1 2ae0afa critical bugfix 09f2a92 updated examples a0a36e5 Merge branch 'develop' of https://github.com/ethereum/ethereum.js into develop 2b179a8 updated node install test 8f63640 Merge pull request #203 from frozeman/develop 22ef4a1 added estimateGas method cd2e462 version 0.4.0 ae7762a Merge pull request #198 from ethereum/minerMethods d1e1206 removed byte formatter methods 6fd17d9 merged develop 373fd1b Merge pull request #201 from debris/batch 274fc29 Merge pull request #200 from debris/contract_overhaul b2ff2ff Merge branch 'contract_overhaul' into batch 99a3bda removed redundant lines 7cafac9 Merge branch 'develop' into contract_overhaul fa8db32 Merge pull request #202 from debris/async_properties 5f9272c asyncGet -> getAsync cd0df61 gulp 80c0792 async getting properties, remove property setters 744bb9e batch for requests with calls/transacts 8636077 initial support for batch requests a0b9cfb contract async call && transact 1272780 sendTransaction && call async 6afb1f9 Merge branch 'async-contract-calls' of https://github.com/niran/web3.js into contract_overhaul 611f640 asynchronous contract creation, breaking changes e3796bf merged develop edf808a add getWork and submitWork functions and toXBytes utils 9812b01 Merge branch 'blockFilterProposal' of https://github.com/ethereum/ethereum.js into develop 6f466f6 add miner functions 3af8e27 add newblockfilter Proposal e86552f Use async contract calls when a callback is passed git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: 16861fc1944cca721672bb8faa81909d69be2b99
10 years ago
var chai = require('chai');
var assert = chai.assert;
var web3 = require('../index');
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
var bn = require('bignumber.js');
describe('lib/web3/batch', function () {
describe('execute', function () {
it('should execute batch request', function (done) {
var provider = new FakeHttpProvider();
web3.setProvider(provider);
web3.reset();
var result = '0x126';
var result2 = '0x127';
provider.injectBatchResults([result, result2]);
var counter = 0;
var callback = function (err, r) {
counter++;
assert.deepEqual(new bn(result), r);
};
var callback2 = function (err, r) {
assert.equal(counter, 1);
assert.deepEqual(new bn(result2), r);
done();
};
Squashed 'libjsqrc/ethereumjs/' changes from 2a0b46a..d5d2115 d5d2115 example contract using array, fixed #185 21ed235 removed connection keep-alive c44fe01 version 0.7.1 d9b785e fixed #248 490dde5 fixed encoding/decoding strings, #249 b3f5d09 fixed long bytes dynamic decoding/encoding, #249 d097821 small filter improvement d59b1cd removed xhr from browser 42b6e9d version 0.7.0 fe6defd gulp 44dcd24 set connection keepalive 2b17c0f gulpfile changes 4a46c73 Merge pull request #228 from ethereum/strings 93c8006 tests for encoding and decoding prematurely terminated strings and strings containing internal zeros 7dd44e7 Merge branch 'strings' of https://github.com/ethereum/ethereum.js into strings 390a9ff Merge branch 'develop' into strings bcd9cfb updated deps, removed unused karma ef15fc1 Merge pull request #244 from ethereum/allevents 6f74d57 Merge branch 'develop' into allevents 7aca17e Merge branch 'develop' into allevents c5ee34d fix for optional event parameters 8170a0a Merge pull request #245 from ethereum/filterInstantWatch 76a094c fixed all issues noted by marek d78b512 add possible callback to filters e1b17a9 re-build develop af9c027 all events filter b270616 version 0.6.1 c47d6a8 gulp 7cf7cf3 map file 6da1d3e gulp 450042e Update eth.js 3951286 Added sendRawTransaction 323b529 merged develop 16ffdf6 merged master ecf0a2c changed | to Math.floor d2b5ba2 Merge pull request #239 from ethereum/mistFixes 9e6bf9d removed browser XHR 9061116 fixed build issues in formatInputDynamicBytes 0e3b29c fixed coverage issue d51e9a2 merged latest develop f0247aa made meteor package available on the server side as well e97c5f5 fixed and tested meteor package init 3e49f56 add currentProvidor and mist fixes bd6d9ba merged develop 7b730b1 Merge branch 'strings' of github.com:ethereum/web3.js into strings cc533d9 fixed bytes wrong encoding 8c6f976 Merge branch 'develop' into strings 7c970e3 add bytes32 test with leading 0 9c7f7bb re-add .map files 189484f add extra int tests 73cc711 Merge branch 'develop' into strings fa3239f abi string type, fixes #216, #218, #219 git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: d5d2115bf9ad07a736a189e1022b7d3a549e4006
10 years ago
provider.injectValidation(function (payload) {
var first = payload[0];
var second = payload[1];
assert.equal(first.method, 'eth_getBalance');
assert.deepEqual(first.params, ['0x0000000000000000000000000000000000000000', 'latest']);
assert.equal(second.method, 'eth_getBalance');
assert.deepEqual(second.params, ['0x0000000000000000000000000000000000000005', 'latest']);
});
Squashed 'libjsqrc/ethereumjs/' changes from e908439..16861fc 16861fc version 0.4.2 e4f7dde fixed failing lint 69e7d9d fixed #133 55553d7 add async error test d02a375 Merge branch 'develop' of github.com:ethereum/web3.js into develop ff48da1 fixed callback error issue 471bce1 #133 in progress dc69085 version 0.4.1 2ae0afa critical bugfix 09f2a92 updated examples a0a36e5 Merge branch 'develop' of https://github.com/ethereum/ethereum.js into develop 2b179a8 updated node install test 8f63640 Merge pull request #203 from frozeman/develop 22ef4a1 added estimateGas method cd2e462 version 0.4.0 ae7762a Merge pull request #198 from ethereum/minerMethods d1e1206 removed byte formatter methods 6fd17d9 merged develop 373fd1b Merge pull request #201 from debris/batch 274fc29 Merge pull request #200 from debris/contract_overhaul b2ff2ff Merge branch 'contract_overhaul' into batch 99a3bda removed redundant lines 7cafac9 Merge branch 'develop' into contract_overhaul fa8db32 Merge pull request #202 from debris/async_properties 5f9272c asyncGet -> getAsync cd0df61 gulp 80c0792 async getting properties, remove property setters 744bb9e batch for requests with calls/transacts 8636077 initial support for batch requests a0b9cfb contract async call && transact 1272780 sendTransaction && call async 6afb1f9 Merge branch 'async-contract-calls' of https://github.com/niran/web3.js into contract_overhaul 611f640 asynchronous contract creation, breaking changes e3796bf merged develop edf808a add getWork and submitWork functions and toXBytes utils 9812b01 Merge branch 'blockFilterProposal' of https://github.com/ethereum/ethereum.js into develop 6f466f6 add miner functions 3af8e27 add newblockfilter Proposal e86552f Use async contract calls when a callback is passed git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: 16861fc1944cca721672bb8faa81909d69be2b99
10 years ago
var batch = web3.createBatch();
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback));
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000005', 'latest', callback2));
batch.execute();
});
it('should execute batch request', function (done) {
var provider = new FakeHttpProvider();
web3.setProvider(provider);
web3.reset();
var abi = [{
"name": "balance(address)",
"type": "function",
"inputs": [{
"name": "who",
"type": "address"
}],
"constant": true,
"outputs": [{
"name": "value",
"type": "uint256"
}]
}];
Squashed 'libjsqrc/ethereumjs/' changes from 2a0b46a..d5d2115 d5d2115 example contract using array, fixed #185 21ed235 removed connection keep-alive c44fe01 version 0.7.1 d9b785e fixed #248 490dde5 fixed encoding/decoding strings, #249 b3f5d09 fixed long bytes dynamic decoding/encoding, #249 d097821 small filter improvement d59b1cd removed xhr from browser 42b6e9d version 0.7.0 fe6defd gulp 44dcd24 set connection keepalive 2b17c0f gulpfile changes 4a46c73 Merge pull request #228 from ethereum/strings 93c8006 tests for encoding and decoding prematurely terminated strings and strings containing internal zeros 7dd44e7 Merge branch 'strings' of https://github.com/ethereum/ethereum.js into strings 390a9ff Merge branch 'develop' into strings bcd9cfb updated deps, removed unused karma ef15fc1 Merge pull request #244 from ethereum/allevents 6f74d57 Merge branch 'develop' into allevents 7aca17e Merge branch 'develop' into allevents c5ee34d fix for optional event parameters 8170a0a Merge pull request #245 from ethereum/filterInstantWatch 76a094c fixed all issues noted by marek d78b512 add possible callback to filters e1b17a9 re-build develop af9c027 all events filter b270616 version 0.6.1 c47d6a8 gulp 7cf7cf3 map file 6da1d3e gulp 450042e Update eth.js 3951286 Added sendRawTransaction 323b529 merged develop 16ffdf6 merged master ecf0a2c changed | to Math.floor d2b5ba2 Merge pull request #239 from ethereum/mistFixes 9e6bf9d removed browser XHR 9061116 fixed build issues in formatInputDynamicBytes 0e3b29c fixed coverage issue d51e9a2 merged latest develop f0247aa made meteor package available on the server side as well e97c5f5 fixed and tested meteor package init 3e49f56 add currentProvidor and mist fixes bd6d9ba merged develop 7b730b1 Merge branch 'strings' of github.com:ethereum/web3.js into strings cc533d9 fixed bytes wrong encoding 8c6f976 Merge branch 'develop' into strings 7c970e3 add bytes32 test with leading 0 9c7f7bb re-add .map files 189484f add extra int tests 73cc711 Merge branch 'develop' into strings fa3239f abi string type, fixes #216, #218, #219 git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: d5d2115bf9ad07a736a189e1022b7d3a549e4006
10 years ago
var address = '0x1000000000000000000000000000000000000001';
Squashed 'libjsqrc/ethereumjs/' changes from e908439..16861fc 16861fc version 0.4.2 e4f7dde fixed failing lint 69e7d9d fixed #133 55553d7 add async error test d02a375 Merge branch 'develop' of github.com:ethereum/web3.js into develop ff48da1 fixed callback error issue 471bce1 #133 in progress dc69085 version 0.4.1 2ae0afa critical bugfix 09f2a92 updated examples a0a36e5 Merge branch 'develop' of https://github.com/ethereum/ethereum.js into develop 2b179a8 updated node install test 8f63640 Merge pull request #203 from frozeman/develop 22ef4a1 added estimateGas method cd2e462 version 0.4.0 ae7762a Merge pull request #198 from ethereum/minerMethods d1e1206 removed byte formatter methods 6fd17d9 merged develop 373fd1b Merge pull request #201 from debris/batch 274fc29 Merge pull request #200 from debris/contract_overhaul b2ff2ff Merge branch 'contract_overhaul' into batch 99a3bda removed redundant lines 7cafac9 Merge branch 'develop' into contract_overhaul fa8db32 Merge pull request #202 from debris/async_properties 5f9272c asyncGet -> getAsync cd0df61 gulp 80c0792 async getting properties, remove property setters 744bb9e batch for requests with calls/transacts 8636077 initial support for batch requests a0b9cfb contract async call && transact 1272780 sendTransaction && call async 6afb1f9 Merge branch 'async-contract-calls' of https://github.com/niran/web3.js into contract_overhaul 611f640 asynchronous contract creation, breaking changes e3796bf merged develop edf808a add getWork and submitWork functions and toXBytes utils 9812b01 Merge branch 'blockFilterProposal' of https://github.com/ethereum/ethereum.js into develop 6f466f6 add miner functions 3af8e27 add newblockfilter Proposal e86552f Use async contract calls when a callback is passed git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: 16861fc1944cca721672bb8faa81909d69be2b99
10 years ago
var result = '0x126';
var result2 = '0x0000000000000000000000000000000000000000000000000000000000000123';
var counter = 0;
var callback = function (err, r) {
counter++;
assert.deepEqual(new bn(result), r);
};
var callback2 = function (err, r) {
assert.equal(counter, 1);
assert.deepEqual(new bn(result2), r);
done();
};
Squashed 'libjsqrc/ethereumjs/' changes from 2a0b46a..d5d2115 d5d2115 example contract using array, fixed #185 21ed235 removed connection keep-alive c44fe01 version 0.7.1 d9b785e fixed #248 490dde5 fixed encoding/decoding strings, #249 b3f5d09 fixed long bytes dynamic decoding/encoding, #249 d097821 small filter improvement d59b1cd removed xhr from browser 42b6e9d version 0.7.0 fe6defd gulp 44dcd24 set connection keepalive 2b17c0f gulpfile changes 4a46c73 Merge pull request #228 from ethereum/strings 93c8006 tests for encoding and decoding prematurely terminated strings and strings containing internal zeros 7dd44e7 Merge branch 'strings' of https://github.com/ethereum/ethereum.js into strings 390a9ff Merge branch 'develop' into strings bcd9cfb updated deps, removed unused karma ef15fc1 Merge pull request #244 from ethereum/allevents 6f74d57 Merge branch 'develop' into allevents 7aca17e Merge branch 'develop' into allevents c5ee34d fix for optional event parameters 8170a0a Merge pull request #245 from ethereum/filterInstantWatch 76a094c fixed all issues noted by marek d78b512 add possible callback to filters e1b17a9 re-build develop af9c027 all events filter b270616 version 0.6.1 c47d6a8 gulp 7cf7cf3 map file 6da1d3e gulp 450042e Update eth.js 3951286 Added sendRawTransaction 323b529 merged develop 16ffdf6 merged master ecf0a2c changed | to Math.floor d2b5ba2 Merge pull request #239 from ethereum/mistFixes 9e6bf9d removed browser XHR 9061116 fixed build issues in formatInputDynamicBytes 0e3b29c fixed coverage issue d51e9a2 merged latest develop f0247aa made meteor package available on the server side as well e97c5f5 fixed and tested meteor package init 3e49f56 add currentProvidor and mist fixes bd6d9ba merged develop 7b730b1 Merge branch 'strings' of github.com:ethereum/web3.js into strings cc533d9 fixed bytes wrong encoding 8c6f976 Merge branch 'develop' into strings 7c970e3 add bytes32 test with leading 0 9c7f7bb re-add .map files 189484f add extra int tests 73cc711 Merge branch 'develop' into strings fa3239f abi string type, fixes #216, #218, #219 git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: d5d2115bf9ad07a736a189e1022b7d3a549e4006
10 years ago
provider.injectValidation(function (payload) {
var first = payload[0];
var second = payload[1];
assert.equal(first.method, 'eth_getBalance');
assert.deepEqual(first.params, ['0x0000000000000000000000000000000000000000', 'latest']);
assert.equal(second.method, 'eth_call');
assert.deepEqual(second.params, [{
'to': '0x1000000000000000000000000000000000000001',
'data': '0xe3d670d70000000000000000000000001000000000000000000000000000000000000001'
}]);
});
Squashed 'libjsqrc/ethereumjs/' changes from e908439..16861fc 16861fc version 0.4.2 e4f7dde fixed failing lint 69e7d9d fixed #133 55553d7 add async error test d02a375 Merge branch 'develop' of github.com:ethereum/web3.js into develop ff48da1 fixed callback error issue 471bce1 #133 in progress dc69085 version 0.4.1 2ae0afa critical bugfix 09f2a92 updated examples a0a36e5 Merge branch 'develop' of https://github.com/ethereum/ethereum.js into develop 2b179a8 updated node install test 8f63640 Merge pull request #203 from frozeman/develop 22ef4a1 added estimateGas method cd2e462 version 0.4.0 ae7762a Merge pull request #198 from ethereum/minerMethods d1e1206 removed byte formatter methods 6fd17d9 merged develop 373fd1b Merge pull request #201 from debris/batch 274fc29 Merge pull request #200 from debris/contract_overhaul b2ff2ff Merge branch 'contract_overhaul' into batch 99a3bda removed redundant lines 7cafac9 Merge branch 'develop' into contract_overhaul fa8db32 Merge pull request #202 from debris/async_properties 5f9272c asyncGet -> getAsync cd0df61 gulp 80c0792 async getting properties, remove property setters 744bb9e batch for requests with calls/transacts 8636077 initial support for batch requests a0b9cfb contract async call && transact 1272780 sendTransaction && call async 6afb1f9 Merge branch 'async-contract-calls' of https://github.com/niran/web3.js into contract_overhaul 611f640 asynchronous contract creation, breaking changes e3796bf merged develop edf808a add getWork and submitWork functions and toXBytes utils 9812b01 Merge branch 'blockFilterProposal' of https://github.com/ethereum/ethereum.js into develop 6f466f6 add miner functions 3af8e27 add newblockfilter Proposal e86552f Use async contract calls when a callback is passed git-subtree-dir: libjsqrc/ethereumjs git-subtree-split: 16861fc1944cca721672bb8faa81909d69be2b99
10 years ago
var batch = web3.createBatch();
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback));
batch.add(web3.eth.contract(abi).at(address).balance.request(address, callback2));
provider.injectBatchResults([result, result2]);
batch.execute();
});
});
});