Skip to content

Commit

Permalink
Merge branch '1.0' into @types/web3-eth-accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstevens19 authored Feb 25, 2019
2 parents efe8e24 + 03b2d39 commit 2ffee99
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
4 changes: 0 additions & 4 deletions packages/web3-core-helpers/src/Formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@ export const outputTransactionFormatter = (receipt) => {
* @returns {Object}
*/
export const outputTransactionReceiptFormatter = (receipt) => {
if (typeof receipt !== 'object') {
throw new TypeError(`Received receipt is invalid: ${receipt}`);
}

if (receipt.blockNumber !== null) {
receipt.blockNumber = Utils.hexToNumber(receipt.blockNumber);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,4 @@ describe('OutputTransactionReceiptFormatterTest', () => {
]
});
});

it('call outputTransactionReceiptFormatter with invalid argument', () => {
expect(() => {
outputTransactionReceiptFormatter('STRING');
}).toThrow('Received receipt is invalid: STRING');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class GetTransactionReceiptMethod extends AbstractCallMethod {
*/
afterExecution(response) {
if (response !== null) {
return this.formatters.outputTransactionFormatter(response);
return this.formatters.outputTransactionReceiptFormatter(response);
}

return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class TransactionReceiptValidator {
* @returns {Boolean}
*/
isValidReceiptStatus(receipt) {
return receipt.status === true || receipt.status === '0x1' || typeof receipt.status === 'undefined';
return receipt.status === true || typeof receipt.status === 'undefined';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ describe('GetTransactionReceiptMethodTest', () => {
});

it('afterExecution should map the response', () => {
formatters.outputTransactionFormatter.mockReturnValueOnce({empty: false});
formatters.outputTransactionReceiptFormatter.mockReturnValueOnce({empty: false});

expect(method.afterExecution({})).toHaveProperty('empty', false);

expect(formatters.outputTransactionFormatter).toHaveBeenCalledWith({});
expect(formatters.outputTransactionReceiptFormatter).toHaveBeenCalledWith({});
});

it('afterExecution should return null', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ describe('TransactionReceiptValidatorTest', () => {
expect(Utils.hexToNumber).toHaveBeenCalledWith(110);
});

it('calls validate and returns true with undefined status property', () => {
delete receipt.status;

Utils.hexToNumber.mockReturnValueOnce(110);

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

expect(transactionReceiptValidator.validate(receipt, method)).toEqual(true);

expect(Utils.hexToNumber).toHaveBeenCalledWith(110);
});

it('calls validate and returns error because of invalid gasUsage', () => {
Utils.hexToNumber.mockReturnValueOnce(100);

Expand Down

0 comments on commit 2ffee99

Please sign in to comment.