From e8a480aac44546e6bd5d7457545bc951a8787814 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Mon, 2 Apr 2018 13:17:54 -0700 Subject: transactions validationt - valdate from field on txParams --- test/unit/tx-gas-util-test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/unit') diff --git a/test/unit/tx-gas-util-test.js b/test/unit/tx-gas-util-test.js index d9a12d1c3..15d412c72 100644 --- a/test/unit/tx-gas-util-test.js +++ b/test/unit/tx-gas-util-test.js @@ -29,4 +29,28 @@ describe('Tx Gas Util', function () { } assert.throws(() => { txGasUtil.validateRecipient(zeroRecipientTxParams) }, Error, 'Invalid recipient address') }) + + it('should error when from is not a hex string', function () { + + // where from is undefined + const txParams = {} + assert.throws(() => { txGasUtil.validateFrom(txParams) }, Error, `Invalid from address ${txParams.from} not a string`) + + // where from is array + txParams.from = [] + assert.throws(() => { txGasUtil.validateFrom(txParams) }, Error, `Invalid from address ${txParams.from} not a string`) + + // where from is a object + txParams.from = {} + assert.throws(() => { txGasUtil.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(() => { txGasUtil.validateFrom(txParams) }, Error, `Invalid from address`) + + // should run + txParams.from ='0x1678a085c290ebd122dc42cba69373b5953b831d' + txGasUtil.validateFrom(txParams) + }) + }) -- cgit