-
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.
* Add stripHexPrefix * Init stripHexPrefix test * Add stripHexPrefix method * Add stripHexPrefix * Add stripHexPrefix * Remove console.log * Use existing isHex to check * Update import path for utils package, change test from strictEqual to deepEqual * Correct regex * Extra additional test * Add ganache CI test fix
- Loading branch information
1 parent
edf481d
commit ee8bec9
Showing
7 changed files
with
106 additions
and
0 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
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,54 @@ | ||
var chai = require('chai'); | ||
var utils = require('../packages/web3-utils'); | ||
|
||
var BigNumber = require('bignumber.js'); | ||
var BN = require('bn.js'); | ||
|
||
var assert = chai.assert; | ||
|
||
var tests = [ | ||
{ value: '1', expected: '1' }, | ||
{ value: '0x1', expected: '1'}, | ||
{ value: '0xf', expected: 'f'}, | ||
{ value: '-1', expected: '-1'}, | ||
{ value: '-0x1', expected: '-1'}, | ||
{ value: '-15', expected: '-15'}, | ||
{ value: '-0xf', expected: '-f'}, | ||
{ value: '0x657468657265756d', expected: '657468657265756d'}, | ||
{ value: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'}, | ||
{ value: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '-ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'}, | ||
{ value: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'}, | ||
{ value: 0, expected: 0}, | ||
{ value: '0', expected: '0'}, | ||
{ value: '0x0', expected: '0'}, | ||
{ value: -0, expected: -0}, | ||
{ value: '-0', expected: '-0'}, | ||
{ value: '-0x0', expected: '-0'}, | ||
{ value: [1,2,3,{test: 'data'}], expected: [1,2,3,{test: 'data'}]}, | ||
{ value: {test: 'test'}, expected: {test: 'test'}}, | ||
{ value: '{"test": "test"}', expected: '{"test": "test"}'}, | ||
{ value: 'myString', expected: 'myString'}, | ||
{ value: 'myString 34534!', expected: 'myString 34534!'}, | ||
{ value: new BN(15), expected: new BN(15)}, | ||
{ value: new BigNumber(15), expected: new BigNumber(15)}, | ||
{ value: 'Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/', expected: 'Heeäööä👅D34ɝɣ24Єͽ-.,äü+#/'}, | ||
{ value: true, expected: true}, | ||
{ value: false, expected: false}, | ||
{ value: 'ff\u0003\u0000\u0000\u00005èÆÕL]\u0012|ξ\u001a7«\u00052\u0011(ÐY\n<\u0010\u0000\u0000\u0000\u0000\u0000\u0000e!ßd/ñõì\f:z¦Î¦±ç·÷Í¢Ëß\u00076* \bñùC1ÉUÀé2\u001aÓB', | ||
expected: 'ff\u0003\u0000\u0000\u00005èÆÕL]\u0012|ξ\u001a7«\u00052\u0011(ÐY\n<\u0010\u0000\u0000\u0000\u0000\u0000\u0000e!ßd/ñõì\f:z¦Î¦±ç·÷Í¢Ëß\u00076* \bñùC1ÉUÀé2\u001aÓB'}, | ||
{ value: '\u0003\u0000\u0000\u00005èÆÕL]\u0012|ξ\u001a7«\u00052\u0011(ÐY\n<\u0010\u0000\u0000\u0000\u0000\u0000\u0000e!ßd/ñõì\f:z¦Î¦±ç·÷Í¢Ëß\u00076* \bñùC1ÉUÀé2\u001aÓB', | ||
expected: '\u0003\u0000\u0000\u00005èÆÕL]\u0012|ξ\u001a7«\u00052\u0011(ÐY\n<\u0010\u0000\u0000\u0000\u0000\u0000\u0000e!ßd/ñõì\f:z¦Î¦±ç·÷Í¢Ëß\u00076* \bñùC1ÉUÀé2\u001aÓB'}, | ||
{ value: '내가 제일 잘 나가', expected: '내가 제일 잘 나가'}, | ||
{ value: Buffer.from('100'), expected: Buffer.from('100')}, | ||
{ value: '0xfffff0x0fffffffffff0xffffff0x', expected: '0xfffff0x0fffffffffff0xffffff0x'} | ||
]; | ||
|
||
describe('lib/utils/utils', function () { | ||
describe('stripHexPrefix', function () { | ||
tests.forEach(function (test) { | ||
it('should turn ' + test.value + ' to ' + test.expected, function () { | ||
assert.deepEqual(utils.stripHexPrefix(test.value), test.expected); | ||
}); | ||
}); | ||
}); | ||
}); |
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