mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 11:38:12 +00:00
test for explicit sendTransaction && call
This commit is contained in:
parent
3d3db61e2e
commit
960e9c99ec
@ -211,6 +211,39 @@ describe('web3.eth.contract', function () {
|
||||
|
||||
});
|
||||
|
||||
it('should explicitly make a call with optional params', function () {
|
||||
|
||||
var provider = new FakeHttpProvider();
|
||||
web3.setProvider(provider);
|
||||
web3.reset();
|
||||
var sha3 = '0x5131231231231231231231';
|
||||
var address = '0x1234567890123456789012345678901234567890';
|
||||
provider.injectResult(sha3);
|
||||
var step = 0;
|
||||
provider.injectValidation(function (payload) {
|
||||
if (step === 0) {
|
||||
step = 1;
|
||||
assert.equal(payload.jsonrpc, '2.0');
|
||||
assert.equal(payload.method, 'web3_sha3');
|
||||
assert.equal(payload.params[0], web3.fromAscii('balance(address)'));
|
||||
} else if (step === 1) {
|
||||
assert.equal(payload.method, 'eth_call');
|
||||
assert.deepEqual(payload.params, [{
|
||||
data: sha3.slice(0, 10) + '0000000000000000000000001234567890123456789012345678901234567890',
|
||||
to: address,
|
||||
from: address,
|
||||
gas: '0xc350'
|
||||
}, 'latest']);
|
||||
}
|
||||
});
|
||||
|
||||
var Contract = web3.eth.contract(desc);
|
||||
var contract = new Contract(address);
|
||||
|
||||
contract.balance.call(address, {from: address, gas: 50000});
|
||||
|
||||
});
|
||||
|
||||
it('should sendTransaction with optional params', function () {
|
||||
var provider = new FakeHttpProvider();
|
||||
web3.setProvider(provider);
|
||||
@ -245,5 +278,40 @@ describe('web3.eth.contract', function () {
|
||||
|
||||
contract.send(address, 17, {from: address, gas: 50000, gasPrice: 3000, value: 10000});
|
||||
});
|
||||
|
||||
it('should explicitly sendTransaction with optional params', function () {
|
||||
var provider = new FakeHttpProvider();
|
||||
web3.setProvider(provider);
|
||||
web3.reset();
|
||||
var sha3 = '0x5131231231231231231231';
|
||||
var address = '0x1234567890123456789012345678901234567890';
|
||||
provider.injectResult(sha3);
|
||||
var step = 0;
|
||||
provider.injectValidation(function (payload) {
|
||||
if (step === 0) {
|
||||
step = 1;
|
||||
assert.equal(payload.jsonrpc, '2.0');
|
||||
assert.equal(payload.method, 'web3_sha3');
|
||||
assert.equal(payload.params[0], web3.fromAscii('send(address,uint256)'));
|
||||
} else if (step === 1) {
|
||||
assert.equal(payload.method, 'eth_sendTransaction');
|
||||
assert.deepEqual(payload.params, [{
|
||||
data: sha3.slice(0, 10) +
|
||||
'0000000000000000000000001234567890123456789012345678901234567890' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000011' ,
|
||||
to: address,
|
||||
from: address,
|
||||
gas: '0xc350',
|
||||
gasPrice: '0xbb8',
|
||||
value: '0x2710'
|
||||
}]);
|
||||
}
|
||||
});
|
||||
|
||||
var Contract = web3.eth.contract(desc);
|
||||
var contract = new Contract(address);
|
||||
|
||||
contract.send.sendTransaction(address, 17, {from: address, gas: 50000, gasPrice: 3000, value: 10000});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user