UNPKG

1.33 kBtext/coffeescriptView Raw
1chaiAsPromised = require 'chai-as-promised'
2chai = require 'chai'
3chai.use chaiAsPromised
4expect = chai.expect
5
6Custodian = require '../lib/custodian'
7Envelope = require 'ecc-envelope'
8
9_ = require 'lodash'
10bs = require 'bs58check'
11ecc = require 'ecc-tools'
12
13describe 'Custodian', ->
14 before ->
15 @custodian = Custodian()
16 @barHash = bs.decode('aYSAd13fa7mzsguAoaXnecLfpTDKziwQ4BN2r3QLdi4QcLVZZ')
17
18 describe 'data', ->
19 it 'should allow me to put a value and get a the hash', ->
20 result = @custodian.data.put('bar')
21 expect(result).to.eventually.deep.equal(@barHash)
22
23 it 'should allow me to get a value from the hash', ->
24 result = @custodian.data.get(@barHash)
25 expect(result).to.eventually.equal('bar')
26
27 describe 'document', ->
28 before ->
29 @privateKey = ecc.privateKey()
30 @publicKey = ecc.publicKey(@privateKey, true)
31 @envelope = Envelope(send: {hello: 'world'}, from: @privateKey)
32
33 it 'should allow me to put a value and get a the key', ->
34 result = @custodian.document.put(@envelope.encode())
35 expect(result).to.eventually.deep.equal(@publicKey)
36
37 it 'should allow me to get a value from the key', ->
38 result = @custodian.document.get(@publicKey)
39 @envelope.encode().then (envelope) ->
40 expect(result).to.eventually.deep.equal(envelope)