-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrevoke.js
64 lines (53 loc) · 1.42 KB
/
revoke.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const context = require('ara-context')()
const bip39 = require('bip39')
const test = require('ava')
const { revoke } = require('../revoke')
test('revoke() invalid opts', async (t) => {
t.plan(9)
const mnemonic = bip39.generateMnemonic()
await t.throwsAsync(
revoke(),
{ instanceOf: TypeError },
'Expecting opts to be an object.'
)
await t.throwsAsync(
revoke({ }),
{ instanceOf: TypeError },
'Expecting web3 context object.'
)
await t.throwsAsync(
revoke({ context: 'web3' }),
{ instanceOf: TypeError },
'Expecting web3 context object.'
)
await t.throwsAsync(
revoke({ context }),
{ instanceOf: TypeError },
'Expecting mnemonic for revoking.'
)
await t.throwsAsync(
revoke({ context, mnemonic: 1234 }),
{ instanceOf: TypeError },
'Expecting mnemonic to be a string.'
)
await t.throwsAsync(
revoke({ context, mnemonic }),
{ instanceOf: TypeError },
'Expecting password.'
)
await t.throwsAsync(
revoke({ context, mnemonic: 'hello' }),
{ instanceOf: TypeError },
'Expecting a valid bip39 mnemonic for revoking.'
)
await t.throwsAsync(
revoke({ context, mnemonic, password: 1234 }),
{ instanceOf: TypeError },
'Expecting password to be a string.'
)
await t.throwsAsync(
revoke({ context, mnemonic, password: 'test' }),
{ instanceOf: Error },
'Could not resolve DID for the provided mnemonic'
)
})