Skip to content

Commit

Permalink
Fix issue with boolean typed receipt status
Browse files Browse the repository at this point in the history
  • Loading branch information
angus-hamill committed Mar 21, 2019
1 parent 1a7c600 commit 2f8e92f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export default class AbstractObservedTransactionMethod extends AbstractMethod {
* @returns {Boolean}
*/
hasRevertReceiptStatus(receipt) {
if (typeof receipt.status === 'boolean') {
return !receipt.status;
}
return Boolean(parseInt(receipt.status)) === false && receipt.status !== undefined && receipt.status !== null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ describe('AbstractObservedTransactionMethodTest', () => {
expect(afterExecutionMock).toHaveBeenCalledWith({status: '0x1'});
});

it('calls execute and returns with the expected resolved Promise when the status is a boolean', async () => {
providerMock.send.mockReturnValueOnce(Promise.resolve('transactionHash'));

observableMock.subscribe = jest.fn((next, error, complete) => {
next({count: 0, receipt: {status: true}});

complete();
});

await expect(method.execute()).resolves.toEqual({status: true});

expect(providerMock.send).toHaveBeenCalledWith('rpcMethod', []);

expect(beforeExecutionMock).toHaveBeenCalledWith(moduleInstanceMock);

expect(afterExecutionMock).toHaveBeenCalledWith({status: true});
});

it('calls execute and returns with the expected rejected Promise', async () => {
providerMock.send.mockReturnValueOnce(Promise.resolve('transactionHash'));

Expand Down

0 comments on commit 2f8e92f

Please sign in to comment.