aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-02-16 07:49:04 +0800
committerGitHub <noreply@github.com>2017-02-16 07:49:04 +0800
commit352bb5cb3941c3a07b383c2400dae337771c6d3a (patch)
treed3db707f1c2e8236c78e143b48e1a2fd9f0323f9 /test
parentcdd4faa917a2f02b531c479eb2f05f39f303d51b (diff)
parentf2539d125c2cfe240511f8505e222a9893bf7748 (diff)
downloadtangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar
tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.gz
tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.bz2
tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.lz
tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.xz
tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.tar.zst
tangerine-wallet-browser-352bb5cb3941c3a07b383c2400dae337771c6d3a.zip
Merge branch 'master' into dev
Diffstat (limited to 'test')
-rw-r--r--test/unit/id-management-test.js2
-rw-r--r--test/unit/keyrings/simple-test.js42
2 files changed, 42 insertions, 2 deletions
diff --git a/test/unit/id-management-test.js b/test/unit/id-management-test.js
index 25eea8777..cbc6403bc 100644
--- a/test/unit/id-management-test.js
+++ b/test/unit/id-management-test.js
@@ -16,7 +16,7 @@ describe('IdManagement', function() {
})
describe('#signMsg', function () {
- it.skip('passes the dennis test', function() {
+ it('passes the dennis test', function() {
const address = '0x9858e7d8b79fc3e6d989636721584498926da38a'
const message = '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0'
const privateKey = '0x7dd98753d7b4394095de7d176c58128e2ed6ee600abe97c9f6d9fd65015d9b18'
diff --git a/test/unit/keyrings/simple-test.js b/test/unit/keyrings/simple-test.js
index 5fe29a67d..ba7dd448a 100644
--- a/test/unit/keyrings/simple-test.js
+++ b/test/unit/keyrings/simple-test.js
@@ -1,5 +1,7 @@
const assert = require('assert')
const extend = require('xtend')
+const Web3 = require('web3')
+const web3 = new Web3()
const ethUtil = require('ethereumjs-util')
const SimpleKeyring = require('../../../app/scripts/keyrings/simple')
const TYPE_STR = 'Simple Key Pair'
@@ -55,7 +57,7 @@ describe('simple-keyring', function() {
const privateKey = '0x7dd98753d7b4394095de7d176c58128e2ed6ee600abe97c9f6d9fd65015d9b18'
const expectedResult = '0x28fcb6768e5110144a55b2e6ce9d1ea5a58103033632d272d2b5cf506906f7941a00b539383fd872109633d8c71c404e13dba87bc84166ee31b0e36061a69e161c'
- it.skip('passes the dennis test', function(done) {
+ it('passes the dennis test', function(done) {
keyring.deserialize([ privateKey ])
.then(() => {
return keyring.signMessage(address, message)
@@ -65,6 +67,44 @@ describe('simple-keyring', function() {
done()
})
})
+
+ it('reliably can decode messages it signs', function (done) {
+
+ const message = 'hello there!'
+ const msgHashHex = web3.sha3(message)
+ let address
+ let addresses = []
+
+ keyring.deserialize([ privateKey ])
+ .then(() => {
+ keyring.addAccounts(9)
+ })
+ .then(() => {
+ return keyring.getAccounts()
+ })
+ .then((addrs) => {
+ addresses = addrs
+ return Promise.all(addresses.map((address) => {
+ return keyring.signMessage(address, msgHashHex)
+ }))
+ })
+ .then((signatures) => {
+
+ signatures.forEach((sgn, index) => {
+ const address = addresses[index]
+
+ var r = ethUtil.toBuffer(sgn.slice(0,66))
+ var s = ethUtil.toBuffer('0x' + sgn.slice(66,130))
+ var v = ethUtil.bufferToInt(ethUtil.toBuffer('0x' + sgn.slice(130,132)))
+ var m = ethUtil.toBuffer(msgHashHex)
+ var pub = ethUtil.ecrecover(m, v, r, s)
+ var adr = '0x' + ethUtil.pubToAddress(pub).toString('hex')
+
+ assert.equal(adr, address, 'recovers address from signature correctly')
+ })
+ done()
+ })
+ })
})
describe('#addAccounts', function() {