Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with boolean typed receipt status #2548

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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