Address feedback

This commit is contained in:
Andre Medeiros 2018-09-11 14:48:46 -04:00
parent 799a87f35e
commit 29c1ea39f8
1 changed files with 6 additions and 8 deletions

View File

@ -112,28 +112,26 @@ class Test {
// 3) Once we get the receipt back, we dispatch the real call and pass the original callback;
//
// This will still allow tests to get the return value from the call and run contracts unmodified.
simProvider.realSendAsync = simProvider.sendAsync;
simProvider.realSendAsync = simProvider.sendAsync.bind(simProvider);
simProvider.sendAsync = function(payload, cb) {
if(payload.method !== 'eth_call') {
return simProvider.realSendAsync.apply(simProvider.realSendAsync, [payload, cb]);
return simProvider.realSendAsync(payload, cb);
}
let newParams = Object.assign({}, payload.params[0], {gasPrice: '0x77359400'});
let newPayload = {
id: parseInt(Math.random(1000000) * 1000000, 10),
id: payload.id + 1,
method: 'eth_sendTransaction',
params: [newParams],
jsonrpc: payload.jsonrpc
};
let txCallback = (_err, response) => {
simProvider.realSendAsync(newPayload, (_err, response) => {
let txHash = response.result;
self.web3.eth.getTransactionReceipt(txHash, (_err, _res) => {
simProvider.realSendAsync.apply(simProvider.realSendAsync, [payload, cb]);
simProvider.realSendAsync(payload, cb);
});
};
simProvider.realSendAsync.apply(simProvider.realSendAsync, [newPayload, txCallback]);
});
};
this.web3.setProvider(simProvider);