diff options
author | tmashuang <thomas.b.huang@gmail.com> | 2018-05-21 20:59:26 +0800 |
---|---|---|
committer | tmashuang <thomas.b.huang@gmail.com> | 2018-05-21 20:59:26 +0800 |
commit | 13ebb0b455bc775a53b6bb30e675a39d02d8f6f5 (patch) | |
tree | 8e746281051ff1f75b948d89e1053c8da2ffc2cd /test/unit/tx-utils-test.js | |
parent | f279a8e61a3f50326fe9f26b0b860af47cd662fb (diff) | |
download | tangerine-wallet-browser-13ebb0b455bc775a53b6bb30e675a39d02d8f6f5.tar tangerine-wallet-browser-13ebb0b455bc775a53b6bb30e675a39d02d8f6f5.tar.gz tangerine-wallet-browser-13ebb0b455bc775a53b6bb30e675a39d02d8f6f5.tar.bz2 tangerine-wallet-browser-13ebb0b455bc775a53b6bb30e675a39d02d8f6f5.tar.lz tangerine-wallet-browser-13ebb0b455bc775a53b6bb30e675a39d02d8f6f5.tar.xz tangerine-wallet-browser-13ebb0b455bc775a53b6bb30e675a39d02d8f6f5.tar.zst tangerine-wallet-browser-13ebb0b455bc775a53b6bb30e675a39d02d8f6f5.zip |
Moved loose some loose test files to sub folders
Diffstat (limited to 'test/unit/tx-utils-test.js')
-rw-r--r-- | test/unit/tx-utils-test.js | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/test/unit/tx-utils-test.js b/test/unit/tx-utils-test.js deleted file mode 100644 index be16225ba..000000000 --- a/test/unit/tx-utils-test.js +++ /dev/null @@ -1,98 +0,0 @@ -const assert = require('assert') -const txUtils = require('../../app/scripts/controllers/transactions/lib/util') - - -describe('txUtils', function () { - describe('#validateTxParams', function () { - it('does not throw for positive values', function () { - var sample = { - from: '0x1678a085c290ebd122dc42cba69373b5953b831d', - value: '0x01', - } - txUtils.validateTxParams(sample) - }) - - it('returns error for negative values', function () { - var sample = { - from: '0x1678a085c290ebd122dc42cba69373b5953b831d', - value: '-0x01', - } - try { - txUtils.validateTxParams(sample) - } catch (err) { - assert.ok(err, 'error') - } - }) - }) - - describe('#normalizeTxParams', () => { - it('should normalize txParams', () => { - let txParams = { - chainId: '0x1', - from: 'a7df1beDBF813f57096dF77FCd515f0B3900e402', - to: null, - data: '68656c6c6f20776f726c64', - random: 'hello world', - } - - let normalizedTxParams = txUtils.normalizeTxParams(txParams) - - assert(!normalizedTxParams.chainId, 'their should be no chainId') - assert(!normalizedTxParams.to, 'their should be no to address if null') - assert.equal(normalizedTxParams.from.slice(0, 2), '0x', 'from should be hexPrefixd') - assert.equal(normalizedTxParams.data.slice(0, 2), '0x', 'data should be hexPrefixd') - assert(!('random' in normalizedTxParams), 'their should be no random key in normalizedTxParams') - - txParams.to = 'a7df1beDBF813f57096dF77FCd515f0B3900e402' - normalizedTxParams = txUtils.normalizeTxParams(txParams) - assert.equal(normalizedTxParams.to.slice(0, 2), '0x', 'to should be hexPrefixd') - - }) - }) - - describe('#validateRecipient', () => { - it('removes recipient for txParams with 0x when contract data is provided', function () { - const zeroRecipientandDataTxParams = { - from: '0x1678a085c290ebd122dc42cba69373b5953b831d', - to: '0x', - data: 'bytecode', - } - const sanitizedTxParams = txUtils.validateRecipient(zeroRecipientandDataTxParams) - assert.deepEqual(sanitizedTxParams, { from: '0x1678a085c290ebd122dc42cba69373b5953b831d', data: 'bytecode' }, 'no recipient with 0x') - }) - - it('should error when recipient is 0x', function () { - const zeroRecipientTxParams = { - from: '0x1678a085c290ebd122dc42cba69373b5953b831d', - to: '0x', - } - assert.throws(() => { txUtils.validateRecipient(zeroRecipientTxParams) }, Error, 'Invalid recipient address') - }) - }) - - - describe('#validateFrom', () => { - it('should error when from is not a hex string', function () { - - // where from is undefined - const txParams = {} - assert.throws(() => { txUtils.validateFrom(txParams) }, Error, `Invalid from address ${txParams.from} not a string`) - - // where from is array - txParams.from = [] - assert.throws(() => { txUtils.validateFrom(txParams) }, Error, `Invalid from address ${txParams.from} not a string`) - - // where from is a object - txParams.from = {} - assert.throws(() => { txUtils.validateFrom(txParams) }, Error, `Invalid from address ${txParams.from} not a string`) - - // where from is a invalid address - txParams.from = 'im going to fail' - assert.throws(() => { txUtils.validateFrom(txParams) }, Error, `Invalid from address`) - - // should run - txParams.from ='0x1678a085c290ebd122dc42cba69373b5953b831d' - txUtils.validateFrom(txParams) - }) - }) -}) |