Skip to content

Commit

Permalink
Merge branch 'testing/accounts-module' of github.com:ethereum/web3.js…
Browse files Browse the repository at this point in the history
… into testing/accounts-module
  • Loading branch information
Samuel Furter committed Mar 28, 2019
2 parents 881b7df + 34c14c7 commit 296dad3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,6 @@ export default class AbstractObservedTransactionMethod extends AbstractMethod {
* @returns {Boolean}
*/
hasRevertReceiptStatus(receipt) {
return Boolean(parseInt(receipt.status)) === false && receipt.status !== undefined && receipt.status !== null;
return receipt.status === false && receipt.status !== undefined && receipt.status !== null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('AbstractObservedTransactionMethodTest', () => {
providerMock.send.mockReturnValueOnce(Promise.resolve('transactionHash'));

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

complete();
});
Expand All @@ -78,17 +78,17 @@ describe('AbstractObservedTransactionMethodTest', () => {
promiEvent.on('transactionHash', transactionHashCallback);
promiEvent.on('confirmation', confirmationCallback);
promiEvent.on('receipt', (receipt) => {
expect(receipt).toEqual({status: '0x1'});
expect(receipt).toEqual({status: true});

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

expect(beforeExecutionMock).toHaveBeenCalledWith(moduleInstanceMock);

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

expect(transactionHashCallback).toHaveBeenCalledWith('transactionHash');

expect(confirmationCallback).toHaveBeenCalledWith(0, {status: '0x1'});
expect(confirmationCallback).toHaveBeenCalledWith(0, {status: true});

done();
});
Expand Down Expand Up @@ -120,18 +120,18 @@ describe('AbstractObservedTransactionMethodTest', () => {
providerMock.send.mockReturnValueOnce(Promise.resolve('transactionHash'));

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

complete();
});

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

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

expect(beforeExecutionMock).toHaveBeenCalledWith(moduleInstanceMock);

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

it('calls execute and returns with the expected rejected Promise', async () => {
Expand All @@ -152,15 +152,15 @@ describe('AbstractObservedTransactionMethodTest', () => {
providerMock.send.mockReturnValueOnce(Promise.resolve('transactionHash'));

observableMock.subscribe = jest.fn((next, error, complete) => {
next({count: 0, receipt: {status: '0x0', gasUsed: 1}});
next({count: 0, receipt: {status: false, gasUsed: 1}});

complete();
});

method.parameters = [{gas: 0}];

await expect(method.execute()).rejects.toThrow(
`Transaction has been reverted by the EVM:\n${JSON.stringify({status: '0x0', gasUsed: 1}, null, 2)}`
`Transaction has been reverted by the EVM:\n${JSON.stringify({status: false, gasUsed: 1}, null, 2)}`
);

expect(providerMock.send).toHaveBeenCalledWith('rpcMethod', method.parameters);
Expand All @@ -170,7 +170,7 @@ describe('AbstractObservedTransactionMethodTest', () => {
providerMock.send.mockReturnValueOnce(Promise.resolve('transactionHash'));

observableMock.subscribe = jest.fn((next, error, complete) => {
next({count: 0, receipt: {status: '0x0', gasUsed: 1}});
next({count: 0, receipt: {status: false, gasUsed: 1}});

complete();
});
Expand All @@ -179,7 +179,7 @@ describe('AbstractObservedTransactionMethodTest', () => {

await expect(method.execute()).rejects.toThrow(
`Transaction ran out of gas. Please provide more gas:\n${JSON.stringify(
{status: '0x0', gasUsed: 1},
{status: false, gasUsed: 1},
null,
2
)}`
Expand Down

0 comments on commit 296dad3

Please sign in to comment.