diff options
author | kumavis <kumavis@users.noreply.github.com> | 2017-03-07 08:51:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-07 08:51:16 +0800 |
commit | 2acf991b67bc42fb904ff77af6ff6a7ca3a683fd (patch) | |
tree | e2c21a396f4cbb4653693082d1a6d2a6bc4e8696 /test/unit | |
parent | e91ddfcacc37c0b45289a6df017c32e803b55d88 (diff) | |
parent | 51aa95a65cf0a12d273fc3655b5407d3e23f1997 (diff) | |
download | tangerine-wallet-browser-2acf991b67bc42fb904ff77af6ff6a7ca3a683fd.tar tangerine-wallet-browser-2acf991b67bc42fb904ff77af6ff6a7ca3a683fd.tar.gz tangerine-wallet-browser-2acf991b67bc42fb904ff77af6ff6a7ca3a683fd.tar.bz2 tangerine-wallet-browser-2acf991b67bc42fb904ff77af6ff6a7ca3a683fd.tar.lz tangerine-wallet-browser-2acf991b67bc42fb904ff77af6ff6a7ca3a683fd.tar.xz tangerine-wallet-browser-2acf991b67bc42fb904ff77af6ff6a7ca3a683fd.tar.zst tangerine-wallet-browser-2acf991b67bc42fb904ff77af6ff6a7ca3a683fd.zip |
Merge pull request #1177 from MetaMask/i1173-ShowPersonalMessage
Render personal_sign messages as utf-8 text
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/components/binary-renderer-test.js | 25 | ||||
-rw-r--r-- | test/unit/personal-message-manager-test.js | 23 |
2 files changed, 47 insertions, 1 deletions
diff --git a/test/unit/components/binary-renderer-test.js b/test/unit/components/binary-renderer-test.js new file mode 100644 index 000000000..3264faddc --- /dev/null +++ b/test/unit/components/binary-renderer-test.js @@ -0,0 +1,25 @@ +var assert = require('assert') +var BinaryRenderer = require('../../../ui/app/components/binary-renderer') + +describe('BinaryRenderer', function() { + + let binaryRenderer + const message = 'Hello, world!' + const buffer = new Buffer(message, 'utf8') + const hex = buffer.toString('hex') + + beforeEach(function() { + binaryRenderer = new BinaryRenderer() + }) + + it('recovers message', function() { + const result = binaryRenderer.hexToText(hex) + assert.equal(result, message) + }) + + + it('recovers message with hex prefix', function() { + const result = binaryRenderer.hexToText('0x' + hex) + assert.equal(result, message) + }) +}) diff --git a/test/unit/personal-message-manager-test.js b/test/unit/personal-message-manager-test.js index 657d5e675..77e1656c5 100644 --- a/test/unit/personal-message-manager-test.js +++ b/test/unit/personal-message-manager-test.js @@ -4,7 +4,7 @@ const EventEmitter = require('events') const PersonalMessageManager = require('../../app/scripts/lib/personal-message-manager') -describe('Transaction Manager', function() { +describe('Personal Message Manager', function() { let messageManager beforeEach(function() { @@ -86,4 +86,25 @@ describe('Transaction Manager', function() { assert.equal(messageManager.getMsg('2').status, 'approved') }) }) + + describe('#normalizeMsgData', function() { + it('converts text to a utf8 buffer', function() { + var input = 'hello' + var output = messageManager.normalizeMsgData(input) + assert.equal(output, '0x68656c6c6f', 'predictably hex encoded') + }) + + it('tolerates a hex prefix', function() { + var input = '0x12' + var output = messageManager.normalizeMsgData(input) + assert.equal(output, '0x12', 'un modified') + }) + + it('tolerates normal hex', function() { + var input = '12' + var output = messageManager.normalizeMsgData(input) + assert.equal(output, '0x12', 'adds prefix') + }) + }) + }) |