git ssb

1+

Dominic / ssb-keys



Commit b6cf4825e0a4f6e6535fdf0109c9f48414be5b84

test loading presigil legacy edgecase

Dominic Tarr committed on 10/14/2015, 9:22:58 PM
Parent: d8f89fd8a1616d164ee6e69ede47bdeaf92c25ae

Files changed

test/index.jschanged
test/index.jsView
@@ -1,11 +1,12 @@
11 var tape = require('tape')
22 var ssbkeys = require('../')
33 var crypto = require('crypto')
44 var path = require('path').join(__dirname, 'keyfile')
5+var fs = require('fs')
56
67 tape('create and load async', function (t) {
7- try { require('fs').unlinkSync(path) } catch(e) {}
8+ try { fs.unlinkSync(path) } catch(e) {}
89 ssbkeys.create(path, function(err, k1) {
910 if (err) throw err
1011 ssbkeys.load(path, function(err, k2) {
1112 if (err) throw err
@@ -17,9 +18,9 @@
1718 })
1819 })
1920
2021 tape('create and load sync', function (t) {
21- try { require('fs').unlinkSync(path) } catch(e) {}
22+ try { fs.unlinkSync(path) } catch(e) {}
2223 var k1 = ssbkeys.createSync(path)
2324 var k2 = ssbkeys.loadSync(path)
2425 t.equal(k1.id.toString('hex'), k2.id.toString('hex'))
2526 t.equal(k1.private.toString('hex'), k2.private.toString('hex'))
@@ -89,9 +90,9 @@
8990 t.end()
9091 })
9192
9293 tape('create and load async, legacy', function (t) {
93- try { require('fs').unlinkSync(path) } catch(e) {}
94+ try { fs.unlinkSync(path) } catch(e) {}
9495 ssbkeys.create(path, 'k256', function(err, k1) {
9596 if (err) throw err
9697 ssbkeys.load(path, function(err, k2) {
9798 if (err) throw err
@@ -106,9 +107,9 @@
106107 })
107108 })
108109
109110 tape('create and load sync, legacy', function (t) {
110- try { require('fs').unlinkSync(path) } catch(e) {}
111+ try { fs.unlinkSync(path) } catch(e) {}
111112 var k1 = ssbkeys.createSync(path, 'k256', true)
112113 var k2 = ssbkeys.loadSync(path)
113114
114115 console.log(k2)
@@ -152,4 +153,31 @@
152153
153154 t.end()
154155
155156 })
157+
158+tape('create and load presigil-legacy async', function (t) {
159+ try { fs.unlinkSync(path) } catch(e) {}
160+ var keys = ssbkeys.generate('ed25519')
161+ keys.id = keys.id.substring(1)
162+ fs.writeFileSync(path, JSON.stringify(keys))
163+
164+ var k2 = ssbkeys.loadSync(path)
165+ t.equal(k2.id, '@' + keys.id)
166+ t.end()
167+
168+})
169+
170+tape('create and load presigil-legacy', function (t) {
171+
172+ try { fs.unlinkSync(path) } catch(e) {}
173+ var keys = ssbkeys.generate('ed25519')
174+ keys.id = keys.id.substring(1)
175+ fs.writeFileSync(path, JSON.stringify(keys))
176+
177+ ssbkeys.load(path, function (err, k2) {
178+ if(err) throw err
179+ t.equal(k2.id, '@' + keys.id)
180+ t.end()
181+ })
182+
183+})

Built with git-ssb-web