-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.x' into feature/add-goerli-identification-support-1.x
- Loading branch information
Showing
15 changed files
with
220 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
var assert = require('assert'); | ||
var formatters = require('../packages/web3-core-helpers/src/formatters.js'); | ||
|
||
describe('outputTransactionReceiptFormatter', function() { | ||
|
||
it('call outputTransactionReceiptFormatter with a valid receipt', function() { | ||
var receipt = { | ||
status: '0x0', | ||
cumulativeGasUsed: '0x100', | ||
gasUsed: '0x100', | ||
blockNumber: '0x100', | ||
transactionIndex: '0xa', | ||
to: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
from: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
contractAddress: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078' | ||
}; | ||
|
||
assert.deepEqual(formatters.outputTransactionReceiptFormatter(receipt), { | ||
status: false, | ||
cumulativeGasUsed: 256, | ||
gasUsed: 256, | ||
blockNumber: 256, | ||
transactionIndex: 10, | ||
to: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
from: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
contractAddress: '0x03C9A938fF7f54090d0d99e2c6f80380510Ea078' | ||
}); | ||
}); | ||
|
||
it('call outputTransactionReceiptFormatter with a valid receipt and logs', function() { | ||
var receipt = { | ||
status: '0x0', | ||
cumulativeGasUsed: '0x100', | ||
gasUsed: '0x100', | ||
blockNumber: '0x100', | ||
transactionIndex: '0xa', | ||
to: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
from: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
contractAddress: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
logs: [{}] | ||
}; | ||
|
||
assert.deepEqual(formatters.outputTransactionReceiptFormatter(receipt), { | ||
status: false, | ||
cumulativeGasUsed: 256, | ||
gasUsed: 256, | ||
blockNumber: 256, | ||
transactionIndex: 10, | ||
to: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
from: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
contractAddress: '0x03C9A938fF7f54090d0d99e2c6f80380510Ea078', | ||
logs: [ | ||
{ | ||
blockNumber: undefined, | ||
id: null, | ||
logIndex: undefined, | ||
transactionIndex: undefined | ||
} | ||
] | ||
}); | ||
}); | ||
|
||
it('call outputTransactionReceiptFormatter when status is "0x1"', function() { | ||
var receipt = { | ||
status: '0x1', | ||
cumulativeGasUsed: '0x100', | ||
gasUsed: '0x100', | ||
blockNumber: '0x100', | ||
transactionIndex: '0xa', | ||
to: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
from: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
contractAddress: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078' | ||
}; | ||
|
||
assert.equal(formatters.outputTransactionReceiptFormatter(receipt).status, true) | ||
}); | ||
|
||
it('call outputTransactionReceiptFormatter when status is "0x01"', function() { | ||
var receipt = { | ||
status: '0x01', | ||
cumulativeGasUsed: '0x100', | ||
gasUsed: '0x100', | ||
blockNumber: '0x100', | ||
transactionIndex: '0xa', | ||
to: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
from: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
contractAddress: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078' | ||
}; | ||
|
||
assert.equal(formatters.outputTransactionReceiptFormatter(receipt).status, true) | ||
}); | ||
|
||
it('call outputTransactionReceiptFormatter when status is "undefined"', function() { | ||
var receipt = { | ||
status: undefined, | ||
cumulativeGasUsed: '0x100', | ||
gasUsed: '0x100', | ||
blockNumber: '0x100', | ||
transactionIndex: '0xa', | ||
to: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
from: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
contractAddress: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078' | ||
}; | ||
|
||
assert.equal(formatters.outputTransactionReceiptFormatter(receipt).status, undefined) | ||
}); | ||
|
||
it('call outputTransactionReceiptFormatter when status is "null"', function() { | ||
var receipt = { | ||
status: null, | ||
cumulativeGasUsed: '0x100', | ||
gasUsed: '0x100', | ||
blockNumber: '0x100', | ||
transactionIndex: '0xa', | ||
to: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
from: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078', | ||
contractAddress: '0x03c9a938ff7f54090d0d99e2c6f80380510ea078' | ||
}; | ||
|
||
assert.equal(formatters.outputTransactionReceiptFormatter(receipt).status, null) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var chai = require('chai'); | ||
var utils = require('../packages/web3-utils'); | ||
|
||
var assert = chai.assert; | ||
|
||
// Expect 2 chars per bytes plus `0x` prefix | ||
var tests = [ | ||
{ value: 0, expected: { prefix: '0x', type: 'string', length: 2 }}, | ||
{ value: 15, expected: { prefix: '0x', type: 'string', length: 32 }}, | ||
{ value: 16, expected: { prefix: '0x', type: 'string', length: 34 }} | ||
]; | ||
|
||
describe('lib/utils/utils', function () { | ||
describe('randomHex', function () { | ||
tests.forEach(function (test) { | ||
it('should turn ' + test.value + ' to ' + test.expected, function () { | ||
var result = utils.randomHex(test.value); | ||
|
||
assert.strictEqual(typeof result, test.expected.type); | ||
assert.strictEqual(result.slice(0,2), test.expected.prefix); | ||
assert.strictEqual(result.length, test.expected.length); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters