From 70e14b8a6f050d0304d81067893a32ccd391c404 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 6 Mar 2017 17:36:08 -0800 Subject: Fixed internal encoding test case --- test/unit/personal-message-manager-test.js | 2 +- test/unit/tx-utils-test.js | 38 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 test/unit/tx-utils-test.js (limited to 'test') diff --git a/test/unit/personal-message-manager-test.js b/test/unit/personal-message-manager-test.js index 77e1656c5..20481af40 100644 --- a/test/unit/personal-message-manager-test.js +++ b/test/unit/personal-message-manager-test.js @@ -91,7 +91,7 @@ describe('Personal Message Manager', function() { it('converts text to a utf8 buffer', function() { var input = 'hello' var output = messageManager.normalizeMsgData(input) - assert.equal(output, '0x68656c6c6f', 'predictably hex encoded') + assert.equal(output, '0x00680065006c006c006f', 'predictably hex encoded') }) it('tolerates a hex prefix', function() { diff --git a/test/unit/tx-utils-test.js b/test/unit/tx-utils-test.js new file mode 100644 index 000000000..44d8e13e9 --- /dev/null +++ b/test/unit/tx-utils-test.js @@ -0,0 +1,38 @@ +const assert = require('assert') +const ethUtil = require('ethereumjs-util') +const BN = ethUtil.BN + +const TxUtils = require('../../app/scripts/lib/tx-utils') + + +describe('txUtils', function() { + let txUtils + + before(function() { + txUtils = new TxUtils() + }) + + describe('addGasBuffer', function() { + describe('adds a flat value', function() { + it('over an empty value', function() { + const input = '0x0' + const output = txUtils.addGasBuffer(input) + assert.notEqual(output, input, 'changed the value') + + const inputBn = new BN(input, 'hex') + const outputBn = new BN(output, 'hex') + assert(outputBn.gt(inputBn), 'returns a greater value') + }) + + it('over an value', function() { + const input = '0x123fad' + const output = txUtils.addGasBuffer(input) + assert.notEqual(output, input, 'changed the value') + + const inputBn = new BN(input, 'hex') + const outputBn = new BN(output, 'hex') + assert(outputBn.gt(inputBn), 'returns a greater value') + }) + }) + }) +}) -- cgit v1.2.3 From 99b49b11f61314eee372c6679db3ad7217c7f4f2 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 6 Mar 2017 17:36:37 -0800 Subject: Fix test name --- test/unit/personal-message-manager-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/unit/personal-message-manager-test.js b/test/unit/personal-message-manager-test.js index 20481af40..41ac3db87 100644 --- a/test/unit/personal-message-manager-test.js +++ b/test/unit/personal-message-manager-test.js @@ -88,7 +88,7 @@ describe('Personal Message Manager', function() { }) describe('#normalizeMsgData', function() { - it('converts text to a utf8 buffer', function() { + it('converts text to a utf8 hex string', function() { var input = 'hello' var output = messageManager.normalizeMsgData(input) assert.equal(output, '0x00680065006c006c006f', 'predictably hex encoded') -- cgit v1.2.3 From 6253885e286a554736e2e51736a742d39a377727 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 7 Mar 2017 11:36:13 -0800 Subject: Remove unrelated test file --- test/unit/tx-utils-test.js | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 test/unit/tx-utils-test.js (limited to 'test') diff --git a/test/unit/tx-utils-test.js b/test/unit/tx-utils-test.js deleted file mode 100644 index 44d8e13e9..000000000 --- a/test/unit/tx-utils-test.js +++ /dev/null @@ -1,38 +0,0 @@ -const assert = require('assert') -const ethUtil = require('ethereumjs-util') -const BN = ethUtil.BN - -const TxUtils = require('../../app/scripts/lib/tx-utils') - - -describe('txUtils', function() { - let txUtils - - before(function() { - txUtils = new TxUtils() - }) - - describe('addGasBuffer', function() { - describe('adds a flat value', function() { - it('over an empty value', function() { - const input = '0x0' - const output = txUtils.addGasBuffer(input) - assert.notEqual(output, input, 'changed the value') - - const inputBn = new BN(input, 'hex') - const outputBn = new BN(output, 'hex') - assert(outputBn.gt(inputBn), 'returns a greater value') - }) - - it('over an value', function() { - const input = '0x123fad' - const output = txUtils.addGasBuffer(input) - assert.notEqual(output, input, 'changed the value') - - const inputBn = new BN(input, 'hex') - const outputBn = new BN(output, 'hex') - assert(outputBn.gt(inputBn), 'returns a greater value') - }) - }) - }) -}) -- cgit v1.2.3 From fba7a50e1bad007a94badf990e5ad661d4049409 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 7 Mar 2017 11:43:59 -0800 Subject: Fixed encoding --- test/unit/personal-message-manager-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/unit/personal-message-manager-test.js b/test/unit/personal-message-manager-test.js index 41ac3db87..f2c01392c 100644 --- a/test/unit/personal-message-manager-test.js +++ b/test/unit/personal-message-manager-test.js @@ -91,7 +91,7 @@ describe('Personal Message Manager', function() { it('converts text to a utf8 hex string', function() { var input = 'hello' var output = messageManager.normalizeMsgData(input) - assert.equal(output, '0x00680065006c006c006f', 'predictably hex encoded') + assert.equal(output, '0x68656c6c6f', 'predictably hex encoded') }) it('tolerates a hex prefix', function() { -- cgit v1.2.3