Skip to content

Commit

Permalink
Merge f77cd3f into 12592fe
Browse files Browse the repository at this point in the history
  • Loading branch information
nivida committed Jun 4, 2019
2 parents 12592fe + f77cd3f commit 2e71888
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/web3-providers/src/batch-request/BatchRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class BatchRequest {
let mappedResult;

// TODO: Find a better handling for custom behaviours in a batch request (afterBatchRequest?)
if (method.Type === 'eth-send-transaction-method') {
if (method.Type === 'eth-send-transaction-method' || method.Type === 'observed-transaction-method') {
mappedResult = responseItem.result;
} else {
mappedResult = method.afterExecution(responseItem.result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,30 @@ describe('BatchRequestTest', () => {
expect(JsonRpcMapper.toPayload).toHaveBeenCalledWith('rpc_method', [true]);
});

it('calls execute with the SendRawTransactionMethod and returns a resolved promise', async () => {
JsonRpcResponseValidator.validate.mockReturnValueOnce(true);

JsonRpcMapper.toPayload.mockReturnValueOnce({});

providerMock.sendPayload = jest.fn((payload) => {
expect(payload).toEqual([{}]);

return Promise.resolve([{result: true}]);
});

abstractMethodMock.Type = 'observed-transaction-method';
batchRequest.add(abstractMethodMock);

await expect(batchRequest.execute()).resolves.toEqual({
methods: [abstractMethodMock],
response: [true]
});

expect(JsonRpcResponseValidator.validate).toHaveBeenCalled();

expect(JsonRpcMapper.toPayload).toHaveBeenCalledWith('rpc_method', [true]);
});

it('calls execute with accounts defined and returns a resolved promise', async () => {
JsonRpcResponseValidator.validate.mockReturnValueOnce(false);

Expand Down

0 comments on commit 2e71888

Please sign in to comment.